/* フォント: サイトで使う文字だけに絞った Noto Sans JP / KR（可変フォント・SIL OFL）。tools/gen_fonts.py で作る */
@font-face { font-family: 'Noto Sans JP'; src: url(../fonts/noto-sans-jp.woff2) format('woff2'); font-weight: 400 900; font-display: swap; }
@font-face { font-family: 'Noto Sans KR'; src: url(../fonts/noto-sans-kr.woff2) format('woff2'); font-weight: 400 900; font-display: swap; }

:root {
  --bg: #1b120e;
  --panel: rgba(28, 18, 13, .82);
  --line: rgba(255, 255, 255, .14);
  --text: #f7ece2;
  --muted: #c9b6a6;
  --accent: #ff7a1a;
  --gold: #ffd84a;
  --good: #6be36b;
  --bad: #ff4d3d;
  --key-c: #bfe3f6;
  --key-c-edge: #5e9cc2;
  --key-v: #f6b3b3;
  --key-v-edge: #c46f72;
  --ink: #1f2a44;
  font-family: 'Noto Sans JP', 'Noto Sans KR', system-ui, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }

.layout { display: flex; justify-content: center; gap: 20px; padding: 16px; }
/* 16:9 のプレイ画面が画面の幅と高さの両方に収まる大きさ（最大1400px） */
.frame { flex: 0 1 auto; width: min(1400px, calc((100dvh - 32px) * 16 / 9)); min-width: 0; max-width: 100%; container: frame / inline-size; }
.ad-side { width: 300px; flex: none; }
.ad-side .ad-slot { position: sticky; top: 16px; height: 600px; margin: 0; }
/* 広告は右→左の順に、置いてもゲーム画面が約1100px残る幅のときだけ表示 */
@media (max-width: 1450px) { .ad-right { display: none; } }
@media (max-width: 1780px) { .ad-left { display: none; } }

