/* 見た目の決まりは typing-quiz と共通:線・文字・影はすべて「墨」1色。紙の地に、和の色をはっきり使う。 */
:root {
  --ink: #1f2250;
  --paper: #fff7e8;
  --shu: #ff5a4e;
  --kin: #ffc93c;
  --ruri: #3d6bff;
  --wakatake: #35c98f;
  --fuji: #a77bff;
  --sakura: #ff8fb8;
  --shu-soft: #ffe0dc;
  --kin-soft: #fff1c7;
  --ruri-soft: #dde6ff;
  --wakatake-soft: #d6f5e8;
  --fuji-soft: #eee5ff;
  --sakura-soft: #ffe3ee;
  --gray: #b9bccc;
  --gray-soft: #e7e8f0;
  --round: "Zen Maru Gothic", "Hiragino Maru Gothic ProN", "Yu Gothic", sans-serif;
  --chunky: "Dela Gothic One", "Zen Maru Gothic", sans-serif;
  --kick: 0;
  color-scheme: light;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--ink);
  font-family: var(--round);
  font-weight: 700;
  line-height: 1.7;
  background-color: var(--paper);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='24' viewBox='0 0 48 24'%3E%3Cg fill='%23fff7e8' stroke='%231f2250' stroke-opacity='.08' stroke-width='1.5'%3E%3Ccircle cx='0' cy='12' r='12'/%3E%3Ccircle cx='0' cy='12' r='8'/%3E%3Ccircle cx='0' cy='12' r='4'/%3E%3Ccircle cx='48' cy='12' r='12'/%3E%3Ccircle cx='48' cy='12' r='8'/%3E%3Ccircle cx='48' cy='12' r='4'/%3E%3Ccircle cx='24' cy='24' r='12'/%3E%3Ccircle cx='24' cy='24' r='8'/%3E%3Ccircle cx='24' cy='24' r='4'/%3E%3C/g%3E%3C/svg%3E");
  overflow-x: hidden;
}

