/*
 * GAME CENTER 3D の画面のスタイル。
 *
 * 見た目のきまり：
 *   - 夏祭りの夜。紙（生成り）の札に、こげ茶の文字。大事なボタンは朱色、ふつうのボタンは藍色。
 *   - 文字は丸ゴシックの太字。見出しは白ぬきに濃いふちどり。
 *   - 3D の上に重ねる部品は、背景をぼかす効果（backdrop-filter）を使わない（スマホで重くなるため）。
 */

:root {
  color-scheme: dark;
  --night: #120f2b;
  --ink: #3a2217;
  --ink-soft: #7a5a48;
  --paper: #fff6e3;
  --paper-2: #ffe9c2;
  --paper-line: #e8cfa0;
  --red: #e5402b;
  --red-dark: #a3210f;
  --indigo: #2c4aa6;
  --indigo-dark: #162a66;
  --gold: #ffc93c;
  --gold-dark: #b97a00;
  --green: #2e9e5b;
  --pink: #f0629a;
  --font: "Hiragino Maru Gothic ProN", "Hiragino Sans", "Yu Gothic UI", "Yu Gothic", "Meiryo", "Noto Sans JP",
    system-ui, sans-serif;
}

/* touch-action はすべての要素に付ける（親に付けるだけでは、ダブルタップで拡大する端末がある） */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  touch-action: manipulation;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--night);
  color: var(--paper);
  font-family: var(--font);
  font-weight: 700;
  -webkit-font-smoothing: antialiased;
  /* タッチ端末対策。引っぱって更新・長押しメニュー・テキスト選択を止める */
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

button {
  font-family: inherit;
  font-weight: inherit;
  color: inherit;
  border: none;
  background: none;
  cursor: pointer;
}

#app {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  /* iOS Safari はツールバーがページに重なるので、実際に見えている高さを使う
     （--app-height は utils/viewport.ts が visualViewport から入れる） */
  height: var(--app-height, 100%);
  /* ノッチやホームバーに操作系が隠れないようにするための余白 */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

#stage {
  position: absolute;
  inset: 0;
}
#stage canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* ================================================================ ボタン */

.btn {
  position: relative;
  min-width: clamp(120px, 14vw, 220px);
  padding: clamp(12px, 1.6vh, 18px) clamp(16px, 2vw, 30px);
  border-radius: 18px;
  font-size: clamp(17px, 1.7vw, 26px);
  font-weight: 900;
  letter-spacing: 0.04em;
  line-height: 1.15;
  color: #fff;
  background: var(--indigo);
  border: 3px solid #fff;
  box-shadow: 0 6px 0 var(--indigo-dark), 0 10px 18px rgba(0, 0, 0, 0.35);
  transition: transform 0.08s, box-shadow 0.08s, filter 0.15s;
  white-space: nowrap;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(5px); box-shadow: 0 1px 0 var(--indigo-dark); }
.btn small {
  display: block;
  margin-top: 3px;
  font-size: 0.46em;
  font-weight: 700;
  letter-spacing: 0.14em;
  opacity: 0.8;
}
.btn.primary { background: var(--red); box-shadow: 0 6px 0 var(--red-dark), 0 10px 18px rgba(0, 0, 0, 0.35); }
.btn.primary:active { box-shadow: 0 1px 0 var(--red-dark); }
.btn.accent {
  background: var(--gold);
  color: var(--ink);
  box-shadow: 0 6px 0 var(--gold-dark), 0 10px 18px rgba(0, 0, 0, 0.35);
}
.btn.accent:active { box-shadow: 0 1px 0 var(--gold-dark); }
.btn:disabled { filter: grayscale(0.85) brightness(0.8); opacity: 0.6; cursor: not-allowed; }

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: clamp(10px, 1.4vw, 20px);
  justify-content: center;
  margin-top: clamp(16px, 2.4vh, 28px);
}
/* 長いカード（あそびかた・景品図鑑・一覧）では、とじるボタンをいつも下に見せておく（下まで送らなくても閉じられる） */
.btn-row.sticky {
  position: sticky;
  bottom: calc(-1 * var(--card-pad-y, 18px));
  z-index: 2;
  margin-bottom: calc(-1 * var(--card-pad-y, 18px));
  padding: 14px 0 var(--card-pad-y, 18px);
  background: linear-gradient(180deg, rgba(255, 246, 227, 0) 0, var(--paper) 16px);
}

/* ================================================================ 上のバー（HUD） */

#hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: calc(8px + var(--safe-top)) calc(12px + var(--safe-right)) 8px calc(12px + var(--safe-left));
  pointer-events: none;
  transition: opacity 0.3s;
}
#hud > * { pointer-events: auto; }
.hud-space { flex: 1; pointer-events: none !important; }
/* せまい画面のときだけ使う部品（1 段目の右寄せのすき間と、段の折り返し） */
.hud-space.first { display: none; }
.hud-break { display: none; flex-basis: 100%; height: 0; pointer-events: none !important; }

.hud-chip,
.hud-name,
.hud-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  padding: 0 12px;
  border-radius: 12px;
  background: var(--paper);
  color: var(--ink);
  border: 2px solid var(--ink);
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.35);
  font-size: 15px;
  white-space: nowrap;
}
.hud-chip .k { font-size: 11px; color: var(--ink-soft); }
.hud-chip b { font-size: 19px; font-weight: 900; font-variant-numeric: tabular-nums; }
.hud-name {
  background: var(--red);
  color: #fff;
  border-color: #fff;
  font-size: 17px;
  font-weight: 900;
}
.hud-btn { justify-content: center; min-width: 38px; padding: 0 10px; font-size: 16px; font-weight: 900; }
.hud-btn:active { transform: translateY(2px); box-shadow: none; }
.hud-btn.off { background: #cdbfae; color: #8a7767; }
.hud-btn.quit.armed { background: var(--red); color: #fff; border-color: #fff; }

.hud-chip.score { background: var(--ink); color: var(--gold); border-color: var(--gold); }
.hud-chip.score .k { color: #f3d9a0; }
.hud-chip.score b { font-size: 22px; }
/* 星（もらえる くじ券の数）と、次の星の線 */
.hud-chip.score .goal-stars { color: var(--gold); font-size: 13px; letter-spacing: 0.04em; }
.hud-chip.score .goal-next { color: #cdb588; font-size: 12px; font-weight: 700; white-space: nowrap; }
.hud-chip.score.star-up { animation: star-up 0.6s cubic-bezier(0.2, 1.4, 0.4, 1); }
@keyframes star-up {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 210, 63, 0.9); }
  35% { transform: scale(1.22); box-shadow: 0 0 0 10px rgba(255, 210, 63, 0); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 210, 63, 0); }
}
.hud-chip.ticket { background: var(--gold); }
.hud-chip.best b { font-size: 16px; }

.hud-chip.plays .pips { display: flex; gap: 3px; }
.hud-chip.plays .pip { width: 9px; height: 9px; border-radius: 50%; background: #d9c6a4; }
.hud-chip.plays .pip.on { background: var(--red); }

.hud-chip.time b { font-size: 22px; min-width: 1.4em; text-align: center; }
.hud-chip.time.warn { background: var(--red); color: #fff; border-color: #fff; animation: blink 1s steps(2, end) infinite; }
.hud-chip.time.warn .k { color: #ffe1d8; }

.hud-chip.gauge .bar {
  width: clamp(70px, 12vw, 150px);
  height: 12px;
  border-radius: 6px;
  background: #d9c6a4;
  overflow: hidden;
}
.hud-chip.gauge .bar i {
  display: block;
  height: 100%;
  width: 100%;
  border-radius: 6px;
  background: linear-gradient(90deg, #2e9e5b, #7ed957);
}
.hud-chip.gauge b { min-width: 2.7em; text-align: right; font-size: 16px; }
.hud-chip.gauge.warn .bar i { background: linear-gradient(90deg, #e5402b, #ff8a5b); }
.hud-chip.gauge.warn { animation: blink 1s steps(2, end) infinite; }

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* ================================================================ ひとこと（遊び方の案内） */

#hint {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(58px + var(--safe-top));
  z-index: 9;
  display: flex;
  justify-content: center;
  padding: 0 12px;
  pointer-events: none;
  transition: opacity 0.3s;
}
.hint-bubble {
  max-width: min(92vw, 560px);
  padding: 6px 16px;
  border-radius: 999px;
  background: rgba(18, 15, 43, 0.78);
  border: 2px solid rgba(255, 233, 194, 0.55);
  color: var(--paper);
  font-size: clamp(13px, 1.2vw, 17px);
  line-height: 1.35;
  text-align: center;
  white-space: pre-line;
}
.hint-bubble:empty { display: none; }

/* ================================================================ 操作ボタン */

#controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 12px calc(20px + var(--safe-right)) calc(16px + var(--safe-bottom)) calc(20px + var(--safe-left));
  pointer-events: none;
  transition: opacity 0.3s;
}
#controls > * { pointer-events: auto; }

.dpad {
  display: grid;
  grid-template-columns: repeat(3, auto);
  grid-template-rows: repeat(3, auto);
  gap: 5px;
  align-items: center;
  justify-items: center;
}
.pad-button {
  width: clamp(52px, 4.6vw, 68px);
  height: clamp(52px, 4.6vw, 68px);
  border-radius: 50%;
  border: 3px solid #fff;
  background: var(--indigo);
  color: #fff;
  font-size: clamp(17px, 1.5vw, 23px);
  box-shadow: 0 5px 0 var(--indigo-dark), 0 8px 14px rgba(0, 0, 0, 0.35);
  transition: transform 0.08s, box-shadow 0.08s, filter 0.15s;
  touch-action: none;
}
.pad-button.pressed { transform: translateY(4px); box-shadow: 0 1px 0 var(--indigo-dark); filter: brightness(0.9); }
.pad-button.unused { visibility: hidden; }
.pad-center { font-size: 11px; color: var(--paper); text-shadow: 0 1px 3px #000; text-align: center; }

.action-area { display: flex; align-items: flex-end; }
.action-button {
  min-width: clamp(170px, 18vw, 280px);
  padding: clamp(16px, 2vh, 24px) clamp(18px, 2vw, 30px);
  border-radius: 24px;
  border: 4px solid #fff;
  background: var(--red);
  color: #fff;
  font-size: clamp(24px, 2.6vw, 38px);
  font-weight: 900;
  letter-spacing: 0.06em;
  line-height: 1.1;
  box-shadow: 0 8px 0 var(--red-dark), 0 14px 22px rgba(0, 0, 0, 0.4);
  transition: transform 0.08s, box-shadow 0.08s, filter 0.15s;
  touch-action: none;
  white-space: nowrap;
}
.action-button small { display: block; margin-top: 4px; font-size: 11px; letter-spacing: 0.16em; opacity: 0.8; }
.action-button.pressed { transform: translateY(7px); box-shadow: 0 1px 0 var(--red-dark); }
.action-button.water { background: #1f8fd6; box-shadow: 0 8px 0 #0e4f85, 0 14px 22px rgba(0, 0, 0, 0.4); }
.action-button.water.pressed { box-shadow: 0 1px 0 #0e4f85; }
.action-button:disabled,
.pad-button:disabled {
  filter: grayscale(0.8) brightness(0.75);
  opacity: 0.55;
  cursor: not-allowed;
}

/* 金魚すくいのレバー。丸い台の上の赤い玉を、指でつまんで倒す */
.lever {
  position: relative;
  width: clamp(150px, 13vw, 200px);
  height: clamp(150px, 13vw, 200px);
  touch-action: none;
  cursor: grab;
}
.lever.held { cursor: grabbing; }
.lever.disabled { opacity: 0.45; }
.lever-base {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 42%, #3d5fc4 0%, #24408e 60%, #162a66 100%);
  border: 4px solid #fff;
  box-shadow: 0 6px 0 var(--indigo-dark), 0 12px 20px rgba(0, 0, 0, 0.4), inset 0 0 18px rgba(0, 0, 0, 0.4);
}
/* 内側の点線の輪：ここまでなら水中でもゆっくり（金魚が逃げない） */
.lever-gate {
  position: absolute;
  inset: 26%;
  border-radius: 50%;
  border: 3px dashed rgba(255, 255, 255, 0.6);
}
.lever-shaft {
  position: absolute;
  left: 50%;
  top: 50%;
  height: 12px;
  margin-top: -6px;
  width: 0;
  border-radius: 6px;
  background: linear-gradient(180deg, #f1f4fa 0%, #a4adc0 60%, #707a92 100%);
  transform-origin: 0 50%;
  pointer-events: none;
  opacity: 0;
}
.lever-knob {
  position: absolute;
  left: 30%;
  top: 30%;
  width: 40%;
  height: 40%;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffc2b0 0%, #ff5a40 38%, #c8261a 75%, #7a100a 100%);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.5), inset 0 -4px 8px rgba(0, 0, 0, 0.25);
  pointer-events: none;
  transition: transform 0.12s ease-out;
}
.lever.held .lever-knob { transition: none; }
.lever-caption {
  position: absolute;
  left: 0;
  right: 0;
  top: -20px;
  font-size: 12px;
  color: var(--paper);
  text-shadow: 0 1px 3px #000;
  text-align: center;
  pointer-events: none;
}

/* ================================================================ 重ねる画面（カード） */

#overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: none;
  align-items: center;
  justify-content: center;
  padding: calc(10px + var(--safe-top)) calc(10px + var(--safe-right)) calc(10px + var(--safe-bottom))
    calc(10px + var(--safe-left));
}
#overlay.show { display: flex; }
#overlay .veil {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(18, 15, 43, 0.55) 0%, rgba(10, 8, 26, 0.88) 75%);
  animation: fade-in 0.28s ease both;
}
/* タイトルでは通りを見せたいので、暗くするのは上下だけ */
#overlay .veil.light {
  background: linear-gradient(
    180deg,
    rgba(10, 8, 26, 0.72) 0%,
    rgba(10, 8, 26, 0.12) 34%,
    rgba(10, 8, 26, 0.12) 52%,
    rgba(10, 8, 26, 0.82) 100%
  );
}

.card {
  position: relative;
  width: min(100%, 760px);
  max-height: 100%;
  overflow-y: auto;
  --card-pad-y: clamp(18px, 3vh, 34px);
  padding: var(--card-pad-y) clamp(16px, 3vw, 40px);
  border-radius: 26px;
  background: var(--paper);
  color: var(--ink);
  border: 4px solid var(--ink);
  box-shadow: 0 0 0 4px var(--paper), 0 0 0 7px var(--red), 0 24px 60px rgba(0, 0, 0, 0.6);
  text-align: center;
  animation: pop-in 0.34s cubic-bezier(0.2, 1.3, 0.5, 1) both;
}
.card.wide { width: min(100%, 940px); }
.card.plain {
  background: none;
  border: none;
  box-shadow: none;
  color: var(--paper);
}

.headline {
  font-size: clamp(30px, 4.6vw, 62px);
  font-weight: 900;
  line-height: 1.15;
  letter-spacing: 0.04em;
  color: var(--red);
}
.headline.good { color: #d98a00; }
.headline.bad { color: var(--ink-soft); }
.card.plain .headline {
  color: #fff;
  -webkit-text-stroke: 0;
  text-shadow: 0 0 0 #000, 0 4px 0 var(--red-dark), 0 6px 16px rgba(0, 0, 0, 0.6);
}
.sub { margin-top: 10px; font-size: clamp(14px, 1.4vw, 21px); line-height: 1.5; color: var(--ink-soft); }
.card.plain .sub { color: var(--paper-2); }
.tag {
  display: inline-block;
  margin-top: 8px;
  padding: 3px 14px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  font-size: clamp(13px, 1.1vw, 17px);
}

/* ---- 選ぶ画面（モード・むずかしさ・形・屋台の一覧） */

.choice-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 20px auto 0;
  width: 100%;
  max-width: 560px;
}
.choice-list.many {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 270px), 1fr));
  max-width: 900px;
  gap: 10px;
}
.choice {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px 18px;
  border-radius: 18px;
  background: #fff;
  color: var(--ink);
  border: 3px solid var(--ink);
  box-shadow: 0 5px 0 var(--ink);
  text-align: left;
  transition: transform 0.1s, box-shadow 0.1s, background 0.15s;
}
.choice:hover,
.choice:focus-visible { background: var(--paper-2); }
.choice:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.choice.disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }
.choice-badge {
  flex: none;
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: var(--paper-2);
  font-size: 25px;
}
.choice-body { flex: 1; min-width: 0; }
.choice-label { font-size: clamp(19px, 1.9vw, 26px); font-weight: 900; }
.choice-caption { margin-top: 2px; font-size: clamp(12px, 1.05vw, 15px); color: var(--ink-soft); line-height: 1.35; }
.choice-best { flex: none; font-size: 13px; color: #b06a00; text-align: right; line-height: 1.3; }
.choice-list.many .choice { padding: 10px 14px; gap: 10px; }
.choice-list.many .choice-badge { width: 42px; height: 42px; font-size: 22px; }
.choice-list.many .choice-label { font-size: clamp(17px, 1.6vw, 22px); }

/* ---- 星（屋台ごとのできばえ。くじ券をもらえた枚数と同じ） */
.stars { letter-spacing: 0.08em; color: #d9c6a4; white-space: nowrap; }
.stars .on { color: #f2a900; }
.stars.big { font-size: clamp(30px, 4vw, 52px); }
.stars.big .on { display: inline-block; animation: star-pop 0.5s cubic-bezier(0.2, 1.6, 0.4, 1) both; }
.stars.big .on:nth-child(2) { animation-delay: 0.18s; }
.stars.big .on:nth-child(3) { animation-delay: 0.36s; }
@keyframes star-pop {
  from { transform: scale(0) rotate(-40deg); }
  to { transform: scale(1) rotate(0); }
}

/* ---- 結果 */

.stat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px clamp(14px, 3vw, 44px);
  justify-content: center;
  margin: clamp(12px, 2vh, 22px) 0;
}
.stat .k { font-size: clamp(11px, 0.95vw, 14px); color: var(--ink-soft); }
.stat .v { font-size: clamp(24px, 3vw, 44px); font-weight: 900; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat .v.score { color: var(--red); }
.stat .v.good { color: var(--green); }
.stat .v.best { color: #c98200; }
.stat .v.sub { color: var(--indigo); }

.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 6px 0 10px; }
.chips-title { font-size: 13px; color: var(--ink-soft); margin-top: 6px; }
.chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 14px 5px 6px;
  border-radius: 999px;
  background: #fff;
  border: 2px solid var(--paper-line);
  font-size: clamp(13px, 1.1vw, 17px);
}
.chip img { width: clamp(30px, 2.6vw, 42px); height: auto; }
.chip .swatch { width: 26px; height: 26px; border-radius: 50%; border: 2px solid rgba(0, 0, 0, 0.2); }
.chip b { color: var(--red); }

.ribbon {
  display: inline-block;
  margin-top: 8px;
  padding: 4px 22px;
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  font-size: clamp(16px, 1.8vw, 26px);
  font-weight: 900;
  animation: throb 1.2s ease-in-out infinite;
}
.ticket-line {
  margin-top: 12px;
  padding: 8px 14px;
  border-radius: 14px;
  background: var(--paper-2);
  font-size: clamp(14px, 1.3vw, 19px);
  line-height: 1.5;
}
.ticket-line.got { background: var(--gold); }
.ticket-line small { display: block; font-size: 0.82em; color: var(--ink-soft); }

.kuji-rank {
  font-size: clamp(60px, 10vw, 130px);
  font-weight: 900;
  line-height: 1.05;
  text-shadow: 0 5px 0 rgba(0, 0, 0, 0.18);
}

/* ---- 遊び方 */

.howto {
  margin-top: 14px;
  text-align: left;
  font-size: clamp(14px, 1.2vw, 17px);
  font-weight: 500;
  line-height: 1.7;
}
.howto h3 {
  margin: 16px 0 4px;
  padding: 4px 12px;
  border-radius: 10px;
  background: var(--paper-2);
  font-size: 1.1em;
  font-weight: 900;
}
.howto b { font-weight: 900; color: var(--red-dark); }

/* ---- 景品図鑑 */

.zukan-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 10px;
  margin: 16px 0 6px;
}
.zukan-cell {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 26px 6px 10px;
  border-radius: 16px;
  background: #efe2c6;
  border: 2px dashed #cdb78c;
}
.zukan-cell img {
  width: 74px;
  height: 74px;
  object-fit: contain;
  /* まだ当たっていない景品は影だけ見せる */
  filter: brightness(0) opacity(0.3);
}
.zukan-cell.owned { background: #fff; border: 2px solid var(--gold-dark); }
.zukan-cell.owned img { filter: drop-shadow(0 5px 6px rgba(0, 0, 0, 0.25)); }
.zukan-rank {
  position: absolute;
  top: 6px;
  left: 6px;
  padding: 1px 9px;
  border-radius: 999px;
  font-size: 12px;
  color: #fff;
}
.zukan-name { font-size: 13px; text-align: center; }
.zukan-cell:not(.owned) .zukan-name { color: #a8946f; }
.zukan-count { position: absolute; top: 6px; right: 8px; font-size: 12px; color: var(--red); }

/* ================================================================ タイトル */

.title { display: flex; flex-direction: column; align-items: center; }
.title-brand {
  padding: 4px 16px;
  border-radius: 999px;
  background: rgba(18, 15, 43, 0.7);
  border: 2px solid var(--gold);
  color: var(--gold);
  font-size: clamp(12px, 1.1vw, 16px);
  letter-spacing: 0.22em;
}
/* 題字。1 文字ずつ、ひもに吊った提灯に書く */
.title-lanterns {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0 clamp(4px, 0.6vw, 10px);
  margin-top: clamp(14px, 2.4vh, 26px);
}
.title-word { display: flex; gap: clamp(4px, 0.6vw, 10px); padding: 0 clamp(6px, 1vw, 16px); }
.title-lantern {
  position: relative;
  width: clamp(44px, 6.6vw, 96px);
  height: clamp(56px, 8.4vw, 122px);
  margin-top: clamp(14px, 2vw, 26px);
  display: grid;
  place-items: center;
  border-radius: 50% / 44%;
  background: radial-gradient(circle at 42% 34%, #ffb38a 0%, #ff5a36 52%, #cf2f18 100%);
  color: #fff;
  font-size: clamp(26px, 4.2vw, 62px);
  font-weight: 900;
  text-shadow: 0 2px 0 rgba(120, 20, 8, 0.6);
  box-shadow: 0 0 34px rgba(255, 110, 60, 0.7);
  transform-origin: 50% -18%;
  animation: sway 2.6s ease-in-out infinite;
}
.title-lantern.cream {
  background: radial-gradient(circle at 42% 34%, #ffffff 0%, #ffe9c2 55%, #f0c98a 100%);
  color: var(--red);
  text-shadow: none;
  box-shadow: 0 0 34px rgba(255, 220, 160, 0.6);
}
/* 上下の黒いふたと、吊りひも */
.title-lantern::before,
.title-lantern::after {
  content: "";
  position: absolute;
  left: 30%;
  right: 30%;
  height: 9%;
  border-radius: 3px;
  background: #24140f;
}
.title-lantern::before { top: -3%; box-shadow: 0 calc(clamp(14px, 2vw, 26px) * -0.55) 0 -3px #24140f; }
.title-lantern::after { bottom: -3%; }
@keyframes sway {
  0%, 100% { transform: rotate(-3.2deg); }
  50% { transform: rotate(3.2deg); }
}
.title-sub {
  margin-top: clamp(14px, 2.2vh, 24px);
  font-size: clamp(18px, 2.4vw, 34px);
  font-weight: 900;
  color: #fff;
  text-shadow: 0 3px 0 var(--red-dark), 0 5px 14px rgba(0, 0, 0, 0.7);
  letter-spacing: 0.08em;
}
.title-info {
  margin-top: clamp(14px, 2.4vh, 24px);
  padding: 6px 18px;
  border-radius: 999px;
  background: rgba(18, 15, 43, 0.72);
  color: var(--paper-2);
  font-size: clamp(13px, 1.2vw, 17px);
}

/* ================================================================ 知らせ（GET! など） */

#toast {
  position: absolute;
  left: 50%;
  top: 30%;
  transform: translate(-50%, -50%);
  z-index: 25;
  pointer-events: none;
  display: none;
  text-align: center;
  width: max-content;
  max-width: 92vw;
}
#toast.show { display: block; animation: toast-in 0.26s cubic-bezier(0.2, 1.5, 0.5, 1) both; }
.toast-head {
  font-size: clamp(34px, 5.4vw, 72px);
  font-weight: 900;
  line-height: 1.1;
  color: #fff;
  -webkit-text-stroke: clamp(5px, 0.7vw, 9px) var(--red-dark);
  paint-order: stroke fill;
  text-shadow: 0 6px 14px rgba(0, 0, 0, 0.5);
}
.toast-head.good { -webkit-text-stroke-color: #b06a00; color: #fff7d6; }
.toast-head.bad { -webkit-text-stroke-color: #33405f; }
.toast-sub {
  display: inline-block;
  margin-top: 8px;
  padding: 5px 18px;
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  border: 2px solid var(--ink);
  font-size: clamp(14px, 1.5vw, 22px);
  white-space: pre-line;
}
.toast-sub:empty { display: none; }
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, -50%) scale(0.6); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* とくてんが飛んでいく数字 */
.fly-score {
  position: absolute;
  z-index: 26;
  pointer-events: none;
  font-size: clamp(22px, 2.6vw, 36px);
  font-weight: 900;
  color: var(--gold);
  -webkit-text-stroke: 5px var(--ink);
  paint-order: stroke fill;
  white-space: nowrap;
}

/* 紙吹雪 */
.confetti { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 40; }
.confetti i {
  position: absolute;
  top: -8vh;
  width: 10px;
  height: 16px;
  opacity: 0.95;
  animation-name: confetti-fall;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
}
@keyframes confetti-fall {
  0% { transform: translateY(0) rotate(0deg); }
  100% { transform: translateY(115vh) rotate(720deg); }
}

/* ================================================================ 店を選ぶ画面 */

.shop { position: absolute; inset: 0; z-index: 20; pointer-events: none; }
.shop-tags { position: absolute; inset: 0; overflow: hidden; }
/* 店の上に浮かぶ名札。位置は JS が毎フレーム決める */
.shop-tag {
  position: absolute;
  left: 0;
  top: 0;
  padding: 5px 13px;
  border-radius: 999px;
  background: rgba(18, 15, 43, 0.82);
  border: 2px solid rgba(255, 233, 194, 0.6);
  color: var(--paper);
  font-size: clamp(12px, 1.05vw, 16px);
  white-space: nowrap;
  pointer-events: auto;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
}
.shop-tag.active {
  background: var(--gold);
  color: var(--ink);
  border-color: #fff;
  font-size: clamp(14px, 1.3vw, 19px);
  font-weight: 900;
  box-shadow: 0 0 22px rgba(255, 201, 60, 0.8), 0 4px 10px rgba(0, 0, 0, 0.4);
}
.shop-hint {
  position: absolute;
  top: calc(12px + var(--safe-top));
  left: 0;
  right: 0;
  text-align: center;
  font-size: clamp(12px, 1.1vw, 16px);
  color: var(--paper);
  text-shadow: 0 2px 6px #000, 0 0 12px #000;
}
.shop-card {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(14px + var(--safe-bottom));
  margin: 0 auto;
  width: min(94vw, 620px);
  padding: 12px 14px 16px;
  border-radius: 22px;
  background: var(--paper);
  color: var(--ink);
  border: 3px solid var(--ink);
  box-shadow: 0 0 0 3px var(--paper), 0 0 0 6px var(--red), 0 16px 40px rgba(0, 0, 0, 0.55);
  pointer-events: auto;
}
.shop-row { display: flex; align-items: center; gap: 8px; }
.shop-nav {
  flex: none;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 3px solid #fff;
  background: var(--indigo);
  color: #fff;
  font-size: 19px;
  box-shadow: 0 4px 0 var(--indigo-dark);
  outline: 2px solid var(--ink);
}
.shop-nav:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--indigo-dark); }
.shop-info { flex: 1; min-width: 0; text-align: center; }
.shop-name { font-size: clamp(21px, 2.3vw, 32px); font-weight: 900; line-height: 1.2; }
.shop-caption { margin-top: 3px; font-size: clamp(12px, 1.1vw, 16px); color: var(--ink-soft); line-height: 1.35; }
.shop-card.disabled .shop-caption { color: var(--red); }
.shop-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 2px 12px;
  margin-top: 5px;
  font-size: clamp(12px, 1.05vw, 15px);
  color: #9a6a00;
}
.shop-meta .stars { font-size: 1.25em; }
.shop-buttons { display: flex; gap: 10px; justify-content: center; margin-top: 12px; }
.shop-buttons .btn { min-width: 0; padding: 13px 14px; }
.shop-buttons .shop-play { flex: 2.2; }
.shop-buttons .shop-list,
.shop-buttons .shop-back { flex: 1; }

/* ================================================================ 動き */

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes pop-in {
  from { opacity: 0; transform: scale(0.88); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes throb {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

/* ================================================================ 画面の形に合わせる */

/* 指で押す端末では、キーの案内は意味がないので消す */
@media (pointer: coarse) {
  .btn small,
  .action-button small { display: none; }
  .pad-button { width: 70px; height: 70px; font-size: 24px; }
  .lever { width: 184px; height: 184px; }
  .action-button { min-width: 190px; }
}

/* 横幅がせまい（スマホの縦持ち）：上のバーを 2 段にする */
@media (max-width: 700px) {
  /* 1 段目：やめる・名前・音・くじ券 ／ 2 段目：のこり・ベスト・とくてん */
  #hud > * { order: 1; }
  .hud-space.first { display: block; }
  .hud-break { display: block; order: 2; }
  #hud > .row2 { order: 3; }
  #hud { gap: 6px; }
  .hud-chip,
  .hud-name,
  .hud-btn { height: 34px; padding: 0 9px; font-size: 14px; }
  .hud-name { font-size: 15px; }
  .hud-chip b { font-size: 17px; }
  .hud-chip.score b { font-size: 19px; }
  .hud-chip.best { display: none; }
  #hint { top: calc(92px + var(--safe-top)); }
}

/* 縦長の画面：操作ボタンを左右に並べ、大きなボタンを広く */
@media (max-aspect-ratio: 1 / 1) {
  #controls { align-items: center; gap: 12px; padding-left: calc(14px + var(--safe-left)); padding-right: calc(14px + var(--safe-right)); }
  .action-area { flex: 1; }
  .action-button { min-width: 0; width: 100%; }
}
/* 縦長で幅の広い画面（タブレットの縦持ち）：大きなボタンが横いっぱいに細長くならないよう、右に寄せて大きくする */
@media (max-aspect-ratio: 1 / 1) and (min-width: 600px) {
  #controls { justify-content: space-between; }
  .action-area { flex: 0 1 440px; }
  .action-button { font-size: 34px; padding: 26px 16px; }
}
@media (max-aspect-ratio: 1 / 1) and (max-width: 440px) {
  .pad-button { width: 58px; height: 58px; font-size: 20px; }
  .lever { width: 156px; height: 156px; }
  .action-button { font-size: 25px; padding: 20px 8px; }
  .shop-card { padding: 10px 10px 14px; }
  .shop-name { font-size: 20px; }
  .shop-nav { width: 46px; height: 46px; }
  .shop-buttons { gap: 7px; }
  .shop-buttons .btn { padding: 13px 6px; font-size: 16px; letter-spacing: 0; }
  .choice { padding: 11px 12px; gap: 10px; }
  .choice-best { display: none; }
}

/* 低い横画面（スマホの横持ち）：全体を一段小さくして、屋台が見える帯を広く残す */
@media (max-height: 520px) {
  #hud { gap: 6px; padding-top: calc(5px + var(--safe-top)); padding-bottom: 4px; }
  .hud-chip,
  .hud-name,
  .hud-btn { height: 30px; padding: 0 8px; font-size: 13px; }
  .hud-chip b { font-size: 16px; }
  .hud-break,
  .hud-space.first { display: none; }
  #hud > * { order: 0; }
  #hint { top: calc(42px + var(--safe-top)); }
  .hint-bubble { font-size: 12px; padding: 3px 12px; }
  #controls { padding-top: 6px; padding-bottom: calc(8px + var(--safe-bottom)); }
  .pad-button { width: 50px; height: 50px; font-size: 18px; }
  .dpad { gap: 3px; }
  .lever { width: 128px; height: 128px; }
  .action-button { min-width: 150px; font-size: 23px; padding: 12px 16px; border-radius: 18px; }
  .card { padding: 12px 16px; border-radius: 18px; }
  .headline { font-size: clamp(24px, 4.4vw, 40px); }
  .choice-list { margin-top: 10px; gap: 8px; }
  .choice-list:not(.many) { flex-direction: row; max-width: 860px; }
  .choice-list:not(.many) .choice { flex-direction: column; text-align: center; gap: 6px; padding: 10px 8px; }
  .choice-list.many { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
  .choice-list.many .choice { padding: 6px 9px; }
  .choice-list.many .choice-caption { display: none; }
  .choice-badge { width: 36px; height: 36px; font-size: 19px; }
  .choice-best { display: none; }
  .btn-row { margin-top: 10px; }
  .btn { padding: 9px 16px; font-size: 16px; border-radius: 14px; }
  .stat-row { margin: 6px 0; }
  .stat .v { font-size: clamp(20px, 3vw, 30px); }
  .title-lantern { width: clamp(34px, 6vw, 56px); height: clamp(44px, 7.6vw, 70px); font-size: clamp(20px, 3.6vw, 34px); margin-top: 12px; }
  .title-sub { font-size: 18px; margin-top: 8px; }
  .title-info { margin-top: 8px; }
  /* 店のカードは右下へ寄せて、店が見える場所を広く残す */
  .shop-card { width: min(54vw, 440px); left: auto; right: calc(10px + var(--safe-right)); bottom: calc(8px + var(--safe-bottom)); padding: 8px 10px 10px; }
  .shop-caption,
  .shop-hint { display: none; }
  .shop-nav { width: 40px; height: 40px; font-size: 15px; }
  .shop-buttons { margin-top: 8px; }
  .shop-buttons .btn { padding: 9px 8px; font-size: 15px; }
}

/* タイトルの「つづきから」。下の小さい文字に、前に遊んだ屋台の名前を出す */
.btn.resume small { display: block; font-size: 12px; letter-spacing: 0.02em; opacity: 0.85; text-transform: none; }
@media (pointer: coarse) {
  .btn.resume small { display: block; }
}