.ad-slot {
  display: grid; place-items: center; margin: 24px auto 0; border: 1px dashed var(--line);
  color: var(--muted); font-size: 12px; letter-spacing: .1em; background: rgba(0, 0, 0, .35);
}
.ad-bottom { max-width: 728px; height: 90px; }
.ad-rect { width: 336px; max-width: 100%; height: 280px; }
.ad-result { margin-top: 48px; } /* 誤クリック防止のためボタンから離す */
.back-top { position: absolute; left: 20px; top: 16px; font-size: 13px; color: var(--muted); text-decoration: none; text-shadow: 0 1px 2px #000; }
.back-top:hover { color: var(--gold); }

/* 共通の店内背景 */
.screen { position: relative; isolation: isolate; border-radius: 16px; overflow: hidden; padding: 24px; }
.screen::before {
  content: ''; position: absolute; inset: 0; z-index: -1;
  background: url(../img/bg-restaurant.webp) center / cover; filter: brightness(.72) saturate(1.1);
}
.screen::after { content: ''; position: absolute; inset: 0; z-index: -1; background: radial-gradient(ellipse at 50% 60%, transparent 30%, rgba(0, 0, 0, .55)); }

/* ロゴ */
.logo-lg, .logo-sm {
  font-weight: 900; letter-spacing: .02em; line-height: 1.05;
  background: linear-gradient(#fff7b0, #ffd23f 45%, #ff8a1a); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 1px #3a1800) drop-shadow(2px 2px 0 #3a1800) drop-shadow(-1px -1px 0 #3a1800) drop-shadow(0 4px 6px rgba(0, 0, 0, .6));
}
.logo-ko { font-family: 'Noto Sans KR', sans-serif; font-weight: 900; color: #ff6a2a; filter: drop-shadow(1px 1px 0 #3a1000) drop-shadow(0 2px 3px rgba(0, 0, 0, .6)); }

/* タイトル */
.title-logo { margin: 8px 0 0; text-align: center; font-size: 64px; }
#screen-title .logo-ko { text-align: center; font-size: 26px; margin-bottom: 8px; }
.tagline { margin: 4px 0 6px; text-align: center; font-size: 30px; font-weight: 900; color: #fff; letter-spacing: .08em; text-shadow: 0 0 2px #3a1800, 2px 2px 0 #3a1800, 0 4px 10px rgba(0, 0, 0, .7); }
.lead { text-align: center; color: var(--text); margin: 0 0 20px; text-shadow: 0 2px 4px #000; }
.courses { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; max-width: 1120px; margin: 0 auto; }
.courses .course { grid-column: span 2; } /* 上段3つ・下段3つ */
/* 狭い幅では2列 → 1列 */
@container frame (max-width: 900px) {
  .courses { grid-template-columns: repeat(4, 1fr); }
  .title-logo { font-size: 48px; }
}
@container frame (max-width: 560px) {
  .courses .course { grid-column: 1 / -1; }
  .course-meta { white-space: normal; }
}
.course {
  position: relative; isolation: isolate; overflow: hidden;
  display: grid; gap: 4px; text-align: left; padding: 16px 14px; border-radius: 12px;
  background: var(--panel); border: 2px solid var(--line); transition: transform .1s, border-color .1s;
}
.course:hover { transform: translateY(-2px); border-color: var(--accent); }
.course-img {
  position: absolute; right: -8%; top: 50%; z-index: -1; height: 150%; translate: 0 -50%; pointer-events: none; opacity: .9;
  -webkit-mask-image: linear-gradient(to right, transparent 20%, #000 65%); mask-image: linear-gradient(to right, transparent 20%, #000 65%);
  transition: scale .2s;
}
.course:hover .course-img { scale: 1.06; }
.course > span { text-shadow: 0 1px 3px #000; }
.course-level { font-size: 12px; color: var(--accent); font-weight: 700; }
.course-name { font-size: 20px; font-weight: 900; }
.course-name small { font-size: 75%; }
.course-meta { font-size: 16px; font-weight: 700; color: var(--muted); white-space: nowrap; }
.settings { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 20px; margin: 20px auto 8px; padding: 8px 16px; width: fit-content; background: var(--panel); border-radius: 999px; }
.mobile-note { display: none; max-width: 520px; margin: 0 auto 16px; padding: 10px 14px; border-radius: 10px; background: var(--accent); color: #fff; font-weight: 700; text-align: center; }
@media (hover: none) and (pointer: coarse), (max-width: 700px) { .mobile-note { display: block; } }
.fs-btn { border: 1px solid var(--line); border-radius: 999px; background: rgba(0, 0, 0, .3); padding: 0 10px; font-size: inherit; }
.note { font-size: 12px; color: var(--muted); text-align: center; margin: 0; text-shadow: 0 1px 2px #000; }

/* プレイ画面（16:9・コンテナ幅基準でスケール） */
.play { padding: 0; aspect-ratio: 16 / 9; container-type: inline-size; }
.duct { position: absolute; left: 50%; top: -3cqw; width: 16cqw; transform: translateX(-50%); filter: brightness(.85) drop-shadow(0 1cqw 1.5cqw rgba(0, 0, 0, .5)); }
.hud-left { position: absolute; left: 1.4cqw; top: 1cqw; z-index: 3; text-align: center; }
.logo-sm { font-size: 3.6cqw; }
.hud-box {
  display: inline-block; margin-top: .5cqw; padding: .3cqw 1cqw; border-radius: .5cqw;
  background: rgba(15, 10, 8, .78); font-size: 1.9cqw; font-weight: 700; white-space: nowrap;
}
.hud-box b { font-variant-numeric: tabular-nums; }
.hud-box.hud-time { font-size: 2.9cqw; }
#hud-time.low { color: var(--bad); }
.hud-left .logo-ko { font-size: 1.8cqw; }
.hud-right { position: absolute; right: 1.4cqw; top: 1cqw; z-index: 3; display: grid; justify-items: end; }
.diff { color: var(--good); }
.diff.minus { color: #ff8a80; }
.hud-right i { font-style: normal; color: var(--gold); }
.fever-badge { margin-top: .5cqw; font-size: 2cqw; color: var(--gold); font-weight: 900; text-shadow: 0 2px 4px #000; animation: pulse .5s infinite alternate; }

.stage { position: absolute; inset: 0; }
.stage.fever::after { content: ''; position: absolute; inset: 0; pointer-events: none; box-shadow: inset 0 0 8cqw rgba(255, 110, 30, .55); }
#grill { position: absolute; inset: 0; width: 100%; height: 100%; }

/* 吹き出し */
.order {
  position: absolute; left: 50%; top: 3%; transform: translateX(-50%); z-index: 2; text-align: center;
  min-width: 30cqw; padding: .8cqw 2.4cqw 1cqw; border-radius: 1.2cqw;
  background: rgba(18, 18, 18, .86); border: .25cqw solid #f2f2f2; box-shadow: 0 .6cqw 1.6cqw rgba(0, 0, 0, .5); pointer-events: none;
}
.order::after {
  content: ''; position: absolute; left: 50%; bottom: -1.5cqw; transform: translateX(-50%);
  border: 1.3cqw solid transparent; border-top-color: #f2f2f2; border-bottom: 0;
}
.order.fever { border-color: var(--gold); box-shadow: 0 0 2cqw rgba(255, 200, 60, .6); }
.order-ko { font-family: 'Noto Sans KR', sans-serif; font-size: 5cqw; font-weight: 900; line-height: 1.2; white-space: pre; }
.order-ko .typed { color: var(--gold); }
.order-ko .rest { color: #fffbe6; }
.order-ko .caret { color: var(--gold); font-weight: 400; animation: pulse .5s infinite alternate; }
/* お替りモード: 皿数だけ出し、会計・コンボ・注文の値段は出さない */
.play.okawari .hud-box:not(.hud-time), .play.okawari .order-price { display: none; }
/* パンチャン級: 会計・コンボ・注文の値段・キーガイドは出さない */
.play.free .hud-right, .play.free .order-price, .play.free .order-keys { display: none; }
.order-ko.flash .typed, .order-ko.flash .rest { animation: flashText .25s; }
.order-ko.flash { animation: shake .25s; }
.order-ja { font-size: 2.8cqw; font-weight: 900; line-height: 1.2; color: #f3f3f3; }
.order-ruby { font-size: 1.6cqw; font-weight: 700; color: #f3f3f3; }
/* キー入力（キーボードの上の別枠。キーボードごと1.3倍に拡大される） */
.order-keys {
  justify-self: center; margin-bottom: .3cqw; padding: .2cqw 1cqw; border-radius: .6cqw; background: rgba(18, 18, 18, .86);
  font-family: ui-monospace, Menlo, monospace; font-size: 1.4cqw; font-weight: 700; white-space: pre; color: #ff9a1f;
}
.order-keys span span, .order-keys > span { padding: 0 .35cqw; }
.order-keys .done { display: inline-block; padding: 0 .2cqw; background: #1976d2; border-radius: .5cqw; color: #9fe4ff; }
.order-keys .cur { color: #fff; text-decoration: underline .3cqw var(--gold); text-underline-offset: .5cqw; }
.order-price { position: absolute; right: -1.2cqw; top: -1.2cqw; background: var(--accent); color: #fff; font-size: 1.2cqw; font-weight: 700; padding: .2cqw .8cqw; border-radius: 999px; }

.sizzle-word {
  position: absolute; top: 25%; z-index: 2; font-size: 3cqw; font-weight: 900; color: #fff; opacity: 0;
  -webkit-text-stroke: .25cqw #222; paint-order: stroke fill; text-shadow: 0 .3cqw .6cqw rgba(0, 0, 0, .6); transition: opacity .2s;
}
.sizzle-word.left { left: 18%; rotate: -12deg; }
.sizzle-word.right { right: 18%; rotate: 12deg; }
.sizzle-word.on { opacity: 1; animation: wobble .35s infinite alternate; }

.countdown { position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; font-size: 14cqw; font-weight: 900; color: var(--gold); background: rgba(0, 0, 0, .4); }
.popups { position: absolute; inset: 0; z-index: 4; pointer-events: none; }
.popup { position: absolute; left: 50%; top: 52%; transform: translateX(-50%); font-weight: 900; font-size: 2.6cqw; animation: rise 2s ease-out forwards; white-space: nowrap; -webkit-text-stroke: .2cqw #2a1200; paint-order: stroke fill; }
.popup.gain { color: var(--gold); }
.popup.burn { color: #bbb; }
.popup.bonus { color: var(--good); top: 62%; }
.popup.fever { color: var(--accent); font-size: 3.8cqw; top: 40%; }

/* 仮想キーボード（左手・中央・右手に分割） */
.keyboard {
  position: absolute; left: 50%; bottom: .8cqw; transform: translateX(-50%) scale(1.3); transform-origin: 50% 100%; z-index: 3;
  display: grid; row-gap: .5cqw; justify-items: start; user-select: none;
}
.kb-row { display: flex; gap: 1.6cqw; }
/* ホームポジションの目安の両手（hands.js）。キーの上にごく薄く重ねる */
.hands { position: absolute; inset: 0; width: 100%; height: 100%; overflow: hidden; pointer-events: none; z-index: 1; }
.keyboard .hands { translate: 0 11.5px; } /* ゲーム画面は少し下げる（キーボードは scale(1.3) なので画面上で約15px） */
.hands g { fill: #fff; stroke: #fff; stroke-linecap: round; stroke-linejoin: round; opacity: .3; }
.kb-row.r0 { margin-left: 1.3cqw; }
.kb-row.r1 { margin-left: 2.6cqw; }
.kb-block { display: flex; gap: .5cqw; }
.kb-key {
  position: relative; width: 4.6cqw; height: 4cqw; border-radius: .7cqw; display: grid; place-items: center;
  color: var(--ink); box-shadow: inset 0 .25cqw 0 rgba(255, 255, 255, .6); transition: transform .06s;
}
.kb-key.consonant { background: var(--key-c); border-bottom: .45cqw solid var(--key-c-edge); }
.kb-key.vowel { background: var(--key-v); border-bottom: .45cqw solid var(--key-v-edge); }
.kb-key b { font-family: 'Noto Sans KR', sans-serif; font-size: 2.2cqw; font-weight: 900; }
.kb-key small { position: absolute; right: .5cqw; bottom: .2cqw; font-size: .9cqw; font-weight: 700; opacity: .6; }
.kb-key em { position: absolute; left: .5cqw; top: .2cqw; font-size: 1cqw; font-style: normal; font-weight: 700; opacity: .6; }
/* ホームポジションの突起: キーの色を乗算で濃くした線 */
.kb-key.home::after { content: ''; position: absolute; left: 50%; bottom: .12cqw; width: 60%; height: .22cqw; translate: -50% 0; border-radius: 1cqw; background: #b3b3b3; mix-blend-mode: multiply; }
.kb-shift { background: #d9d9d9; border-bottom: .45cqw solid #8d8d8d; font-size: 1.4cqw; font-weight: 700; }
.kb-shift { width: 4.6cqw; }
.kb-space { width: 14.8cqw; background: #d9d9d9; border-bottom: .45cqw solid #8d8d8d; font-size: 1.4cqw; font-weight: 700; } /* キー3つ分 */
.kb-key.hit { background: var(--gold); border-bottom-color: #c99a00; transform: translateY(.2cqw); }
.kb-key.next { background: var(--gold); border-bottom-color: #c99a00; box-shadow: 0 0 1.4cqw rgba(255, 216, 74, .9), inset 0 .25cqw 0 rgba(255, 255, 255, .7); animation: blink .45s infinite alternate; }
/* ポーズ */
.pause { position: absolute; inset: 0; z-index: 6; display: grid; place-items: center; background: rgba(0, 0, 0, .05); }
.pause-box { display: grid; gap: 1cqw; min-width: 24cqw; padding: 2cqw 2.4cqw; border-radius: 1.2cqw; background: var(--panel); text-align: center; box-shadow: 0 1cqw 3cqw rgba(0, 0, 0, .5); }
.pause-title { font-size: 2.4cqw; font-weight: 900; color: var(--gold); }
.pause .btn { font-size: 1.6cqw; padding: .8cqw 2cqw; }
.hint { position: absolute; left: 1.4cqw; top: 9.5cqw; margin: 0; font-size: 1.1cqw; color: var(--muted); z-index: 3; display: flex; align-items: center; gap: 1cqw; }
.hint .fs-btn { padding: 0 .8cqw; }

/* リザルト */
/* リザルト: 左列にお会計とランキング登録、右列に今日のメニュー。16:9 の枠に収め、はみ出す列だけスクロール */
.result { aspect-ratio: 16 / 9; display: grid; grid-template-columns: minmax(340px, 30%) 1fr; grid-template-rows: minmax(0, 1fr); gap: 24px; }
.res-left, .res-right .review { min-height: 0; overflow-y: auto; scrollbar-width: thin; }
.res-right { min-height: 0; }
.res-right .review { flex: 0 1 auto; align-content: start; padding-right: 4px; }
.res-left { display: grid; grid-template-columns: minmax(0, 1fr); align-content: start; gap: 14px; }
.res-right { display: flex; flex-direction: column; }
.res-right .ad-result { flex: none; margin: auto 0 0; }
/* 高さの低い画面ではお会計を詰めて左列を収める */
@media (max-height: 800px) {
  .receipt { padding: 12px 18px; }
  .receipt h2 { font-size: 20px; }
  .bill { padding: 6px 0; font-size: 15px; }
  .stats li { line-height: 1.35; }
  .res-total b { font-size: 28px; }
  .stats { gap: 2px 16px; font-size: 12px; }
  .receipt .buttons { margin-top: 10px; padding-top: 10px; }
  .rank-box { padding: 10px 14px 12px; }
  .rank-sel span { width: 38px; height: 38px; font-size: 22px; }
  .rank-head { margin-bottom: 2px; }
  .rank-form { gap: 6px; }
  .rank-label { display: none; } /* 空の枠に「動物」などと出るので省く */
  .rank-icons button { height: 27px; }
  .res-left { gap: 10px; }
}
@container frame (max-width: 900px) {
  .result { aspect-ratio: auto; grid-template-columns: 1fr; }
}
.receipt { background: #f7f1e8; color: #2a1d17; border-radius: 8px; padding: 16px 22px; box-shadow: 0 8px 24px rgba(0, 0, 0, .5); }
.receipt h2 { margin: 0; text-align: center; letter-spacing: .3em; }
.res-course { text-align: center; font-size: 13px; color: #7a6656; margin-bottom: 8px; }
.bill { display: grid; grid-template-columns: 1fr auto; gap: 6px; margin: 0; padding: 8px 0; border-block: 1px dashed #b9a596; font-size: 16px; }
.bill dt, .bill dd { margin: 0; }
.bill dd { font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.res-total { display: grid; justify-items: center; margin: 8px 0 2px; }
.res-total-label { font-size: 13px; color: #7a6656; }
.res-total b { font-size: 34px; font-weight: 900; font-variant-numeric: tabular-nums; line-height: 1.2; }
.res-diff { font-size: 15px; font-weight: 700; }
.res-diff.plus { color: #d63a18; }
.res-diff.minus { color: #3d5aa8; }
.res-best { text-align: center; font-weight: 700; color: #b8860b; }
.receipt .buttons { gap: 8px; margin-top: 16px; padding-top: 14px; border-top: 1px dashed #b9a596; }
.receipt .btn { padding: 10px 14px; font-size: 14px; white-space: nowrap; }
.receipt .btn:not(.primary) { background: #fff; border-color: #b9a596; color: #2a1d17; }
/* ランキング登録（お会計の下の別枠） */
.rank-box { padding: 12px 16px 14px; border-radius: 10px; background: var(--panel); border: 2px solid var(--accent); box-shadow: 0 8px 24px rgba(0, 0, 0, .5); }
.rank-head { margin: 0 0 6px; text-align: center; font-size: 16px; color: var(--gold); }
.rank-form { display: grid; gap: 8px; }
.rank-label { margin: 0; text-align: center; font-size: 13px; color: var(--text); }
.rank-pick { display: flex; justify-content: center; align-items: center; gap: 10px; }
.rank-sel { display: flex; gap: 4px; }
.rank-sel span { position: relative; display: grid; place-items: center; width: 44px; height: 44px; border: 2px dashed #b9a596; border-radius: 8px; font-size: 26px; background: #fff; }
.rank-sel span:empty::before { content: attr(data-name); font-size: 10px; color: #9a8676; }
.rank-sel span:not(:empty) { border-style: solid; border-color: var(--accent); cursor: pointer; }
.rank-form .btn { padding: 8px 18px; }
.rank-form .btn:disabled { opacity: .5; cursor: default; }
.rank-icons { display: grid; gap: 2px; padding: 4px; border-radius: 8px; background: #f7f1e8; }
.rank-row { display: grid; grid-template-columns: 3.4em repeat(12, minmax(0, 1fr)); align-items: center; gap: 1px; }
.rank-row + .rank-row { padding-top: 2px; border-top: 1px dashed #d8c9b8; }
.rank-row-name { font-size: 11px; font-weight: 700; color: #7a4a1a; }
.rank-icons button { min-width: 0; height: 30px; padding: 0; border: 2px solid transparent; border-radius: 6px; background: none; font-size: 18px; line-height: 1; }
.rank-icons button:hover { background: #fff; }
.rank-icons button.on { border-color: var(--accent); background: #fff; }
.rank-msg { text-align: center; font-weight: 700; color: var(--gold); margin-top: 6px; }
.rank-msg:empty { display: none; }
.stats { list-style: none; padding: 0; margin: 10px 0 0; display: grid; grid-template-columns: 1fr 1fr; gap: 4px 16px; font-size: 13px; }
.stats li { display: flex; justify-content: space-between; }
.review-title { font-size: 18px; margin: 0 0 2px; text-shadow: 0 1px 3px #000; }
.review-note { font-size: 12px; color: var(--muted); margin: 0 0 8px; text-shadow: 0 1px 3px #000; }
.review li[data-i] { cursor: pointer; border: 1px solid transparent; }
.review li[data-i]:hover { border-color: var(--accent); }
.res-okawari { margin: 0 0 12px; padding: 8px 12px; text-align: center; background: var(--panel); border: 1px solid var(--accent); border-radius: 8px; }
.res-okawari b { font-family: 'Noto Sans KR', sans-serif; }
.res-okawari .ok { color: var(--good); }
.res-okawari .ng { color: var(--bad); }
.review { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px; }
.review li { display: flex; align-items: center; gap: 8px; background: var(--panel); padding: 6px 10px; border-radius: 8px; }
.review .empty { color: var(--muted); }
.speaker { border: 0; background: none; font-size: 18px; padding: 0; }
.rw-ko { font-family: 'Noto Sans KR', sans-serif; font-weight: 700; }
.rw-ja { font-size: 12px; color: var(--muted); flex: 1; }
.rw-n { font-size: 12px; color: var(--good); }
.buttons { display: flex; justify-content: center; gap: 12px; margin-top: 20px; }
.btn { padding: 10px 20px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }

@keyframes shake { 30% { translate: -.5cqw 0; } 60% { translate: .5cqw 0; } }
@keyframes flashText { 30% { color: var(--bad); } }
/* さっと表示（0.1秒）→ しばらく表示 → ゆっくり消える */
@keyframes rise {
  from { opacity: 0; translate: 0 1cqw; scale: .85; }
  5% { opacity: 1; translate: 0 0; scale: 1; }
  45% { opacity: 1; }
  to { opacity: 0; translate: 0 -3cqw; }
}
@keyframes blink { to { filter: brightness(1.15); transform: translateY(.1cqw); } }
@keyframes pulse { to { opacity: .55; } }
@keyframes wobble { to { translate: 0 -.4cqw; scale: 1.04; } }
