/* ============================================================
   style.css — 색상은 맨 위 :root 변수만 바꾸면 전체에 반영돼요
   ============================================================ */
:root{
  /* 테마 색 2가지 (Display P3 지원 화면에서는 아래 @supports 값이 쓰여요) */
  --blue:#1653da;                 /* color(display-p3 0.161 0.322 0.825) */
  --mint:#ccfdde;                 /* color(display-p3 0.838 0.987 0.879) */

  --bg:#f3fcf6; --card:#ffffff; --ink:#13203f; --sub:#5f6b85; --line:#d7e8de;
  --accent:var(--blue);           /* 버튼·진행바 등 채우는 색 */
  --accent-ink:var(--blue);       /* 글자에 쓰는 강조색 */
  --accent-soft:rgba(22,83,218,.10);
  --mint-soft:var(--mint);        /* 태그·안내 박스 배경 */
  --mint-ink:#0f3a9e;             /* 민트 배경 위 글자 */
  --stage:#0d1530;                /* 짤 박스 배경 */
}
@supports (color: color(display-p3 0 0 0)){
  :root{
    --blue:color(display-p3 0.161 0.322 0.825);
    --mint:color(display-p3 0.838 0.987 0.879);
  }
}
@media (prefers-color-scheme: dark){
  :root{
    --bg:#0b1226; --card:#131c35; --ink:#eaf1ff; --sub:#93a0bd; --line:#233052;
    --accent-ink:#8fb0ff;         /* 어두운 배경에서 읽히도록 같은 블루를 밝게 */
    --accent-soft:rgba(143,176,255,.14);
    --mint-soft:rgba(204,253,222,.12);
    --mint-ink:var(--mint);
    --stage:#050a18;
  }
}
*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0; background:var(--bg); color:var(--ink);
  font-family:-apple-system,BlinkMacSystemFont,"Pretendard","Apple SD Gothic Neo","Malgun Gothic","Noto Sans KR","Segoe UI",Roboto,sans-serif;
  display:flex; justify-content:center;
  padding-top:env(safe-area-inset-top,0px);
  padding-bottom:env(safe-area-inset-bottom,0px);
  -webkit-text-size-adjust:100%;
  word-break:keep-all; overflow-wrap:anywhere;
}
button{ font-family:inherit; }
[hidden]{ display:none !important; }

#app{ width:100%; max-width:520px; padding:20px 16px 40px; }

