/* Layout: 1列・最大560px。入口(ゲーム一覧)→ あそぶ → 結果 → 番付 の4画面を切り替える。藍染の札を山吹色で引き立てる。 */
:root {
  --bg: #EAF0F3;
  --surface: #FBFCFD;
  --ink: #16263A;
  --ink-soft: #4A5B70;
  --rule: #C5D0D9;
  --indigo: #1E3F66;
  --card-line: rgba(255, 255, 255, .22);
  --face: #FFFDF6;
  --face-edge: #C9D3DC;
  --gold: #F0B323;
  --gold-ink: #3A2A00;
  --gold-soft: #FFF1C9;
  --ok: #1B7F4B;
  --ok-bg: #DDF2E5;
  --ng: #B3261E;
  --ng-bg: #FBE3E0;
  --c-red: #C62828;
  --c-blue: #1456C4;
  --c-green: #1B7F3B;
  --c-purple: #7B2FA6;
  --focus: #D9480F;

  --font-display: "Kaisei Tokumin", "Hiragino Mincho ProN", "Yu Mincho", serif;
  --font-body: "BIZ UDPGothic", "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0F1722;
    --surface: #18222F;
    --ink: #E8EEF4;
    --ink-soft: #A9B7C6;
    --rule: #2C3A4B;
    --indigo: #2B5486;
    --card-line: rgba(255, 255, 255, .2);
    --face: #EFE9DA;
    --face-edge: #51627A;
    --gold: #F0B323;
    --gold-ink: #2A1E00;
    --gold-soft: #4A3A10;
    --ok: #6FD39B;
    --ok-bg: #173D2A;
    --ng: #FF9A8F;
    --ng-bg: #4A1F1B;
    --c-red: #FF7A70;
    --c-blue: #7FB0FF;
    --c-green: #6FD38A;
    --c-purple: #D49BFF;
    --focus: #FFB08A;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0F1722;
  --surface: #18222F;
  --ink: #E8EEF4;
  --ink-soft: #A9B7C6;
  --rule: #2C3A4B;
  --indigo: #2B5486;
  --card-line: rgba(255, 255, 255, .2);
  --face: #EFE9DA;
  --face-edge: #51627A;
  --gold: #F0B323;
  --gold-ink: #2A1E00;
  --gold-soft: #4A3A10;
  --ok: #6FD39B;
  --ok-bg: #173D2A;
  --ng: #FF9A8F;
  --ng-bg: #4A1F1B;
  --c-red: #FF7A70;
  --c-blue: #7FB0FF;
  --c-green: #6FD38A;
  --c-purple: #D49BFF;
  --focus: #FFB08A;
  color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 20px;
  line-height: 1.7;
  padding-inline: 16px;
  padding-block: 20px 48px;
}
.page { max-width: 560px; margin-inline: auto; }
.screen { display: flex; flex-direction: column; gap: 20px; }
p, h1, h2, h3, ol, ul { margin: 0; padding: 0; }
ol, ul { list-style: none; }
.soft { color: var(--ink-soft); font-size: 1rem; }

h1, h2 {
  font-family: var(--font-display);
  line-height: 1.3;
  letter-spacing: .04em;
  text-wrap: balance;
}
h1 { font-size: 2.1rem; }
h2 { font-size: 1.7rem; }
h3 { font-size: 1.15rem; }
h2:focus { outline: none; }

/* ボタン */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 64px;
  padding: 10px 20px;
  border-radius: 12px;
  border: 2px solid var(--ink);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 1.1rem;
  font-weight: 700;
  text-align: center;
  cursor: pointer;
}
.btn-gold { background: var(--gold); color: var(--gold-ink); border-color: var(--gold); }
.btn-small { min-height: 52px; font-size: 1rem; padding-inline: 16px; }
button:focus-visible, input:focus-visible { outline: 4px solid var(--focus); outline-offset: 3px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 12px; }
.btn-row .btn { flex: 1 1 200px; }

