/* Gable — 写真を引き立てる、石と紙のような落ち着いた配色 */
:root {
  --bg: #f3efe7;
  --surface: #fbf9f4;
  --surface-2: #ebe5da;
  --ink: #1f1c18;
  --ink-2: #5d564c;
  --ink-3: #8a8275;
  --line: #ddd5c7;
  --accent: #9a4a2b;      /* テラコッタ */
  --accent-ink: #fff8f2;
  --good: #3f6b4a;
  --bar: #c9b99f;
  --shadow: 0 1px 2px rgb(40 30 20 / 0.06), 0 8px 24px rgb(40 30 20 / 0.08);
  --radius: 14px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, "Hiragino Mincho ProN", "Yu Mincho", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Hiragino Sans", "Yu Gothic UI", "Noto Sans JP", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151412;
    --surface: #1e1c19;
    --surface-2: #2a2723;
    --ink: #eee8de;
    --ink-2: #b5ac9e;
    --ink-3: #847b6e;
    --line: #35312b;
    --accent: #d98a62;
    --accent-ink: #1b120c;
    --good: #8fc09b;
    --bar: #6b5f4d;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 8px 24px rgb(0 0 0 / 0.35);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
a { color: inherit; }
[hidden] { display: none !important; }

.app {
  max-width: 520px;
  margin: 0 auto;
  padding: 0 16px calc(24px + env(safe-area-inset-bottom));
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* 見出し */
.top {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 56px;
  padding-top: env(safe-area-inset-top);
}
.brand { display: flex; align-items: center; gap: 7px; text-decoration: none; }
.brand-mark { width: 26px; height: 26px; color: var(--accent); }
.brand-name { font: 600 23px/1 var(--serif); letter-spacing: 0.01em; }
.number { color: var(--ink-3); font-size: 14px; font-variant-numeric: tabular-nums; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.pill, .icon-btn {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  height: 36px;
  cursor: pointer;
}
.pill { padding: 0 12px; font-size: 14px; }
.icon-btn { width: 36px; display: grid; place-items: center; padding: 0; }
.icon-btn svg { width: 20px; height: 20px; }

.preview {
  display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center;
  margin: 0 0 10px; padding: 8px 12px; border-radius: 10px;
  background: var(--accent); color: var(--accent-ink); font-size: 14px;
}
.preview select { background: var(--surface); color: var(--ink); border-radius: 6px; border: 0; padding: 2px 6px; }

/* 写真：画面の主役。大きさを最初から確保して、読み込み中も画面が揺れないようにする */
.photo {
  margin: 0;
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface-2);
  box-shadow: var(--shadow);
}
.photo img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transition: opacity 0.35s ease;
}
.photo img.ready { opacity: 1; }
/* 終わったら全体写真を、写真本来の縦横比で見せる */
.photo.full { aspect-ratio: auto; }
.photo.full img { height: auto; object-fit: contain; }
.stages {
  position: absolute; left: 0; right: 0; bottom: 10px;
  display: flex; justify-content: center; gap: 6px;
}
.stages button {
  width: 26px; height: 26px; padding: 0; border: 0; background: none; cursor: pointer;
  display: grid; place-items: center;
}
.stages button::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%;
  background: rgb(255 255 255 / 0.45); box-shadow: 0 0 0 1px rgb(0 0 0 / 0.15);
  transition: transform 0.2s, background 0.2s;
}
.stages button.open::before { background: rgb(255 255 255 / 0.9); }
.stages button.current::before { background: #fff; transform: scale(1.35); }
.stages button:disabled { cursor: default; }

.tagline { margin: 12px 2px 10px; color: var(--ink-2); font-size: 15px; text-align: center; }

/* ヒント：4つの枠を最初から並べ、開いたら中身が出る（並びが動かない） */
.hints {
  list-style: none; margin: 0 0 12px; padding: 0;
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
}
.hints li {
  min-height: 52px; padding: 7px 10px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--line);
  display: flex; flex-direction: column; justify-content: center;
}
.hints .k { font-size: 11px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-3); }
.hints .v { font-size: 14px; line-height: 1.3; font-weight: 600; }
.hints li.locked .v { color: var(--ink-3); font-weight: 400; }
.hints li.fresh { animation: pop 0.45s ease; }
@keyframes pop { from { background: var(--surface-2); } }

/* 回答欄 */
.guess-form { display: flex; gap: 8px; }
.field { position: relative; flex: 1; }
.field input {
  width: 100%; height: 50px; padding: 0 14px;
  border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface);
  font-size: 17px; /* 16px以上にして、iPhoneで勝手に拡大されるのを防ぐ */
  outline: none;
}
.field input:focus { border-color: var(--accent); }
.primary {
  height: 50px; padding: 0 18px; border: 0; border-radius: 12px; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); font-weight: 650;
}
.primary:disabled { opacity: 0.5; cursor: default; }
.wide { width: 100%; }
.ghost { height: 46px; border-radius: 12px; border: 1px solid var(--line); background: none; cursor: pointer; }