/* ---------- common ---------- */
.card{ background:var(--card); border:1px solid var(--line); border-radius:20px; padding:20px; margin-bottom:14px; box-shadow:0 4px 18px rgba(0,0,0,.04); }
.btn{
  appearance:none; border:none; border-radius:14px; padding:13px 16px; font-size:15px; font-weight:700;
  cursor:pointer; width:100%; transition:transform .08s ease, opacity .15s ease; color:var(--ink);
  -webkit-tap-highlight-color:transparent; touch-action:manipulation;
}
.btn-lg{ padding:15px 16px; font-size:16px; margin-top:10px; }
.btn:active{ transform:scale(.98); }
.btn-primary{ background:var(--accent); color:#fff; box-shadow:0 6px 16px rgba(22,83,218,.25); }
.btn-outline{ background:var(--card); border:1.5px solid var(--line); }
.btn-ghost{ background:transparent; color:var(--sub); font-weight:600; }
.btn:disabled{ opacity:.45; cursor:default; box-shadow:none; }
.chip-btn{
  appearance:none; border:1px solid var(--line); background:var(--card); color:var(--ink);
  border-radius:999px; padding:7px 12px; font-size:13px; font-weight:700; cursor:pointer;
  -webkit-tap-highlight-color:transparent; touch-action:manipulation; white-space:nowrap;
}
.chip-btn:disabled{ opacity:.35; cursor:default; }
.row{ display:flex; gap:8px; margin-top:6px; }
.row > *{ flex:1; }
.field-label{ display:block; font-size:13px; font-weight:700; color:var(--sub); margin-bottom:6px; }
.field-hint{ color:var(--sub); font-size:12px; margin:6px 0 0; line-height:1.5; }
.field-hint.center{ text-align:center; min-height:1em; }
.field-hint a{ color:var(--accent-ink); font-weight:700; }
.text-input,.select-input{
  width:100%; padding:13px 14px; border-radius:12px; border:1.5px solid var(--line);
  background:var(--bg); color:var(--ink); font-size:16px; /* 16px prevents iOS zoom on focus */
}
.text-input:focus,.select-input:focus{ outline:none; border-color:var(--accent); }
.select-input{
  font-weight:700; appearance:none; -webkit-appearance:none;
  background-image:url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="%238b8394" stroke-width="2.5"><path d="M6 9l6 6 6-6"/></svg>');
  background-repeat:no-repeat; background-position:right 14px center; padding-right:40px;
}
.tag{ display:inline-block; font-size:11px; font-weight:800; color:var(--mint-ink); background:var(--mint-soft); padding:4px 10px; border-radius:999px; }
.center-msg{ text-align:center; color:var(--sub); font-size:14px; padding:28px 8px; list-style:none; }
.config-error{ font-size:14px; line-height:1.6; }
.config-error ul{ margin:8px 0 0; padding-left:18px; color:var(--accent-ink); }

/* ---------- start ---------- */
.hero{ text-align:center; padding:28px 0 20px; }
.hero-emoji{ font-size:52px; line-height:1; filter:drop-shadow(0 6px 12px rgba(22,83,218,.25)); }
.hero-title{
  margin:12px 0 6px; font-size:28px; font-weight:900; letter-spacing:-.03em; line-height:1.25;
  color:var(--accent-ink);
}
.hero-sub{ margin:0; color:var(--sub); font-size:15px; }
.resume-card{ border-color:var(--accent); background:var(--mint-soft); }
.resume-text{ margin:0 0 4px; font-size:14px; font-weight:600; text-align:center; }

/* ---------- play (fills exactly one screen) ---------- */
#app.screen-play{
  max-width:1100px; padding:8px 8px 6px;
  height:100vh; height:100dvh;
  height:calc(100dvh - env(safe-area-inset-top,0px) - env(safe-area-inset-bottom,0px));
  display:flex; flex-direction:column;
}
.play{ flex:1; min-height:0; display:flex; flex-direction:column; gap:6px; }
.play-head{ display:grid; grid-template-columns:1fr auto 1fr; align-items:center; gap:8px; }
.play-head #undoBtn{ justify-self:start; }
.play-head #statsLink{ justify-self:end; }
.round-name{ font-size:26px; font-weight:900; letter-spacing:-.02em; color:var(--accent-ink); line-height:1.1; }
.progress-row{ display:flex; align-items:center; gap:8px; padding:0 4px; }
.progress-bar{ flex:1; height:5px; border-radius:999px; background:var(--mint-soft); overflow:hidden; }
.progress-fill{ height:100%; border-radius:inherit; background:var(--accent); transition:width .3s ease; }
.progress-count{ font-size:11px; font-weight:700; color:var(--sub); font-variant-numeric:tabular-nums; min-width:44px; text-align:right; }
.vs-wrap{ flex:1; min-height:0; display:flex; flex-direction:column; gap:8px; position:relative; }
@media (min-aspect-ratio: 1/1){ .vs-wrap{ flex-direction:row; } }
.pick{
  flex:1; min-height:0; min-width:0; position:relative; cursor:pointer;
  border-radius:16px; overflow:hidden; background:var(--stage);
  outline:3px solid transparent; outline-offset:-3px;
  transition:transform .2s ease, opacity .2s ease, outline-color .15s ease, box-shadow .2s ease;
  -webkit-tap-highlight-color:transparent; touch-action:manipulation;
}
.pick:focus-visible{ outline-color:var(--accent); }
@media (hover:hover){ .pick:hover{ outline-color:rgba(22,83,218,.5); } }
.pick.picked{ transform:scale(1.02); outline-color:var(--accent); box-shadow:0 0 0 5px var(--mint), 0 10px 30px rgba(22,83,218,.35); z-index:2; }
.pick.picked::after{
  content:"✓"; position:absolute; top:10px; right:10px; width:34px; height:34px; border-radius:50%;
  background:var(--accent); color:#fff; font-weight:900; font-size:18px; display:flex; align-items:center; justify-content:center;
  box-shadow:0 4px 12px rgba(0,0,0,.25); animation:pop .25s ease;
}
.pick.not-picked{ opacity:.3; transform:scale(.97); }
@keyframes pop{ from{ transform:scale(.3); opacity:0; } to{ transform:scale(1); opacity:1; } }
.imgwrap{ position:absolute; inset:0; display:flex; align-items:center; justify-content:center; }
.imgwrap img{
  width:100%; height:100%; object-fit:contain; display:block;
  opacity:0; transition:opacity .25s ease;
  -webkit-user-select:none; user-select:none; -webkit-touch-callout:default;
}
.imgwrap img.loaded{ opacity:1; }
.imgspin{ position:absolute; width:26px; height:26px; border-radius:50%; border:3px solid rgba(255,255,255,.2); border-top-color:#fff; animation:spin .8s linear infinite; }
.img-error{ position:absolute; inset:0; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:10px; color:#ddd; font-size:13px; }
.vs-badge{
  position:absolute; left:50%; top:50%; transform:translate(-50%,-50%); z-index:3; pointer-events:none;
  width:40px; height:40px; border-radius:50%; display:flex; align-items:center; justify-content:center;
  background:var(--mint); color:#1653da; font-size:13px; font-weight:900; letter-spacing:-.02em;
  box-shadow:0 4px 14px rgba(0,0,0,.25); border:2px solid var(--accent);
}
.play-hint{ margin:0; text-align:center; font-size:11px; color:var(--sub); }

/* ---------- result ---------- */
.result{ text-align:center; padding-top:6px; }
.result-title{ font-size:22px; font-weight:900; margin:10px 0 14px; letter-spacing:-.02em; }
.result-media{
  position:relative; width:100%; max-width:380px; margin:0 auto; aspect-ratio:600/686;
  border-radius:20px; overflow:hidden; background:var(--stage); box-shadow:0 10px 30px rgba(0,0,0,.12);
}
.result-media img{ width:100%; height:100%; object-fit:contain; display:block; -webkit-touch-callout:default; }
.gen-overlay{
  position:absolute; left:0; right:0; bottom:0; padding:12px; font-size:13px; font-weight:700; color:#fff;
  background:linear-gradient(transparent, rgba(0,0,0,.75));
}
.result .btn-lg{ max-width:380px; margin-left:auto; margin-right:auto; display:block; }
.result .row{ max-width:380px; margin:6px auto 0; }

/* ---------- stats ---------- */
.topbar{ display:flex; justify-content:flex-start; margin-bottom:8px; }
.page-title{ font-size:24px; font-weight:900; margin:6px 0 4px; letter-spacing:-.02em; }
.page-sub{ color:var(--sub); font-size:13px; margin:0 0 14px; }
.rank-list{ list-style:none; margin:0; padding:0; }
.rank-item{ display:grid; grid-template-columns:30px 76px 1fr auto; align-items:center; gap:12px; padding:10px 0; border-bottom:1px solid var(--line); }
.rank-item:last-child{ border-bottom:none; }
.rank-num{ text-align:center; font-weight:900; font-size:16px; color:var(--sub); font-variant-numeric:tabular-nums; }
.rank-item.top1 .rank-num{ color:var(--accent-ink); font-size:22px; }
.rank-item.top2 .rank-num{ color:var(--accent-ink); opacity:.72; font-size:20px; }
.rank-item.top3 .rank-num{ color:var(--accent-ink); opacity:.5; font-size:19px; }
.rank-thumb{ width:76px; height:76px; border-radius:12px; overflow:hidden; background:var(--stage); }
.rank-thumb img{ width:100%; height:100%; object-fit:contain; display:block; }
.rank-bar{ height:10px; border-radius:999px; background:var(--mint-soft); overflow:hidden; }
.rank-bar-fill{ height:100%; border-radius:inherit; background:var(--accent); }
.rank-percent{ font-size:15px; font-weight:800; color:var(--accent-ink); font-variant-numeric:tabular-nums; min-width:52px; text-align:right; }
.rank-pager{ display:flex; align-items:center; justify-content:space-between; margin-top:12px; padding-top:12px; border-top:1px solid var(--line); }
.page-dots{ display:flex; gap:6px; }
.page-dots .dot{ width:7px; height:7px; border-radius:50%; background:var(--line); }
.page-dots .dot.on{ background:var(--accent); }

@keyframes spin{ to{ transform:rotate(360deg); } }
@media (max-width:360px){
  #app{ padding-left:10px; padding-right:10px; }
  .rank-item{ grid-template-columns:24px 60px 1fr auto; gap:8px; }
  .rank-thumb{ width:60px; height:60px; }
}
@media (prefers-reduced-motion: reduce){
  *{ transition:none !important; animation:none !important; }
}
.compare-line{
  margin:-6px auto 14px; max-width:380px; padding:9px 12px; border-radius:12px;
  background:var(--mint-soft); color:var(--mint-ink); font-size:13px; font-weight:700; line-height:1.45;
}
