/* Game page shell: top bar, play area (canvas), booster bar. Each game sets --bg-top/--bg-bottom/--hud-ink. */

html, body { height: 100%; }
body.game {
  overflow: hidden; overscroll-behavior: none; touch-action: manipulation;
  display: flex; flex-direction: column; min-height: 100dvh;
  background: linear-gradient(180deg, var(--bg-top, #2a1b4a), var(--bg-bottom, #120c22));
  color: var(--hud-ink, #fff);
  padding-top: env(safe-area-inset-top, 0px);
}

.hud {
  display: flex; align-items: center; gap: 10px; flex: none;
  padding: 10px max(14px, env(safe-area-inset-right, 0px)) 6px max(14px, env(safe-area-inset-left, 0px));
}
.hud-btn {
  width: 42px; height: 42px; flex: none; display: grid; place-items: center; border-radius: 14px; border: 0;
  background: var(--hud-chip, rgba(255, 255, 255, .12)); color: inherit; text-decoration: none;
}
.hud-btn svg { width: 22px; height: 22px; }
.hud-title { flex: 1; min-width: 0; text-align: center; line-height: 1.1; }
.hud-title small { display: block; font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; opacity: .7; }
.hud-title b { font: 700 22px/1.15 var(--display); }

.subhud {
  display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; flex: none;
  padding: 0 14px 4px; font-size: 14px; font-weight: 600;
}
.chip { padding: 3px 12px; border-radius: 999px; background: var(--hud-chip, rgba(255, 255, 255, .12)); }

.stage { position: relative; flex: 1; min-height: 0; }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

.boosters {
  display: flex; justify-content: center; gap: 12px; flex: none;
  padding: 8px max(14px, env(safe-area-inset-right, 0px)) calc(14px + env(safe-area-inset-bottom, 0px)) max(14px, env(safe-area-inset-left, 0px));
}
.boost {
  position: relative; display: grid; justify-items: center; gap: 2px; min-width: 66px; padding: 8px 10px 6px;
  border: 0; border-radius: 18px; background: var(--hud-chip, rgba(255, 255, 255, .12)); color: inherit;
  font-size: 12.5px; font-weight: 700; transition: transform .1s, opacity .2s;
}
.boost:active { transform: scale(.94); }
.boost svg { width: 26px; height: 26px; }
.boost .n {
  position: absolute; top: -6px; right: -4px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px;
  background: var(--chili); color: #fff; font-size: 12.5px; line-height: 22px;
}
.boost[aria-disabled="true"] { opacity: .45; }

/* Level-1 tutorial hand */
.coach {
  position: absolute; z-index: 5; pointer-events: none; font-size: 15px; font-weight: 700;
  left: 50%; transform: translateX(-50%); top: 6px; padding: 8px 14px; border-radius: 14px;
  background: rgba(0, 0, 0, .55); color: #fff; white-space: nowrap; max-width: calc(100% - 24px); overflow: hidden; text-overflow: ellipsis;
}
.hand {
  position: absolute; z-index: 6; width: 44px; height: 44px; pointer-events: none; margin: -6px 0 0 -14px;
  animation: tapme 1.1s ease-in-out infinite; filter: drop-shadow(0 4px 6px rgba(0, 0, 0, .35));
}
@keyframes tapme { 0%, 100% { transform: translateY(0) scale(1); } 50% { transform: translateY(10px) scale(.92); } }

/* Win modal */
.win .stars { display: flex; justify-content: center; gap: 6px; margin-top: -4px; }
.win .stars svg { width: 46px; height: 46px; color: #e6d7bf; }
.win .stars svg.on { color: var(--turmeric); animation: starpop .45s cubic-bezier(.2, 1.6, .4, 1) both; }
.win .stars svg.on:nth-child(2) { animation-delay: .15s; }
.win .stars svg.on:nth-child(3) { animation-delay: .3s; }
@keyframes starpop { from { transform: scale(0) rotate(-40deg); } to { transform: none; } }
.win .stat { display: flex; justify-content: center; gap: 18px; color: var(--ink-soft); font-weight: 600; }
.win .stat b { color: var(--ink); font-size: 20px; }
.win .actions { display: grid; gap: 10px; }
.win .streak { font-weight: 700; color: var(--chili); }

@media (min-width: 700px) {
  .hud, .subhud, .boosters { max-width: 720px; width: 100%; margin-inline: auto; }
}

/* Arcade: coach line over the stage */
.coach-line {
  position: absolute; z-index: 5; left: 50%; top: 10px; transform: translate(-50%, -8px); opacity: 0; pointer-events: none;
  max-width: calc(100% - 24px); padding: 8px 16px; border-radius: 14px; background: rgba(0, 0, 0, .6); color: #fff;
  font-size: 16px; font-weight: 700; text-align: center; transition: opacity .25s, transform .25s; width: max-content;
}
.coach-line.show { opacity: 1; transform: translate(-50%, 0); }

/* Arcade: end-of-run screen */
.end { text-align: center; }
.end .end-kicker { font-weight: 800; letter-spacing: .12em; text-transform: uppercase; font-size: 13px; color: var(--chili); }
.end .end-score b { font: 700 64px/1 var(--display); color: var(--ink); }
.end .end-score span { font-weight: 700; color: var(--ink-soft); }
.end .end-best { font-weight: 700; }
.end .end-best.new { color: var(--chili); font-size: 18px; }
.end .end-vs { font-weight: 700; padding: 8px 12px; border-radius: 12px; background: #f6ead6; color: var(--ink); }
.end .end-vs.won { background: var(--mint); color: #fff; }
.end .end-stats { display: grid; grid-template-columns: auto auto; justify-content: center; gap: 2px 14px; margin: 0; color: var(--ink-soft); font-weight: 600; }
.end .end-stats dt { text-align: right; }
.end .end-stats dd { margin: 0; text-align: left; color: var(--ink); font-weight: 800; }
.end .actions { display: grid; gap: 10px; }
.hud-right { display: flex; gap: 6px; }
.hud-btn.help { font: 800 20px/1 var(--font); }
.end .end-next {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 14px; text-decoration: none; color: var(--ink);
  border: 1.5px dashed var(--line); text-align: left;
}
.end .end-next .next-art { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; flex: none; }
.end .end-next .next-art svg { width: 34px; height: 34px; }
.end .end-next small { display: block; font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-soft); }
.end .end-next b { font-size: 17px; }
.end .end-next .go { margin-left: auto; font-weight: 800; color: var(--chili); }

/* Way out of an end screen: Home and the game's page (the HUD back button is behind the modal) */
.modal .end-exit { display: flex; justify-content: center; gap: 8px; border-top: 1px solid var(--line); padding-top: 12px; margin-top: 2px; }
.modal .end-exit a {
  flex: 1 1 0; max-width: 170px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border-radius: 999px; color: var(--ink-soft); font-weight: 800; font-size: 15px; text-decoration: none;
}
.modal .end-exit a:hover, .modal .end-exit a:focus-visible { background: rgba(43, 29, 20, .06); color: var(--ink); }
.modal .end-exit svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }

/* Inline rating row (end screen / win modal) */
.rate { display: grid; justify-items: center; gap: 2px; }
.rate .rate-q { font-weight: 700; color: var(--ink-soft); font-size: 15px; }
.rate-stars { display: flex; gap: 4px; }
.rate-stars button {
  width: 44px; height: 44px; border: 0; background: none; font-size: 32px; line-height: 1; color: #e6d7bf; cursor: pointer;
  transition: transform .12s, color .12s;
}
.rate-stars button.hover, .rate-stars button.on { color: var(--turmeric); }
.rate-stars button:active { transform: scale(.88); }
html[lang="hi"] .hud-title small, html[lang="hi"] .end .end-kicker, html[lang="hi"] .end .end-next small, html[lang="hi"] .coach-line { letter-spacing: 0; }
.end .end-goal { font-weight: 800; color: var(--ink); background: var(--turmeric); border-radius: 12px; padding: 8px 12px; }

/* Small phones: keep the title on one line so the stage keeps its height */
@media (max-width: 380px) {
  .hud { gap: 6px; }
  .hud-title b { font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
  .hud-title small { font-size: 11px; }
}

/* Arcade mode (story) inside a game: brief and result modals, the slide-up story card */
.q-modal { text-align: center; }
.q-modal .end-kicker { font-size: 12.5px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--chili); }
.q-face { width: 84px; height: 84px; margin: -4px auto 6px; }
.q-face svg { width: 100%; height: 100%; display: block; }
.q-modal h2 { font: 700 26px/1.15 var(--display); margin: 2px 0 4px; text-wrap: balance; }
.q-stars-line { font-weight: 700; color: var(--ink-soft); font-size: 14.5px; }
.q-says { margin: 10px 0 4px; font-style: italic; color: var(--ink); }
.q-big-stars { font-size: 40px; letter-spacing: 4px; color: #f2a51d; line-height: 1.1; }
.q-reward { font-weight: 800; color: var(--mint); }
.hud-title { cursor: default; }
.q-card {
  position: fixed; z-index: 60; left: max(12px, env(safe-area-inset-left, 0px)); right: max(12px, env(safe-area-inset-right, 0px));
  bottom: calc(12px + env(safe-area-inset-bottom, 0px)); margin-inline: auto; max-width: 440px;
  display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; align-items: center; gap: 10px;
  padding: 10px 34px 10px 10px; border-radius: 18px; background: var(--paper); color: var(--ink);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .3); transform: translateY(140%); transition: transform .3s ease;
}
.q-card.show { transform: none; }
.q-card-face svg { width: 48px; height: 48px; display: block; }
.q-card-text { display: grid; min-width: 0; line-height: 1.25; }
.q-card-text b { font: 700 16px/1.2 var(--display); }
.q-card-text small { font-size: 13px; color: var(--ink-soft); }
.q-card .btn { grid-column: 1 / -1; justify-self: stretch; }
.q-card-x { position: absolute; top: 4px; right: 6px; width: 28px; height: 28px; border: 0; background: none; font-size: 22px; color: var(--ink-soft); }

/* Taste Test: the game runs inside the sampler's frame, which has its own bar */
body.taste .hud .hud-btn, body.taste .hud .hud-right .hud-btn { visibility: hidden; }
.q-paid { font: 800 22px/1.2 var(--display); color: #c98a12; margin-top: 4px; }

/* "Leave the game?" after an accidental back swipe */
.leave-ask { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: 20px; background: rgba(20, 12, 6, .55); }
.leave-card { width: min(340px, 100%); background: #fffaf2; color: #2b1d14; border-radius: 22px; padding: 22px; display: grid; gap: 8px; text-align: center; box-shadow: 0 20px 50px -10px rgba(0, 0, 0, .5); }
.leave-card b { font-size: 20px; }
.leave-card p { margin: 0 0 8px; opacity: .8; }
.leave-card div { display: grid; gap: 10px; }
html, body { overscroll-behavior-x: none; }