/* 入口 */
.masthead { display: flex; flex-direction: column; gap: 2px; }
.namebox {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
  background: var(--surface);
  border: 2px solid var(--rule);
  border-radius: 14px;
}
.namebox label { font-weight: 700; }
.name-row { display: flex; gap: 10px; }
.name-row input {
  flex: 1 1 0;
  min-width: 0;
  min-height: 56px;
  padding: 6px 14px;
  border: 2px solid var(--ink-soft);
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-size: 1.15rem;
}
.games { display: flex; flex-direction: column; gap: 10px; }
.game-row {
  display: grid;
  grid-template-columns: 60px 1fr auto;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 84px;
  padding: 10px 14px;
  border: 2px solid var(--rule);
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.game-icon {
  display: grid;
  place-items: center;
  width: 60px;
  height: 60px;
  border-radius: 10px;
  background: var(--face);
  border: 2px solid var(--face-edge);
  font-size: 2rem;
  line-height: 1;
}
.game-text { min-width: 0; display: flex; flex-direction: column; }
.game-name { font-size: 1.2rem; font-weight: 700; line-height: 1.4; }
.game-desc { color: var(--ink-soft); font-size: .85rem; line-height: 1.5; }
.game-best { text-align: right; font-size: .8rem; color: var(--ink-soft); line-height: 1.3; white-space: nowrap; }
.game-best b { display: block; font-size: 1.3rem; color: var(--ink); font-variant-numeric: tabular-nums; }

/* あそぶ */
.playbar { display: flex; align-items: center; gap: 14px; }
.playbar h2 { min-width: 0; }
.status {
  padding-block: 8px;
  border-block: 2px solid var(--rule);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.stage { display: flex; flex-direction: column; gap: 16px; }
.message { min-height: 3.4em; font-size: 1.1rem; font-weight: 700; text-wrap: balance; }

/* 問題と選択肢 */
.q {
  padding: 18px 14px;
  background: var(--surface);
  border: 2px solid var(--rule);
  border-radius: 14px;
  text-align: center;
}
.q-main { font-size: 2.2rem; font-weight: 700; line-height: 1.4; font-variant-numeric: tabular-nums; }
.q-main.is-long { font-size: 1.45rem; font-family: var(--font-display); }
.q-sub { font-size: 1.05rem; font-weight: 700; }
.stroop { font-size: 3rem; font-weight: 700; line-height: 1.3; }
.scatter { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 12px; padding-top: 8px; font-size: 2.1rem; line-height: 1.25; }
.scatter span { display: inline-block; }

.choices { display: grid; grid-template-columns: repeat(var(--cols, 2), 1fr); gap: 10px; }
.choice {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 72px;
  min-width: 0;
  padding: 8px;
  border: 2px solid var(--ink-soft);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 1.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}
.choices.is-emoji { gap: 8px; }
.choices.is-emoji .choice { aspect-ratio: 1; min-height: 0; padding: 0; font-size: clamp(1.5rem, 9vw, 2.4rem); line-height: 1; }
.choice.is-ok { background: var(--ok-bg); border-color: var(--ok); box-shadow: inset 0 0 0 3px var(--ok); }
.choice.is-ng { background: var(--ng-bg); border-color: var(--ng); box-shadow: inset 0 0 0 3px var(--ng); }
.choice.is-lit { background: var(--gold); border-color: var(--gold); color: var(--gold-ink); }
.choice.is-done { background: var(--gold-soft); border-color: var(--gold); color: var(--ink-soft); }
.swatch { width: 28px; height: 28px; border-radius: 50%; flex: none; }
.pads .choice { aspect-ratio: 5 / 4; font-size: 3rem; transition: transform .12s; }
.pads .choice.is-lit { transform: scale(1.06); }

/* 絵合わせの札 */
.board { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.card {
  aspect-ratio: 4 / 5;
  max-width: 100%;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  perspective: 700px;
  font: inherit;
  border-radius: 12px;
  -webkit-tap-highlight-color: transparent;
}
.card-inner {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform .45s ease;
}
.card.is-up .card-inner { transform: rotateY(180deg); }
.face {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: 12px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.face-back {
  background-color: var(--indigo);
  background-image:
    repeating-linear-gradient(60deg, var(--card-line) 0 1.5px, transparent 1.5px 15px),
    repeating-linear-gradient(-60deg, var(--card-line) 0 1.5px, transparent 1.5px 15px),
    repeating-linear-gradient(0deg, var(--card-line) 0 1.5px, transparent 1.5px 13px);
  box-shadow: inset 0 0 0 5px var(--indigo), inset 0 0 0 7px var(--card-line);
}
.face-front {
  background: var(--face);
  border: 2px solid var(--face-edge);
  transform: rotateY(180deg);
  font-size: clamp(2rem, 10vw, 3.2rem);
  line-height: 1;
}
.card.is-matched .face-front { border-color: var(--gold); box-shadow: inset 0 0 0 4px var(--gold); }

/* 結果 */
.panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 22px 18px;
  background: var(--surface);
  border: 2px solid var(--rule);
  border-radius: 16px;
}
.score { font-family: var(--font-display); font-size: 3.4rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.score small { font-size: 1.4rem; padding-left: 4px; }

/* 番付 */
.top3 { display: flex; flex-direction: column; gap: 6px; }
.top3 li {
  display: grid;
  grid-template-columns: 3.2em 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--bg);
  font-weight: 700;
}
.top3 .place { font-family: var(--font-display); font-size: 1.2rem; }
.top3 .nick { min-width: 0; overflow-wrap: anywhere; line-height: 1.4; }
.top3 .pts { font-variant-numeric: tabular-nums; white-space: nowrap; }
.top3 li.is-me { background: var(--gold-soft); box-shadow: inset 0 0 0 2px var(--gold); }
.myrank {
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--indigo);
  color: #FFFFFF;
  font-family: var(--font-display);
  font-size: 1.25rem;
  text-align: center;
}
.rank-game { display: flex; flex-direction: column; gap: 8px; padding-top: 16px; border-top: 2px solid var(--rule); }

@media (prefers-reduced-motion: reduce) {
  .card-inner, .pads .choice { transition: none; }
}

/* アプリとして開いたとき用の土台 */
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; padding-top: calc(20px + env(safe-area-inset-top, 0px)); padding-bottom: calc(48px + env(safe-area-inset-bottom, 0px)); }
[hidden] { display: none !important; }
img { max-width: 100%; }
