/* Dash Go — app.css (11 §1). Portrait mobile-first; ≥ 360×640 no scroll
   (FR-073); desktop letterboxed. Reduced-motion handled in JS anim layer. */
:root {
  --bg: #16324f;
  --bg2: #1d3557;
  --panel: #f4f0e6;
  --ink: #1c2b3a;
  --accent: #ffd54a;
  --accent2: #e0533d;
  --radius: 14px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100dvh; }
@supports not (height: 100dvh) {
  html, body { height: 100vh; }
}
body {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: linear-gradient(180deg, var(--bg), var(--bg2));
  color: var(--panel);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* screens — dvh keeps board inside dynamic viewport (mobile address bar) */
.screen {
  position: fixed; inset: 0; display: none;
  flex-direction: column; align-items: center; justify-content: center;
  height: 100dvh;
}
@supports not (height: 100dvh) {
  .screen { height: 100vh; }
}
.screen.active { display: flex; }

/* loading */
.loading-wrap { text-align: center; width: min(78vw, 320px); }
.logo-img {
  width: min(60vw, 240px); height: auto; display: block; margin: 0 auto;
  aspect-ratio: 1176 / 625; /* reserve space — no CLS before image decode */
}
.logo-img.big { width: min(72vw, 300px); margin-bottom: 12px; }
.logo-img.end { width: min(40vw, 160px); margin: 0 auto 10px; }
.loading-label { margin: 18px 0 10px; font-size: 1rem; }
.loading-track { height: 8px; border-radius: 4px; background: rgba(255,255,255,0.18); overflow: hidden; }
.loading-bar { height: 100%; width: 0; background: var(--accent); transition: width 0.2s ease; }

/* home */
.home-wrap { text-align: center; padding: 24px; }
.home-sub { margin: 8px 0 26px; opacity: 0.85; max-width: 40ch; }

/* CTA (reference: yellow CTA) */
.cta {
  display: inline-block; min-width: 200px; padding: 14px 26px;
  background: var(--accent); color: #3b2c00; border: none; border-radius: 999px;
  font-size: 1.1rem; font-weight: 700; cursor: pointer;
  box-shadow: 0 4px 0 #c9a227; transition: transform 0.05s ease;
  min-height: 44px; /* tap target (FE-010) */
}
.cta:active { transform: translateY(2px); box-shadow: 0 2px 0 #c9a227; }
.cta.secondary { background: #40607f; color: var(--panel); box-shadow: 0 4px 0 #2b4258; }
.cta.hidden, .hidden { display: none !important; }

/* HUD */
.hud {
  display: flex; justify-content: space-around; align-items: center;
  width: 100%; padding: max(10px, env(safe-area-inset-top)) 12px 8px;
  gap: 8px;
}
.hud-item { text-align: center; }
.hud-label { display: block; font-size: 0.62rem; letter-spacing: 0.08em; opacity: 0.75; }
.hud-value { display: block; font-size: 1.15rem; font-weight: 700; color: var(--accent); min-width: 3.5em; }
#hud-combo .hud-value { color: var(--panel); }
#hud-combo.active .hud-value { color: #7bd389; }
#hud-combo.active::after { content: ' ×2'; color: #7bd389; font-size: 0.8rem; }
/* decorative HUD icons (P4): stopwatch above time, combo above score */
.hud-icon { display: block; width: 18px; height: 18px; margin: 0 auto 2px; object-fit: contain; opacity: 0.9; }
/* combo icon = combo-STATE indicator only: hidden unless combo is active —
   never a permanent decoration of the SCORE item */
#hud-combo .hud-icon-combo { display: none; }
#hud-combo.active .hud-icon-combo { display: block; }

/* board — flex center keeps computed-layout centered; min-height 0 lets flex shrink */
.board-wrap { flex: 1 1 auto; width: 100%; min-height: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; }
#board { width: 100%; height: 100%; max-width: 100%; max-height: 100%; display: block; touch-action: manipulation; }

/* actions */
.actions {
  display: flex; justify-content: center; gap: 14px;
  padding: 10px 12px max(12px, env(safe-area-inset-bottom));
  width: 100%;
}
.action-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 20px; border: none; border-radius: 999px;
  background: rgba(255,255,255,0.14); color: var(--panel);
  font-size: 1rem; font-weight: 600; cursor: pointer; min-height: 44px;
}
.action-btn:disabled { opacity: 0.4; }
.action-btn .badge {
  background: var(--accent); color: #3b2c00; border-radius: 999px;
  font-size: 0.8rem; padding: 1px 8px; font-weight: 700;
}
/* P4 opsi A: circular artwork as the button visual (added at runtime when the
   asset is ready); the pill styles above remain the fail-soft fallback. */
.action-btn.art {
  width: 64px; height: 64px; min-width: 44px; min-height: 44px;
  padding: 0; border-radius: 50%; position: relative;
  background: var(--btn-art) center / contain no-repeat;
}
.action-btn.art > span:not(.badge) {
  /* label stays in the accessible name — visually hidden, not removed */
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
.action-btn.art .badge { position: absolute; top: -4px; right: -6px; }
.action-btn.art:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
/* Sound toggle (sounds rev 1): same pill, muted state dims + strikes label */
.action-btn.sound-btn .badge { display: none; }
.action-btn.sound-btn.muted { opacity: 0.5; }
.action-btn.sound-btn.muted > span:first-child { text-decoration: line-through; }

/* end */
.end-wrap { text-align: center; padding: 24px; width: min(90vw, 420px); }
.end-title { font-size: 1.9rem; color: var(--accent); margin-bottom: 6px; }
.end-detail { opacity: 0.9; margin-bottom: 4px; }
.end-stats { margin-bottom: 18px; font-weight: 600; }
.end-actions { display: flex; gap: 10px; justify-content: center; margin-top: 14px; flex-wrap: wrap; }
.reward-wrap { margin: 18px auto; padding: 16px; background: rgba(255,255,255,0.1); border-radius: var(--radius); }
.reward-label { font-size: 0.8rem; opacity: 0.8; margin-bottom: 6px; letter-spacing: 0.06em; }
.reward-code {
  font-family: ui-monospace, 'Cascadia Mono', monospace; font-size: 1.4rem;
  font-weight: 700; color: var(--accent); letter-spacing: 0.12em;
  padding: 10px 14px; border: 2px dashed var(--accent); border-radius: 10px;
}

/* toast (reference: covered-tile toast) */
.toast {
  position: fixed; left: 50%; bottom: 88px; transform: translateX(-50%) translateY(16px);
  background: #2b2b2bee; color: #fff; padding: 10px 18px; border-radius: 999px;
  font-size: 0.95rem; opacity: 0; pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  max-width: 86vw; text-align: center;
}
.toast.active { opacity: 1; transform: translateX(-50%) translateY(0); }

/* interstitial (FR-021) */
.interstitial {
  position: fixed; inset: 0; display: none; align-items: center; justify-content: center;
  background: rgba(10, 22, 36, 0.88); z-index: 50; text-align: center; padding: 24px;
}
.interstitial.active { display: flex; }
.interstitial-text { font-size: 1.2rem; font-weight: 600; color: var(--accent); }

/* desktop letterbox (FR-073) */
@media (min-width: 720px) {
  .screen { padding: 0; }
  .board-wrap, .hud, .actions { max-width: 560px; margin: 0 auto; }
  .hud, .actions { width: 100%; }
}

/* mobile portrait narrow (≤380px): reclaim horizontal space, keep tile tappable */
@media (max-width: 380px) {
  .hud { padding: max(8px, env(safe-area-inset-top)) 8px 6px; gap: 6px; }
  .hud-value { font-size: 1rem; min-width: 3em; }
  .actions { gap: 10px; padding: 8px 8px max(8px, env(safe-area-inset-bottom)); }
}

/* mobile landscape (height-constrained): HUD/actions shrink so board keeps 44px touch target */
@media (orientation: landscape) and (max-height: 500px) {
  .hud { padding: 6px 10px 4px; gap: 6px; }
  .hud-label { font-size: 0.58rem; }
  .hud-value { font-size: 1rem; }
  .hud-icon { width: 16px; height: 16px; margin-bottom: 1px; }
  .actions { padding: 6px 10px max(6px, env(safe-area-inset-bottom)); gap: 10px; }
  .action-btn { padding: 8px 16px; min-height: 44px; }
  .board-wrap { min-height: 160px; }
  #board { min-height: 160px; }
}

/* coarse pointer: guarantee 44px+ tap target even if board is tiny */
@media (pointer: coarse) {
  .action-btn { min-height: 44px; min-width: 44px; }
  .cta { min-height: 44px; }
}