.aura { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.aura::before, .aura::after { content: ""; position: absolute; border-radius: 50%; }
.aura::before { width: 46vmax; height: 46vmax; left: -14vmax; top: -12vmax; background: var(--sakura-soft); opacity: .7; }
.aura::after { width: 40vmax; height: 40vmax; right: -12vmax; bottom: -14vmax; background: var(--ruri-soft); opacity: .7; }
.wrap { position: relative; z-index: 2; max-width: 520px; margin: 0 auto; padding: 52px 16px 64px; }
#fx, #fx-back { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; }
#fx { z-index: 5; }
#fx-back { z-index: 1; }
.screen[hidden] { display: none; }

.exit-link {
  position: fixed; top: 10px; left: 10px; z-index: 6;
  padding: 6px 14px; background: rgba(255,255,255,.92); color: var(--ink);
  font-family: var(--round); font-weight: 700; font-size: .8rem;
  border-radius: 999px; text-decoration: none; box-shadow: 0 2px 6px rgba(31,34,80,.2);
}
.exit-link:hover { background: #fff; }

.muted { color: color-mix(in srgb, var(--ink) 62%, var(--paper)); }
kbd { font-family: ui-monospace, Consolas, monospace; font-size: .75em; font-weight: 700; border: 2px solid currentColor; border-radius: 6px; padding: 0 5px; margin-left: 4px; opacity: .8; }

/* ---- 部品 ---- */
.panel {
  background: #fff; border: 3px solid var(--ink); border-radius: 22px; box-shadow: 0 7px 0 var(--ink);
  padding: 20px 20px 16px; margin-bottom: 24px;
}
button {
  font: inherit; font-weight: 700; color: var(--ink); cursor: pointer;
  background: #fff; border: 3px solid var(--ink); border-radius: 16px; box-shadow: 0 4px 0 var(--ink);
  padding: 8px 18px; transition: transform .06s, box-shadow .06s;
}
button:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
button:disabled { opacity: .45; cursor: not-allowed; transform: none; }
button:focus-visible { outline: 4px solid var(--kin); outline-offset: 2px; }
.primary {
  background: var(--shu); color: #fff; font-family: var(--chunky); font-weight: 400; letter-spacing: .04em;
  text-shadow: 0 2px 0 var(--ink); padding: 10px 26px;
}
.big-btn { display: block; margin: 0 auto; font-size: 1.7rem; padding: 12px 56px; border-radius: 22px; box-shadow: 0 7px 0 var(--ink); }
.big-btn:active { transform: translateY(5px); box-shadow: 0 2px 0 var(--ink); }
.sub-btn { font-size: .95rem; }
.link { border: 0; box-shadow: none; background: none; padding: 0 0 0 8px; font-size: .8rem; color: var(--ruri); text-decoration: underline; }
.link:active { transform: none; }

.field { border: 0; padding: 0; margin: 0 0 18px; display: block; min-width: 0; }
.label { display: block; font-family: var(--chunky); font-weight: 400; font-size: .95rem; margin-bottom: 8px; padding: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip { position: relative; cursor: pointer; }
.chip input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.chip span {
  display: inline-block; padding: 5px 14px; border-radius: 14px; font-size: .92rem;
  border: 3px solid var(--ink); background: #fff; box-shadow: 0 3px 0 var(--ink); opacity: .55;
}
.chip input:checked + span { opacity: 1; background: var(--kin-soft); }
.chip:nth-child(3n+1) input:checked + span { background: var(--shu-soft); }
.chip:nth-child(3n+2) input:checked + span { background: var(--ruri-soft); }
.chip:nth-child(3n+3) input:checked + span { background: var(--wakatake-soft); }
.chip input:focus-visible + span { outline: 4px solid var(--kin); outline-offset: 2px; }
.checks { display: flex; flex-wrap: wrap; gap: 10px 22px; }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 0; accent-color: var(--shu); }

/* ---- 開始画面 ---- */
.logo { position: relative; text-align: center; margin: 18px 0 6px; }
.logo-title {
  margin: 0; font-family: var(--chunky); font-weight: 400; line-height: 1.12; transform: rotate(-3deg);
  text-shadow: 3px 0 var(--ink), -3px 0 var(--ink), 0 3px var(--ink), 0 -3px var(--ink),
    2px 2px var(--ink), -2px -2px var(--ink), 2px -2px var(--ink), -2px 2px var(--ink), 0 8px 0 var(--ink);
}
.logo-title span { display: block; }
.logo-title .l1 { font-size: clamp(2rem, 7vw, 2.9rem); color: var(--ruri); }
.logo-title .l2 { font-size: clamp(2.5rem, 9vw, 3.8rem); color: var(--shu); }
.logo-badge, .logo-tag {
  position: absolute; font-family: var(--chunky); font-weight: 400; border: 3px solid var(--ink);
  border-radius: 12px; box-shadow: 0 4px 0 var(--ink); padding: 0 10px; z-index: 1;
}
.logo-badge { left: 10%; top: -6px; background: var(--kin); transform: rotate(-12deg); font-size: 1.1rem; }
.logo-tag { left: 14%; bottom: 4px; background: #fff; transform: rotate(8deg); font-size: .8rem; }
.lead { text-align: center; margin: 14px 0 22px; }
.best { text-align: center; margin: 18px 0 0; min-height: 1.7em; }
.howto { margin-top: 26px; font-size: .92rem; }
.howto summary { cursor: pointer; font-family: var(--chunky); font-weight: 400; }
.howto ul { padding-left: 1.2em; font-weight: 500; }

/* ---- プレイ画面: HUD ---- */
.hud { display: flex; align-items: center; gap: 10px; }
.score-box, .timer, .combo {
  display: flex; align-items: baseline; gap: 4px; background: #fff; border: 3px solid var(--ink);
  border-radius: 14px; box-shadow: 0 4px 0 var(--ink); padding: 0 12px; font-size: .8rem;
  white-space: nowrap; flex: none;
}
.score-box b, .timer b, .combo b { font-family: var(--chunky); font-weight: 400; font-size: 1.6rem; line-height: 1.35; font-variant-numeric: tabular-nums; }
.timer { margin-left: auto; }
.timer.hurry { background: var(--shu); color: #fff; animation: hurry .5s ease-in-out infinite alternate; }
.combo { background: var(--ruri); color: #fff; }
.combo[hidden] { display: none; }
.combo.bump { animation: bump .3s cubic-bezier(.3, 1.8, .5, 1); }
.bar { height: 16px; border: 3px solid var(--ink); border-radius: 99px; background: #fff; overflow: hidden; margin: 12px 0 16px; }
#bar-fill { height: 100%; background: linear-gradient(90deg, var(--shu), var(--kin)); transform-origin: left; }

/* ---- ばん(グリッド)とブロック ---- */
/* 4択のボタンまでスクロールせずに見えるよう、盤面の高さを画面の高さに合わせる */
.board-wrap {
  position: relative; margin: 0 auto 14px; display: flex; gap: 8px; align-items: stretch;
  max-width: min(370px, max(230px, calc((100svh - 350px) * 8 / 12 + 36px)));
}
.board {
  position: relative; flex: 1; min-width: 0; aspect-ratio: 8 / 12; background: #fff; border: 3px solid var(--ink); border-radius: 16px;
  box-shadow: 0 6px 0 var(--ink); overflow: hidden;
  display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(12, 1fr);
  gap: 2px; padding: 3px; transition: box-shadow .3s;
  background-image: linear-gradient(to bottom, transparent calc(100% - 1px), rgba(31,34,80,.06) 0);
  background-size: 100% calc((100% - 6px) / 12);
}
.board.danger { box-shadow: 0 6px 0 var(--ink), 0 0 0 4px var(--shu); }
.cell, .pc {
  border-radius: 5px; display: flex; align-items: center; justify-content: center;
  font-size: clamp(13px, 4.6vw, 20px); line-height: 1; font-weight: 900; color: var(--ink);
  border: 1.5px solid var(--ink); min-width: 0; min-height: 0; overflow: hidden;
}
.cell.pop { animation: cell-pop .25s cubic-bezier(.3, 1.8, .5, 1); }
.c-shu > .pc, .cell.c-shu { background: var(--shu-soft); }
.c-kin > .pc, .cell.c-kin { background: var(--kin-soft); }
.c-ruri > .pc, .cell.c-ruri { background: var(--ruri-soft); }
.c-wakatake > .pc, .cell.c-wakatake { background: var(--wakatake-soft); }
.c-fuji > .pc, .cell.c-fuji { background: var(--fuji-soft); }
.c-sakura > .pc, .cell.c-sakura { background: var(--sakura-soft); }
.cell.c-gray { background: var(--gray-soft); color: color-mix(in srgb, var(--ink) 45%, #fff); }
.cell.k-garbage {
  border-color: color-mix(in srgb, var(--ink) 55%, #fff);
  background: repeating-linear-gradient(135deg, var(--gray-soft) 0 5px, #d9dbe6 5px 8px);
}
.cell.clearing { animation: clearing .3s ease-out forwards; }
.board.rising .cell { animation: rise-up .2s ease-out; }
@keyframes cell-pop { from { transform: scale(.5); opacity: .2; } to { transform: none; opacity: 1; } }
@keyframes clearing { 0% { background: #fff; transform: none; } 40% { background: var(--kin); transform: scale(1.08); } 100% { background: #fff; transform: scaleY(0); opacity: 0; } }
@keyframes rise-up { from { transform: translateY(calc(100% + 2px)); } to { transform: none; } }

/* 落ちてくるピース：グリッドの上に重ねて、1字1マスで横長・縦長に並べる */
.piece { display: grid; gap: 2px; z-index: 2; min-width: 0; min-height: 0; }
.piece[hidden] { display: none; }
.piece.o-h { grid-auto-flow: column; grid-auto-columns: 1fr; }
.piece.o-v { grid-auto-flow: row; grid-auto-rows: 1fr; }
.piece .pc { border-width: 2.5px; box-shadow: inset 0 -3px 0 rgba(31,34,80,.12); }
.piece.ok .pc { box-shadow: 0 0 0 3px var(--kin); }
.piece.ng .pc { background: var(--gray-soft); }
.piece.ng { animation: shake .25s; }

.rise-gauge {
  position: relative; width: 22px; flex: none; border: 3px solid var(--ink); border-radius: 99px; background: #fff; overflow: hidden;
  box-shadow: 0 4px 0 var(--ink);
}
#rise-fill { position: absolute; inset: 0; background: linear-gradient(to top, var(--shu), var(--kin)); transform-origin: bottom; transform: scaleY(0); }
.rise-gauge span {
  position: absolute; left: 0; right: 0; top: 6px; font-size: 9px; line-height: 1.15; text-align: center; writing-mode: horizontal-tb;
  color: var(--ink); font-weight: 900;
}

.next-box {
  display: flex; align-items: baseline; gap: 6px; background: var(--kin-soft); border: 3px solid var(--ink);
  border-radius: 14px; box-shadow: 0 4px 0 var(--ink); padding: 0 10px; font-size: .75rem; white-space: nowrap; min-width: 0;
}
.next-box b { font-size: 1.15rem; line-height: 1.9; overflow: hidden; text-overflow: ellipsis; }

.lines {
  position: absolute; left: 30px; right: 0; top: 38%; text-align: center; pointer-events: none; z-index: 4;
  font-family: var(--chunky); font-weight: 400; font-size: 1.9rem; color: var(--kin);
  text-shadow: 2px 0 var(--ink), -2px 0 var(--ink), 0 2px var(--ink), 0 -2px var(--ink), 0 5px 0 var(--ink);
  opacity: 0;
}
.lines[hidden] { display: none; }
.lines.on { animation: lines-pop .9s ease-out forwards; }
@keyframes lines-pop { 0% { opacity: 0; transform: scale(.4); } 25% { opacity: 1; transform: scale(1.15) rotate(-4deg); } 70% { opacity: 1; transform: scale(1) rotate(-4deg); } 100% { opacity: 0; transform: translateY(-30px) rotate(-4deg); } }

/* ---- 問題カード ---- */
.card {
  position: relative; background: #fff; border: 3px solid var(--ink); border-radius: 22px; box-shadow: 0 7px 0 var(--ink);
  padding: 14px 18px 18px; text-align: center;
}
.q-label { margin: 0 0 4px; font-size: .82rem; color: color-mix(in srgb, var(--ink) 62%, var(--paper)); }
.question { font-family: var(--chunky); font-weight: 400; font-size: 1.9rem; margin: 0 0 14px; }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choices button { font-size: 1.05rem; padding: 12px 8px; border-radius: 16px; }
.choices button.correct { background: var(--wakatake-soft); box-shadow: 0 4px 0 var(--ink), 0 0 0 3px var(--wakatake); }
.choices button.wrong { background: var(--shu-soft); }
.stamp {
  position: absolute; right: 14px; top: 10px; font-family: var(--chunky); font-weight: 400; font-size: 1.3rem;
  color: var(--shu); border: 4px double var(--shu); border-radius: 10px; padding: 0 8px; background: rgba(255, 255, 255, .85);
  opacity: 0; transform: rotate(-14deg) scale(0); pointer-events: none;
}
.stamp.on { animation: stamp .8s cubic-bezier(.2, 1.4, .5, 1) forwards; }
.last { min-height: 1.6em; text-align: center; margin: 10px 0 0; color: #1f9e6c; }

/* ---- 結果画面 ---- */
.result-panel { position: relative; text-align: center; margin-top: 40px; }
.big { margin: 4px 0; }
.big b { font-family: var(--chunky); font-weight: 400; font-size: 4.2rem; line-height: 1.2; color: var(--shu);
  text-shadow: 0 5px 0 var(--ink); font-variant-numeric: tabular-nums; }
.big span { margin-left: 6px; }
.result-stamp { top: 18px; right: 22px; font-size: 1.8rem; }
.result-stamp[hidden] { display: none; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.row.center { justify-content: center; margin-top: 16px; }

/* ---- 連続正解でにぎやかに ---- */
.lv-hot .card { box-shadow: 0 7px 0 var(--ink), 0 0 0 5px var(--kin); }
.lv-hot .score-box b { transform: scale(calc(1 + var(--kick) * .18)); }
.lv-fever .card { box-shadow: 0 7px 0 var(--ink), 0 0 0 5px var(--shu), 0 0 calc(18px + var(--kick) * 36px) 6px rgba(255, 201, 60, .85); }
.lv-fever .aura::before { background: var(--kin-soft); opacity: 1; }
.lv-fever .aura::after { background: var(--sakura-soft); opacity: 1; }
.lv-max .aura { background: conic-gradient(from 0deg at 50% 50%, var(--shu-soft), var(--kin-soft), var(--wakatake-soft), var(--ruri-soft), var(--fuji-soft), var(--sakura-soft), var(--shu-soft)); }

@keyframes bump { from { transform: scale(1.5); } to { transform: none; } }
@keyframes hurry { to { transform: scale(1.08); } }
@keyframes shake { 20% { transform: translateX(-8px) rotate(-1deg); } 40% { transform: translateX(7px) rotate(1deg); } 60% { transform: translateX(-5px); } 80% { transform: translateX(3px); } }
@keyframes stamp {
  0% { opacity: 0; transform: rotate(-14deg) scale(2.4); }
  35% { opacity: 1; transform: rotate(-14deg) scale(.9); }
  55% { transform: rotate(-14deg) scale(1.06); }
  80% { opacity: 1; transform: rotate(-14deg) scale(1); }
  100% { opacity: 0; transform: rotate(-14deg) scale(1); }
}
.result-stamp.on { animation: stamp-stay .7s cubic-bezier(.2, 1.4, .5, 1) forwards; }
@keyframes stamp-stay {
  0% { opacity: 0; transform: rotate(-14deg) scale(2.6); }
  50% { opacity: 1; transform: rotate(-14deg) scale(.9); }
  100% { opacity: 1; transform: rotate(-14deg) scale(1); }
}

/* ---- 看板キャラ「エンタ丸」(mascot.js) ---- */
.mascot-slot { position: absolute; pointer-events: none; z-index: 3; }
.mascot { position: relative; width: 84px; height: 90px; }
.m-inner { position: absolute; inset: 0; transform-origin: 50% 100%; animation: m-bounce .5s ease-in-out infinite alternate; }
.m-body, .m-arm { position: absolute; }
.m-body { inset: 0; }
.m-arm.l { left: -2px; top: 38px; transform-origin: 20px 4px; animation: m-wave .5s ease-in-out infinite alternate; }
.m-arm.r { left: 64px; top: 34px; transform-origin: 4px 4px; transform: rotate(-60deg); }
.m-arm svg, .m-body svg { display: block; overflow: visible; }
.mascot.stamping .m-arm.r { animation: m-slam .38s cubic-bezier(.3, 1.4, .5, 1); }
.mascot.oops .m-inner { animation: m-oops .65s ease-out; }
.lv-hot .m-inner { animation-duration: .3s; }
.lv-fever .m-inner { animation-duration: .22s; }
.lv-fever .m-arm.l { animation-duration: .22s; }
.start-mascot { right: 4%; top: 30px; transform: scale(1.25) rotate(6deg); transform-origin: 50% 100%; }
.play-mascot { right: -96px; bottom: 0; transform: scale(.85); transform-origin: 50% 100%; }
@media (max-width: 600px) { .play-mascot { display: none; } }
.result-mascot { left: 18px; top: 14px; transform: scale(1.1); transform-origin: 0 0; }
@keyframes m-bounce { from { transform: translateY(0) scaleY(1); } to { transform: translateY(-5px) scaleY(1.03); } }
@keyframes m-wave { from { transform: rotate(-10deg); } to { transform: rotate(35deg); } }
@keyframes m-slam { 0% { transform: rotate(-60deg); } 45% { transform: rotate(55deg); } 70% { transform: rotate(40deg); } 100% { transform: rotate(-60deg); } }
@keyframes m-oops { 0% { transform: rotate(0); } 30% { transform: rotate(-24deg) translateY(4px); } 60% { transform: rotate(10deg); } 100% { transform: rotate(0); } }

@media (max-width: 420px) {
  .logo-badge { left: 2%; }
  .logo-tag { left: 4%; }
  .question { font-size: 1.5rem; }
}

.site-footer { margin-top: 40px; font-size: .72rem; font-weight: 500; color: color-mix(in srgb, var(--ink) 60%, var(--paper)); word-break: break-all; }
