/* 共通の土台。契約は ../../API.md §6-4（クラスの約束）。値は tokens.css。
   昭和〜平成のバラエティ番組のセット × 熊本の祭りの夜。太い墨線・ずらし影・電飾。 */

*, *::before, *::after { box-sizing: border-box; }

/* .card や .score__wait など display を持つクラスに [hidden] が負けるのを止める。
   （これが無いと「採点中…」と得点が同時に出る） */
[hidden] { display: none !important; }

html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--stage);
  color: var(--paper);
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 16px;
  line-height: 1.66;
  overscroll-behavior-y: none;
  -webkit-tap-highlight-color: transparent;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, p, ul, ol, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { -webkit-appearance: none; appearance: none; }
a { color: var(--gold); text-underline-offset: 3px; }
img, svg { display: block; max-width: 100%; }

/* ===== 舞台の背景（index.html の .bg。画面の後ろに固定） ===================== */
.bg { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.bg::after {   /* 四隅を落として奥行きを出す */
  content: ""; position: absolute; inset: -10%;
  background: radial-gradient(ellipse 80% 62% at 50% 30%, rgba(90,60,170,.42), transparent 72%),
              radial-gradient(ellipse 120% 90% at 50% 120%, rgba(230,62,43,.22), transparent 70%);
}
.bg__base {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, var(--stage-2) 0%, var(--stage) 46%, #0D0A1C 100%);
}
.bg__burst {
  position: absolute; left: 50%; top: -34vh; width: 190vmax; height: 190vmax;
  transform: translateX(-50%);
  background: repeating-conic-gradient(from 0deg at 50% 50%,
    rgba(255, 201, 60, .10) 0deg 6.2deg, rgba(255, 201, 60, 0) 6.2deg 13deg);
  animation: bg-spin 120s linear infinite;
  opacity: .8;
}
.bg__dots {
  position: absolute; inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, .13) 1.1px, transparent 1.3px);
  background-size: 9px 9px;
  opacity: .5;
  mask-image: linear-gradient(180deg, rgba(0,0,0,.9), rgba(0,0,0,.25) 55%, rgba(0,0,0,.7));
  -webkit-mask-image: linear-gradient(180deg, rgba(0,0,0,.9), rgba(0,0,0,.25) 55%, rgba(0,0,0,.7));
}
.bg__floor {   /* 舞台の床の光 */
  position: absolute; left: 50%; bottom: -16vh; width: 150vw; height: 46vh; transform: translateX(-50%);
  background: radial-gradient(ellipse 50% 50% at 50% 50%, rgba(255, 138, 31, .30), transparent 68%);
}
@keyframes bg-spin { to { transform: translateX(-50%) rotate(360deg); } }

/* ===== 画面の器 ============================================================ */
#app { position: fixed; inset: 0; z-index: 1; overflow: hidden; }

.screen {
  position: absolute; inset: 0;
  overflow-y: auto; overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.28) transparent;
}
.screen::-webkit-scrollbar { width: 9px; }
.screen::-webkit-scrollbar-thumb { background: rgba(255,255,255,.26); border-radius: 9px; }
.screen__in {
  width: 100%; max-width: 640px;
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) 16px calc(34px + env(safe-area-inset-bottom));
  min-height: 100%;
  display: flex; flex-direction: column; gap: 16px;
}
.screen--wide .screen__in { max-width: 880px; }
.screen--stages .screen__in { max-width: 860px; }
.screen--ranking .screen__in { max-width: 860px; }
.screen--result .screen__in { max-width: 700px; }
.screen--about .screen__in { max-width: 700px; }
.screen--title .screen__in { max-width: 560px; gap: 0; }

/* 画面の切替（app.js のフェードに合わせて、出るときだけ少し弾む） */
.screen { animation: screen-in .26s var(--ease-out) both; }
@keyframes screen-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ===== 飾り ================================================================= */
.burst {
  background-image: repeating-conic-gradient(from 0deg at 50% 42%,
    rgba(255, 201, 60, .16) 0deg 7deg, rgba(255, 201, 60, 0) 7deg 14deg);
}
.dots {
  background-image: radial-gradient(rgba(27, 23, 38, .20) 1.2px, transparent 1.4px);
  background-size: 8px 8px;
}