/* 候補：回答欄の上に開く（キーボードに隠れない） */
.suggest {
  position: absolute; left: 0; right: 0; bottom: calc(100% + 6px); z-index: 5;
  list-style: none; margin: 0; padding: 4px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
}
.suggest li {
  padding: 11px 12px; border-radius: 8px; cursor: pointer;
  display: flex; justify-content: space-between; gap: 10px;
}
.suggest li .alt { color: var(--ink-3); font-size: 14px; }
.suggest li[aria-selected="true"], .suggest li:hover { background: var(--surface-2); }
.suggest li.empty { color: var(--ink-3); cursor: default; }

.toast { min-height: 22px; margin: 6px 2px 0; font-size: 14px; color: var(--accent); }

/* 外れた回答の一覧 */
.guesses { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 6px; }
.guesses li {
  height: 46px; padding: 0 12px; border-radius: 10px;
  display: grid; grid-template-columns: 1fr auto 34px 46px; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}
.guesses li.empty { background: transparent; border-style: dashed; }
.guesses li.hit { border-color: var(--good); color: var(--good); font-weight: 650; }
.guesses li > * { line-height: 1.2; align-self: center; }
.guesses .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.guesses .dist { color: var(--ink-2); font-size: 14px; }
.guesses .dir { font-size: 18px; text-align: center; }
.guesses .prox { position: relative; height: 22px; border-radius: 6px; background: var(--surface-2); overflow: hidden; font-size: 12px; text-align: center; line-height: 22px; }
.guesses .prox i { position: absolute; inset: 0 auto 0 0; background: var(--bar); }
.guesses .prox span { position: relative; }
.guesses li.fresh { animation: slide 0.35s ease; }
@keyframes slide { from { transform: translateY(-6px); opacity: 0; } }

/* 結果 */
.result {
  padding: 16px; border-radius: var(--radius); background: var(--surface);
  border: 1px solid var(--line); margin-bottom: 10px;
}
.result-head { margin: 0; font-weight: 650; color: var(--accent); }
.result-name { margin: 2px 0 0; font: 600 26px/1.2 var(--serif); }
.result-place { margin: 4px 0 12px; color: var(--ink-2); }
.result-facts { margin: 0 0 10px; display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; font-size: 14px; }
.result-facts dt { color: var(--ink-3); }
.result-facts dd { margin: 0; }
.result-fact { margin: 0 0 10px; }
.result-fact a, .result-credit a { color: var(--ink-2); }
.result-credit { margin: 0 0 14px; font-size: 12.5px; color: var(--ink-3); }
.mini-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 14px 0 6px; text-align: center; }
.mini-stats b { display: block; font-size: 22px; font-variant-numeric: tabular-nums; }
.mini-stats span { font-size: 11.5px; color: var(--ink-3); }
.next { margin: 8px 0 0; text-align: center; color: var(--ink-2); font-size: 14px; font-variant-numeric: tabular-nums; }
.slot:empty { display: none; } /* 将来の広告枠。中身が入るまで場所を取らない */

/* お知らせ（準備中・公開前） */
.notice { flex: 1; display: grid; place-content: center; text-align: center; padding: 40px 12px; }
.notice-mark { width: 56px; height: 56px; margin: 0 auto 10px; color: var(--accent); }
.notice p { margin: 0 0 6px; font-size: 17px; }

.foot { margin-top: auto; padding-top: 28px; display: flex; justify-content: center; gap: 18px; font-size: 13px; color: var(--ink-3); }
.foot a { text-decoration: none; }
.foot a:hover { text-decoration: underline; }

/* 成績の画面 */
.sheet {
  width: min(440px, calc(100% - 32px)); border: 0; border-radius: 18px; padding: 20px;
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow);
}
.sheet::backdrop { background: rgb(20 15 10 / 0.45); }
.sheet h2 { margin: 0 0 14px; font: 600 22px/1.2 var(--serif); }
.sheet h3 { margin: 18px 0 8px; font-size: 13px; color: var(--ink-3); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); text-align: center; gap: 6px; }
.stat-grid b { display: block; font-size: 26px; font-variant-numeric: tabular-nums; }
.stat-grid span { font-size: 12px; color: var(--ink-3); }
.dist-chart { display: grid; gap: 5px; margin-bottom: 18px; }
.dist-chart div { display: grid; grid-template-columns: 16px 1fr; gap: 8px; align-items: center; font-size: 13px; font-variant-numeric: tabular-nums; }
.dist-chart i { display: block; min-width: 26px; height: 22px; border-radius: 5px; background: var(--surface-2); color: var(--ink); font-style: normal; text-align: right; padding-right: 7px; line-height: 22px; }
.dist-chart i.now { background: var(--accent); color: var(--accent-ink); }

/* サブページ（クレジット・プライバシー） */
.doc { padding: 8px 2px 0; }
.doc h1 { font: 600 28px/1.2 var(--serif); margin: 8px 0 14px; }
.doc h2 { font: 600 19px/1.3 var(--serif); margin: 26px 0 8px; }
.doc p, .doc li { color: var(--ink-2); }
.doc ul { padding-left: 20px; }
.credit-list { list-style: none; padding: 0; display: grid; gap: 10px; }
.credit-list li { padding: 12px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); font-size: 14px; }
.credit-list b { color: var(--ink); }

@media (min-width: 700px) {
  .app { padding-top: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