/* 電飾の縁：玉が交互に光る */
.marquee { position: relative; }
.marquee::before, .marquee::after {
  content: ""; position: absolute; inset: -11px; border-radius: calc(var(--r-lg) + 11px);
  pointer-events: none;
  --bulb: radial-gradient(circle at 50% 50%, #FFF3C4 0 20%, var(--gold) 22% 42%, rgba(255, 201, 60, 0) 46%);
  background-image: var(--bulb), var(--bulb), var(--bulb), var(--bulb);
  background-size: 26px 26px;
  background-repeat: repeat-x, repeat-x, repeat-y, repeat-y;
  filter: drop-shadow(0 0 5px rgba(255, 201, 60, .7));
  animation: bulbs 1.1s steps(1, end) infinite;
}
.marquee::before { background-position: 0 0, 0 100%, 0 0, 100% 0; }
.marquee::after  { background-position: 13px 0, 13px 100%, 0 13px, 100% 13px; animation-delay: .55s; }
@keyframes bulbs { 0%, 49% { opacity: 1; } 50%, 100% { opacity: .22; } }

/* ===== ボタン =============================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font-display); font-size: 16px; line-height: 1.25; letter-spacing: .02em;
  min-height: 48px; padding: 12px 18px;
  border: var(--line); border-radius: var(--r);
  background: var(--paper); color: var(--ink);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform .09s var(--ease-out), box-shadow .09s var(--ease-out), filter .12s var(--ease-out);
}
.btn:hover { filter: brightness(1.05); }
.btn:active { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--ink); }
.btn:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; cursor: default; pointer-events: none; }
.btn svg { width: 20px; height: 20px; flex: none; }

.btn--primary { background: var(--red); color: #fff; border-color: var(--ink); }
.btn--gold { background: var(--gold); color: var(--ink); }
.btn--ghost { background: rgba(255, 247, 232, .07); color: var(--paper); border-color: rgba(255, 247, 232, .55); box-shadow: none; }
.btn--ghost:active { transform: translateY(2px); box-shadow: none; }
.btn--dark { background: rgba(27, 23, 38, .06); color: var(--ink); border-color: var(--ink); }
.btn--xl {
  min-height: 72px; padding: 16px 28px; font-size: 26px; border-radius: var(--r-lg);
  border: var(--line-thick); box-shadow: var(--shadow);
}
.btn--block { width: 100%; }
.btn--sm {
  min-height: 48px; padding: 9px 14px; font-size: 13px; border-radius: var(--r-sm); border-width: 2px;
  font-family: var(--font-body); font-weight: 800; letter-spacing: 0;
}

/* 特大ボタンは電飾つきで「押したくなる」*/
.btn--xl.btn--primary { background: linear-gradient(180deg, #F0553F, var(--red) 60%, var(--red-deep)); }
.btn--glow { box-shadow: var(--shadow), var(--shadow-glow); animation: glow-pulse 2.2s ease-in-out infinite; }
@keyframes glow-pulse {
  0%, 100% { box-shadow: var(--shadow), 0 0 0 4px var(--gold), 0 0 26px rgba(255,201,60,.45); }
  50%      { box-shadow: var(--shadow), 0 0 0 4px var(--gold), 0 0 44px rgba(255,201,60,.85); }
}

/* 小さな丸ボタン（戻る・設定など） */
.iconbtn {
  display: inline-flex; align-items: center; gap: 5px;
  min-height: 48px; min-width: 48px; padding: 6px 12px;
  border: 2px solid rgba(255, 247, 232, .48); border-radius: var(--r-pill);
  background: rgba(27, 23, 38, .45); color: var(--paper);
  font-family: var(--font-body); font-weight: 700; font-size: 13px;
  cursor: pointer; transition: background .14s var(--ease-out);
}
.iconbtn:hover { background: rgba(255, 247, 232, .16); }
.iconbtn:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.iconbtn svg { width: 19px; height: 19px; flex: none; }
.iconbtn--on { background: var(--gold); color: var(--ink); border-color: var(--ink); }

/* ===== 紙のカード ============================================================ */
.card {
  position: relative;
  background: var(--paper); color: var(--ink);
  border: var(--line); border-radius: var(--r);
  box-shadow: var(--shadow);
  padding: 16px;
}
.card--tight { padding: 12px; }
.card--dark { background: linear-gradient(180deg, var(--stage-3), var(--stage-2)); color: var(--paper); border-color: var(--ink); }
.card--gold { background: linear-gradient(180deg, #FFE6A0, var(--gold)); }

/* ===== ステッカー・札・判子 =================================================== */
.sticker {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-display); font-size: 14px; line-height: 1;
  padding: 8px 12px;
  border: var(--line); border-radius: var(--r-sm);
  background: var(--kind-neutral); color: var(--ink);
  box-shadow: var(--shadow-sm);
  transform: rotate(-2.5deg);
}
.sticker--critical { background: var(--kind-critical); }
.sticker--good { background: var(--kind-good); color: #fff; }
.sticker--neutral { background: var(--kind-neutral); }
.sticker--bad { background: var(--kind-bad); color: #fff; }
.sticker--landmine { background: var(--kind-landmine); color: #fff; }

.tag {
  display: inline-flex; align-items: center;
  font-size: 12px; font-weight: 700; line-height: 1;
  padding: 6px 10px; border-radius: var(--r-pill);
  border: 2px solid var(--ink); background: rgba(27, 23, 38, .07); color: var(--ink);
  white-space: nowrap;
}
.tag--ghost { border-color: rgba(255, 247, 232, .5); background: rgba(255, 247, 232, .08); color: var(--paper); }
.tag--gold { background: var(--gold); }
.tag--red { background: var(--red); color: #fff; border-color: var(--ink); }

.stamp {
  display: inline-grid; place-items: center;
  width: var(--stamp-size, 74px); height: var(--stamp-size, 74px); border-radius: 50%;
  border: var(--stamp-line, 4px) solid var(--red);
  color: var(--red);
  background: rgba(255, 247, 232, .1);
  transform: rotate(var(--rot, 10deg));
  box-shadow: inset 0 0 0 3px rgba(230, 62, 43, .28);
  font-family: var(--font-display);
  text-align: center;
}
.stamp__t { font-size: var(--stamp-font, 17px); line-height: 1.05; letter-spacing: -.02em; padding: 0 4px; }
.stamp--gold { border-color: var(--gold); color: var(--gold); box-shadow: inset 0 0 0 3px rgba(255, 201, 60, .3); }
.stamp--ink { border-color: var(--ink); color: var(--ink); box-shadow: inset 0 0 0 3px rgba(27, 23, 38, .22); }

/* ===== テロップ（縁取り文字） ================================================ */
.balance { text-wrap: balance; }

.telop {
  font-family: var(--font-display);
  color: #fff;
  -webkit-text-stroke: 7px var(--ink);
  paint-order: stroke fill;
  text-shadow: 0 4px 0 rgba(0, 0, 0, .4);
  letter-spacing: .01em;
}
.telop--gold { color: var(--gold); }
.telop--red { color: var(--red); -webkit-text-stroke-width: 8px; }

/* ===== ロゴ ================================================================= */
.logo { position: relative; display: inline-flex; align-items: center; gap: 8px; }
.logo__badge {
  display: grid; place-items: center; flex: none;
  width: 1.5em; height: 1.5em; border-radius: 50%;
  background: radial-gradient(circle at 34% 28%, #FFE9A8, var(--gold) 62%, #E5A81F);
  border: 4px solid var(--ink);
  box-shadow: 4px 5px 0 rgba(0, 0, 0, .55);
  font-family: var(--font-display); font-size: .62em; color: var(--ink);
  letter-spacing: -.02em;
  transform: rotate(-7deg);
}
.logo__word { position: relative; display: inline-block; transform: rotate(-2.5deg); font-family: var(--font-display); }
.logo__ink {
  position: absolute; left: 0; top: 0; white-space: nowrap;
  color: var(--ink); -webkit-text-stroke: .22em var(--ink); paint-order: stroke fill;
  text-shadow: .07em .085em 0 rgba(0, 0, 0, .55);
}
.logo__top {
  position: relative; white-space: nowrap;
  color: var(--red); -webkit-text-stroke: .1em #FFF6E4; paint-order: stroke fill;
}
.logo--lg { font-size: clamp(44px, 12.6vw, 62px); }
.logo--md { font-size: 38px; }
.logo--sm { font-size: 24px; }
.logo__stamp {
  position: absolute; right: -.42em; top: -.88em;
  width: 1.24em; height: 1.24em; border-width: .07em;
  background: rgba(21, 16, 43, .78);
}
.logo__stamp .stamp__t { font-size: .3em; }

/* ===== 入力 ================================================================= */
.field { display: flex; flex-direction: column; gap: 6px; }
.field__k { font-family: var(--font-body); font-weight: 900; font-size: 14px; color: var(--ink); }
.field__hint { font-size: 12.5px; color: #6C6478; line-height: 1.5; }
.inp {
  width: 100%; min-height: 52px; padding: 12px 14px;
  border: var(--line); border-radius: var(--r-sm);
  background: #fff; color: var(--ink);
  font-weight: 700;
}
.inp:focus-visible { outline: 3px solid var(--gold); outline-offset: 1px; }
.inp::placeholder { color: #A49CAE; font-weight: 500; }
textarea.inp { min-height: 84px; resize: vertical; line-height: 1.6; }
select.inp { background: #fff; }

/* 横並びの選択 */
.seg { display: flex; gap: 8px; flex-wrap: wrap; }
.seg--wrap .seg__b { flex: 1 1 27%; }
.seg__b {
  flex: 1 1 0; min-height: 52px; padding: 8px 6px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border: var(--line); border-radius: var(--r-sm);
  background: rgba(27, 23, 38, .05); color: var(--ink);
  cursor: pointer; transition: transform .1s var(--ease-pop), background .12s;
}
.seg__b:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.seg__t { font-family: var(--font-display); font-size: 15px; line-height: 1.1; }
.seg__n { font-size: 11px; color: #6C6478; line-height: 1.2; }
.seg__b.is-on { background: var(--gold); box-shadow: var(--shadow-sm); transform: translateY(-2px); }
.seg__b.is-on .seg__n { color: #5A4A20; }
.seg--dark .seg__b { background: rgba(255, 247, 232, .08); color: var(--paper); border-color: rgba(255, 247, 232, .45); }
.seg--dark .seg__b .seg__n { color: rgba(255, 247, 232, .66); }
.seg--dark .seg__b.is-on { background: var(--gold); color: var(--ink); border-color: var(--ink); }
.seg--dark .seg__b.is-on .seg__n { color: #5A4A20; }

/* 入／切 */
.sw { display: flex; align-items: center; gap: 12px; min-height: 52px; cursor: pointer; padding: 4px 0; }
.sw__l { flex: 1; display: flex; flex-direction: column; }
.sw__k { font-family: var(--font-display); font-size: 15px; }
.sw__n { font-size: 12.5px; color: #6C6478; line-height: 1.45; }
.sw__i { position: absolute; opacity: 0; width: 0; height: 0; }
.sw__t {
  flex: none; width: 60px; height: 34px; border-radius: var(--r-pill);
  border: var(--line); background: #D9D2C4; position: relative;
  transition: background .16s var(--ease-out);
}
.sw__t::after {
  content: ""; position: absolute; left: 3px; top: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; border: 2px solid var(--ink);
  transition: transform .16s var(--ease-pop);
}
.sw__i:checked + .sw__t { background: var(--green); }
.sw__i:checked + .sw__t::after { transform: translateX(26px); }
.sw__i:focus-visible + .sw__t { outline: 3px solid var(--gold); outline-offset: 2px; }

/* ===== 上の帯・見出し ======================================================== */
.topbar { display: flex; align-items: center; gap: 10px; min-height: 48px; }
.topbar__t {
  flex: 1; text-align: center;
  font-family: var(--font-display); font-size: 21px; line-height: 1.2; color: var(--paper);
  text-shadow: 0 3px 0 rgba(0, 0, 0, .5);
}
.topbar__pad { flex: none; width: 48px; }
.iconbtn__t { display: none; }
@media (min-width: 420px) { .iconbtn__t { display: inline; } }

.sec { display: flex; flex-direction: column; gap: 10px; }
.sec__h {
  display: flex; align-items: center; gap: 9px;
  font-family: var(--font-display); font-size: 17px; color: var(--gold);
  text-shadow: 0 2px 0 rgba(0, 0, 0, .55);
}
.sec__no {
  display: grid; place-items: center; flex: none;
  width: 27px; height: 27px; border-radius: 50%;
  background: var(--gold); color: var(--ink); border: 2px solid var(--ink);
  font-family: var(--font-body); font-weight: 900; font-size: 14px; line-height: 1;
  text-shadow: none;   /* 親の影が数字をつぶしていた */
}
.sec__b { display: flex; flex-direction: column; gap: 10px; }

/* ===== 似顔絵 =============================================================== */
.pt {
  flex: none; width: 64px; height: 64px; border-radius: 14px; overflow: hidden;
  border: var(--line); box-shadow: var(--shadow-sm); background: #2A2436;
}
.pt svg { width: 100%; height: 100%; }
.pt__img { width: 100%; height: 100%; display: block; object-fit: cover; }  /* 本番と同じ顔（portraits.js が差し替える） */
.pt--lg { width: 104px; height: 104px; border-radius: 18px; }
.pt--xl { width: 132px; height: 132px; border-radius: 22px; border: var(--line-thick); box-shadow: var(--shadow); }
.pt--round { border-radius: 50%; }

/* ガンコ度の★ */
.stars { display: inline-flex; gap: 2px; align-items: center; }
.stars__s { width: 15px; height: 15px; color: rgba(27, 23, 38, .2); }
.stars__s.is-on { color: var(--red); }
.stars--dark .stars__s, .card--dark .stars__s { color: rgba(255, 247, 232, .24); }
.stars--dark .stars__s.is-on, .card--dark .stars__s.is-on { color: var(--gold); }

/* ===== 小物 ================================================================= */
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 700; padding: 4px 9px; border-radius: var(--r-pill);
  background: rgba(27, 23, 38, .08); color: var(--ink);
}
.rub__row { display: flex; align-items: center; gap: 8px; }
.rub__k { flex: 1; font-size: 14px; }
.rub__dots { display: flex; gap: 4px; }
.rub__dot { width: 11px; height: 11px; border-radius: 50%; border: 2px solid var(--ink); background: transparent; }
.rub__dot.is-on { background: var(--gold); }
.rub__n { font-size: 12px; color: #6C6478; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.hr { height: 3px; border-radius: 3px; background: repeating-linear-gradient(90deg, var(--ink) 0 10px, transparent 10px 18px); opacity: .35; }

.muted { color: rgba(255, 247, 232, .68); font-size: 13px; line-height: 1.6; }
.muted--ink { color: #6C6478; }

.note {
  border-left: 5px solid var(--gold); padding: 8px 0 8px 12px;
  font-size: 13.5px; line-height: 1.66; color: var(--ink);
}

/* 足元の署名 */
.powered {
  margin-top: auto; padding-top: 16px;
  display: flex; align-items: center; justify-content: center; gap: 7px;
  font-size: 12px; letter-spacing: .08em; color: rgba(255, 247, 232, .58);
}
.powered__d { width: 5px; height: 5px; border-radius: 50%; background: var(--gold); }

/* ===== 小窓・知らせ ========================================================== */
.modal {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-items: center; padding: 20px;
  background: rgba(10, 7, 22, .72);
  animation: fade-in .16s var(--ease-out) both;
}
.modal__box { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 12px; animation: pop-in .26s var(--ease-pop) both; }
.modal__t { font-family: var(--font-display); font-size: 18px; }
.modal__p { font-size: 14px; line-height: 1.65; color: #4A4358; }
.modal__btns { display: flex; gap: 10px; }
.modal__btns .btn { flex: 1; }
@keyframes fade-in { from { opacity: 0; } }
@keyframes pop-in { from { opacity: 0; transform: scale(.9) translateY(12px); } }

.toast {
  position: fixed; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom)); z-index: 70;
  transform: translateX(-50%);
  max-width: min(92vw, 420px);
  padding: 12px 18px; border-radius: var(--r-pill);
  background: var(--ink); color: var(--paper);
  border: 2px solid var(--gold);
  font-size: 14px; font-weight: 700; text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .5);
  animation: toast-in .26s var(--ease-pop) both;
}
.toast.is-out { animation: toast-out .3s var(--ease-out) both; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 18px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes toast-out { to { opacity: 0; transform: translate(-50%, 14px); } }

/* ===== 動きを減らす ========================================================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important; animation-iteration-count: 1 !important;
    transition-duration: .001ms !important; scroll-behavior: auto !important;
  }
  .bg__burst { animation: none; }
}
html[data-reduce-motion="1"] *,
html[data-reduce-motion="1"] *::before,
html[data-reduce-motion="1"] *::after {
  animation-duration: .001ms !important; animation-iteration-count: 1 !important;
  transition-duration: .001ms !important;
}

/* ===== スタジオ表示（16:9・テロップ級の大きさ） ============================== */
html[data-studio="1"] .screen--ranking .screen__in { max-width: 1060px; zoom: 1.5; }
html[data-studio="1"] .screen--result .screen__in { max-width: 840px; zoom: 1.55; }
html[data-studio="1"] .screen--ranking .screen__in { padding-top: 20px; }
html[data-studio="1"] .powered { font-size: 13px; }
