/* ============================================================
   Pithu Arena - interface styles
   Palette follows the arena art direction: terracotta court,
   sand chalk, teal player, coral defenders, deep indigo panels.
   ============================================================ */

:root {
  --terracotta: #d76a3a;
  --sand: #e9d8a6;
  --teal: #2a9d8f;
  --teal-bright: #3fc4b2;
  --indigo: #264653;
  --indigo-deep: #16303c;
  --yellow: #f4c95d;
  --coral: #e76f51;
  --chalk: #f4f1e8;

  --panel-bg: rgba(20, 44, 56, 0.95);
  --panel-edge: rgba(233, 216, 166, 0.18);
  --panel-edge-strong: rgba(233, 216, 166, 0.34);
  --text: #f4f1e8;
  --text-dim: #a8bcc4;
  --text-faint: #6f8792;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow-panel: 0 24px 70px rgba(0, 0, 0, 0.5);
  --shadow-btn: 0 4px 0 rgba(0, 0, 0, 0.28);

  --font: "Segoe UI", ui-sans-serif, system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);

  --hud-scale: 1;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: #0d1f28;
  overscroll-behavior: none;
  touch-action: none;
}

body {
  font-family: var(--font);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

#game-canvas {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  display: block;
  touch-action: none;
  outline: none;
}

/* ---------------------------------------------------- screens */

.ui-root { position: fixed; inset: 0; pointer-events: none; z-index: 10; }

.screen {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: calc(20px + var(--safe-t)) calc(20px + var(--safe-r)) calc(20px + var(--safe-b)) calc(20px + var(--safe-l));
  opacity: 0;
  visibility: hidden;
  transition: opacity .28s ease, visibility .28s;
  pointer-events: none;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.screen.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* Let the arena read through the menus: the game itself is the best
   advertisement for the game, and a fully opaque scrim wastes it. */
.menu-screen {
  background:
    radial-gradient(ellipse at 50% 0%, rgba(42, 157, 143, .18), transparent 62%),
    linear-gradient(160deg, rgba(13, 31, 40, .62), rgba(9, 22, 29, .78));
  backdrop-filter: blur(3px) saturate(1.05);
  -webkit-backdrop-filter: blur(3px) saturate(1.05);
}

/* The results screen carries more text, so it needs a touch more scrim. */
#results-screen.menu-screen {
  background:
    radial-gradient(ellipse at 50% 0%, rgba(42, 157, 143, .2), transparent 60%),
    linear-gradient(160deg, rgba(13, 31, 40, .8), rgba(9, 22, 29, .9));
}

.overlay-screen { background: rgba(9, 22, 29, .78); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }

/* ---------------------------------------------------- panels */

.menu-panel {
  width: min(460px, 100%);
  background: var(--panel-bg);
  border: 1px solid var(--panel-edge);
  border-radius: var(--radius);
  box-shadow: var(--shadow-panel);
  padding: 30px 28px 24px;
  animation: panel-in .34s cubic-bezier(.2,.9,.3,1.2) both;
  max-height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.menu-panel.wide { width: min(680px, 100%); }
.menu-panel.narrow { width: min(360px, 100%); }

@keyframes panel-in {
  from { opacity: 0; transform: translateY(16px) scale(.97); }
  to   { opacity: 1; transform: none; }
}

/* ---------------------------------------------------- titles */

.game-title {
  font-size: clamp(38px, 9vw, 62px);
  font-weight: 900;
  letter-spacing: .04em;
  line-height: .94;
  text-align: center;
  color: var(--sand);
  text-shadow: 0 3px 0 var(--terracotta), 0 6px 22px rgba(215, 106, 58, .45);
}
.game-title .title-accent { display: block; color: var(--teal-bright); text-shadow: 0 3px 0 var(--indigo-deep); }

.game-tagline {
  text-align: center; margin-top: 12px; margin-bottom: 26px;
  color: var(--text-dim); font-size: 14px; letter-spacing: .02em;
}

.panel-title {
  font-size: 26px; font-weight: 800; letter-spacing: .03em;
  color: var(--sand); margin-bottom: 8px;
}
.panel-lede { color: var(--text-dim); font-size: 14px; line-height: 1.55; margin-bottom: 20px; }

/* ---------------------------------------------------- buttons */

.menu-nav { display: flex; flex-direction: column; gap: 10px; }

.btn {
  font-family: inherit;
  font-size: 15px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--text);
  background: rgba(244, 241, 232, .07);
  border: 1px solid var(--panel-edge);
  border-radius: var(--radius-sm);
  padding: 13px 20px;
  cursor: pointer;
  transition: background .16s ease, transform .12s ease, border-color .16s ease, color .16s ease;
  min-height: 46px;
}
.btn:hover:not(:disabled) { background: rgba(244, 241, 232, .14); border-color: var(--panel-edge-strong); }
.btn:active:not(:disabled) { transform: translateY(2px); }
.btn:disabled { opacity: .45; cursor: default; }
.btn:focus-visible { outline: 2px solid var(--yellow); outline-offset: 2px; }

.btn-primary {
  background: linear-gradient(180deg, var(--teal-bright), var(--teal));
  border-color: transparent; color: #06231f;
  box-shadow: var(--shadow-btn);
}
.btn-primary:hover:not(:disabled) { background: linear-gradient(180deg, #52d8c5, #34b3a3); }
.btn-primary:active:not(:disabled) { box-shadow: 0 1px 0 rgba(0,0,0,.28); }

.btn-ghost { background: transparent; color: var(--text-dim); }
.btn-ghost:hover:not(:disabled) { color: var(--text); }

.btn-small { font-size: 12px; padding: 8px 14px; min-height: 34px; }

.panel-actions { display: flex; gap: 10px; margin-top: 22px; flex-wrap: wrap; }
.panel-actions .btn { flex: 1 1 auto; }
.panel-actions.centred { justify-content: center; }

/* ---------------------------------------------------- menu footer */

.menu-header { margin-bottom: 4px; }
.menu-footer {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 22px; padding-top: 14px;
  border-top: 1px solid rgba(244,241,232,.09);
  font-size: 12px; color: var(--text-faint); letter-spacing: .04em;
}
.menu-highscore { color: var(--yellow); font-weight: 700; }

/* ---------------------------------------------------- how to play */

.howto-steps { list-style: none; display: flex; flex-direction: column; gap: 12px; margin-bottom: 22px; }
.howto-steps li { display: flex; gap: 13px; align-items: flex-start; font-size: 14px; line-height: 1.5; color: var(--text-dim); }
.howto-steps strong { color: var(--text); }
.howto-num {
  flex: 0 0 26px; height: 26px; border-radius: 50%;
  background: var(--terracotta); color: #2a1206;
  display: grid; place-items: center; font-weight: 900; font-size: 13px;
}

.controls-block { border-top: 1px solid rgba(244,241,232,.09); padding-top: 18px; }
.controls-title { font-size: 15px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; color: var(--sand); margin-bottom: 12px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.scheme-badge {
  font-size: 11px; font-weight: 700; letter-spacing: .06em;
  background: var(--teal); color: #06231f; padding: 3px 9px; border-radius: 20px; text-transform: none;
}
.controls-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 7px 18px; }
.controls-list div { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; padding: 5px 0; border-bottom: 1px dashed rgba(244,241,232,.08); }
.controls-list dt { color: var(--text-dim); }
.controls-list dd { color: var(--sand); font-weight: 700; text-align: right; }

/* ---------------------------------------------------- settings */

.settings-group { margin-bottom: 22px; }
.settings-group-title {
  font-size: 12px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase;
  color: var(--teal-bright); margin-bottom: 10px;
}
.setting-row {
  display: grid; grid-template-columns: 1fr 150px 52px;
  align-items: center; gap: 12px;
  padding: 9px 0; border-bottom: 1px solid rgba(244,241,232,.06);
  font-size: 14px; cursor: pointer;
}
.setting-label { color: var(--text-dim); }
.setting-label small { color: var(--text-faint); font-size: 11px; }
.setting-value { color: var(--sand); font-weight: 700; font-size: 13px; text-align: right; font-variant-numeric: tabular-nums; }

.slider { -webkit-appearance: none; appearance: none; width: 100%; height: 5px; border-radius: 3px; background: rgba(244,241,232,.16); outline: none; cursor: pointer; }
.slider::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; background: var(--teal-bright); border: 2px solid var(--indigo-deep); cursor: pointer; }
.slider::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--teal-bright); border: 2px solid var(--indigo-deep); cursor: pointer; }

.toggle-row { grid-template-columns: 1fr 52px; }
.toggle { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-track { position: relative; width: 46px; height: 25px; border-radius: 13px; background: rgba(244,241,232,.16); transition: background .18s ease; justify-self: end; }
.toggle-track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 19px; height: 19px; border-radius: 50%; background: var(--text-dim); transition: transform .18s ease, background .18s ease; }
.toggle:checked + .toggle-track { background: var(--teal); }
.toggle:checked + .toggle-track::after { transform: translateX(21px); background: #fff; }
.toggle:focus-visible + .toggle-track { outline: 2px solid var(--yellow); outline-offset: 2px; }

.select {
  font-family: inherit; font-size: 13px; font-weight: 600;
  background: rgba(244,241,232,.08); color: var(--text);
  border: 1px solid var(--panel-edge); border-radius: var(--radius-sm);
  padding: 8px 10px; cursor: pointer; grid-column: 2 / span 2;
}
.select option { background: var(--indigo-deep); color: var(--text); }

/* ---------------------------------------------------- credits */

.credits-body { text-align: center; }
.credits-role { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--text-faint); }
.credits-name { font-size: 26px; font-weight: 800; color: var(--sand); margin: 5px 0 16px; }
.credits-rule { border: none; border-top: 1px solid rgba(244,241,232,.1); margin: 16px 0; }
.credits-note { font-size: 13px; line-height: 1.6; color: var(--text-dim); margin-bottom: 12px; }

/* ============================================================
   HUD
   ============================================================ */

.hud {
  position: absolute; inset: 0;
  pointer-events: none;
  opacity: 0; visibility: hidden;
  transition: opacity .3s ease, visibility .3s;
  font-size: calc(16px * var(--hud-scale));
}
.hud.is-visible { opacity: 1; visibility: visible; }

.hud-top {
  position: absolute; top: calc(14px + var(--safe-t)); left: calc(16px + var(--safe-l)); right: calc(16px + var(--safe-r));
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
}

.hud-left { display: flex; flex-direction: column; gap: 9px; align-items: flex-start; }

/* health: icon + colour, never colour alone */
.hud-health { display: flex; gap: 6px; }
.heart {
  width: 26px; height: 26px; border-radius: 6px;
  background: var(--coral);
  border: 2px solid rgba(0,0,0,.28);
  display: grid; place-items: center;
  font-size: 13px; font-weight: 900; color: #fff;
  transition: background .2s ease, transform .2s ease, opacity .2s ease;
  box-shadow: 0 2px 6px rgba(0,0,0,.3);
}
.heart::after { content: "\2665"; }
.heart.is-lost { background: rgba(20,40,50,.55); color: transparent; opacity: .5; transform: scale(.85); }
.heart.is-lost::after { content: "\00D7"; color: rgba(244,241,232,.5); }
@keyframes heart-pop { 0% { transform: scale(1); } 45% { transform: scale(1.35); } 100% { transform: scale(.85); } }
.heart.just-lost { animation: heart-pop .34s ease both; }

.hud-stones {
  display: flex; align-items: center; gap: 7px;
  background: rgba(13,31,40,.72); border: 1px solid var(--panel-edge);
  padding: 5px 11px; border-radius: 20px;
  font-size: 14px; font-weight: 800; letter-spacing: .04em;
  color: var(--sand);
}
.hud-stones-icon { width: 15px; height: 11px; border-radius: 2px; background: linear-gradient(180deg, var(--yellow) 0 34%, var(--terracotta) 34% 67%, var(--sand) 67%); }

.hud-centre { text-align: center; }
.hud-timer {
  font-size: 34px; font-weight: 900; letter-spacing: .02em;
  color: var(--sand); font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 10px rgba(0,0,0,.6);
  transition: color .2s ease;
}
.hud-timer.is-urgent { color: var(--coral); animation: pulse-urgent 1s ease-in-out infinite; }
@keyframes pulse-urgent { 0%,100% { transform: scale(1); } 50% { transform: scale(1.07); } }
.hud-timer-label { font-size: 10px; letter-spacing: .22em; color: var(--text-faint); font-weight: 700; }

.hud-right { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.hud-score { font-size: 26px; font-weight: 900; color: var(--yellow); font-variant-numeric: tabular-nums; text-shadow: 0 2px 8px rgba(0,0,0,.5); }
.hud-score-label { font-size: 10px; letter-spacing: .18em; color: var(--text-faint); font-weight: 700; }
.hud-best { color: var(--text-dim); letter-spacing: .04em; }
.hud-pause-btn {
  margin-top: 7px; pointer-events: auto; cursor: pointer;
  background: rgba(13,31,40,.72); border: 1px solid var(--panel-edge); color: var(--text-dim);
  border-radius: 8px; width: 36px; height: 30px; font-size: 11px; letter-spacing: 2px;
}
.hud-pause-btn:hover { color: var(--text); border-color: var(--panel-edge-strong); }

/* objective banner */
.hud-objective-wrap { position: absolute; top: calc(86px + var(--safe-t)); left: 0; right: 0; display: flex; justify-content: center; }
.hud-objective {
  background: rgba(13,31,40,.8); border: 1px solid var(--panel-edge-strong);
  border-left: 4px solid var(--yellow);
  padding: 8px 20px; border-radius: 6px;
  font-size: 15px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase;
  color: var(--sand); white-space: nowrap;
  opacity: 0; transform: translateY(-10px);
  transition: opacity .3s ease, transform .3s ease;
}
.hud-objective.is-visible { opacity: 1; transform: none; }
.hud-objective.is-changing { animation: objective-pop .5s cubic-bezier(.2,.9,.3,1.3) both; }
@keyframes objective-pop { 0% { transform: scale(.85); opacity: 0; } 55% { transform: scale(1.06); opacity: 1; } 100% { transform: scale(1); } }

/* centre overlay */
.hud-centre-overlay { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }

.hud-countdown {
  position: absolute;
  font-size: clamp(80px, 18vw, 150px); font-weight: 900; color: var(--sand);
  text-shadow: 0 6px 0 var(--terracotta), 0 12px 40px rgba(0,0,0,.6);
  opacity: 0;
}
.hud-countdown.is-active { animation: countdown-beat .9s cubic-bezier(.2,.8,.3,1) both; }
@keyframes countdown-beat {
  0% { opacity: 0; transform: scale(1.9); }
  22% { opacity: 1; transform: scale(1); }
  78% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(.8); }
}

.hud-reticle { position: absolute; opacity: 0; transition: opacity .18s ease; }
.hud-reticle.is-visible { opacity: 1; }
.hud-reticle span {
  display: block; width: 26px; height: 26px;
  border: 2px solid rgba(244,241,232,.85); border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(0,0,0,.35), inset 0 0 0 1px rgba(0,0,0,.25);
  position: relative;
}
.hud-reticle span::after {
  content: ""; position: absolute; top: 50%; left: 50%;
  width: 3px; height: 3px; margin: -1.5px 0 0 -1.5px;
  background: var(--yellow); border-radius: 50%;
}

.hud-callout {
  position: absolute;
  font-size: clamp(38px, 9vw, 72px); font-weight: 900; letter-spacing: .05em;
  color: var(--yellow); text-shadow: 0 5px 0 var(--terracotta), 0 10px 34px rgba(0,0,0,.6);
  opacity: 0; pointer-events: none;
}
.hud-callout.is-active { animation: callout-burst 1.5s cubic-bezier(.16,.9,.3,1) both; }
@keyframes callout-burst {
  0% { opacity: 0; transform: scale(.4) rotate(-6deg); }
  18% { opacity: 1; transform: scale(1.12) rotate(2deg); }
  32% { transform: scale(1) rotate(0); }
  76% { opacity: 1; }
  100% { opacity: 0; transform: scale(1.06) translateY(-22px); }
}

/* bottom row */
.hud-bottom {
  position: absolute; bottom: calc(18px + var(--safe-b)); left: calc(16px + var(--safe-l)); right: calc(16px + var(--safe-r));
  display: flex; justify-content: space-between; align-items: flex-end; gap: 12px;
}
.hud-prompt {
  background: rgba(13,31,40,.82); border: 1px solid var(--panel-edge-strong);
  padding: 8px 15px; border-radius: 8px;
  font-size: 13px; font-weight: 600; color: var(--text);
  opacity: 0; transform: translateY(8px);
  transition: opacity .18s ease, transform .18s ease;
  max-width: 60vw;
}
.hud-prompt.is-visible { opacity: 1; transform: none; }
.hud-prompt b { color: var(--yellow); font-weight: 900; padding: 1px 6px; border-radius: 4px; background: rgba(244,201,93,.14); margin: 0 2px; }

.hud-bottom-right { display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }

.hud-carry {
  display: flex; align-items: center; gap: 9px;
  background: rgba(13,31,40,.78); border: 1px solid var(--panel-edge);
  padding: 6px 12px; border-radius: 8px;
  opacity: 0; transform: translateX(10px);
  transition: opacity .2s ease, transform .2s ease;
}
.hud-carry.is-visible { opacity: 1; transform: none; }
.hud-carry-label { font-size: 9px; letter-spacing: .16em; color: var(--text-faint); font-weight: 700; }
.hud-carry-num {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--yellow); color: #3a2408;
  display: grid; place-items: center; font-weight: 900; font-size: 14px;
}

.hud-dodge { display: flex; align-items: center; gap: 8px; opacity: .95; }
.hud-dodge-label { font-size: 9px; letter-spacing: .16em; color: var(--text-faint); font-weight: 700; }
.hud-dodge-bar { width: 74px; height: 5px; border-radius: 3px; background: rgba(13,31,40,.8); border: 1px solid var(--panel-edge); overflow: hidden; }
.hud-dodge-fill { height: 100%; width: 100%; background: var(--teal-bright); transition: width .06s linear, background .2s ease; }
.hud-dodge-fill.is-ready { background: var(--teal-bright); }
.hud-dodge-fill.is-cooling { background: var(--text-faint); }

/* throw charge */
.hud-charge {
  position: absolute; bottom: calc(78px + var(--safe-b)); left: 50%; transform: translateX(-50%) translateY(10px);
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  opacity: 0; transition: opacity .15s ease, transform .15s ease;
}
.hud-charge.is-visible { opacity: 1; transform: translateX(-50%); }
.hud-charge-track { width: 168px; height: 9px; border-radius: 5px; background: rgba(13,31,40,.85); border: 1px solid var(--panel-edge-strong); overflow: hidden; }
.hud-charge-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--teal), var(--yellow) 65%, var(--coral)); transition: width .05s linear; }
.hud-charge-label { font-size: 9px; letter-spacing: .2em; color: var(--text-dim); font-weight: 700; }

/* damage flash */
.hud-damage-flash { position: absolute; inset: 0; pointer-events: none; opacity: 0; box-shadow: inset 0 0 130px 30px rgba(231,111,81,.85); }
.hud-damage-flash.is-active { animation: dmg-flash .45s ease-out both; }
@keyframes dmg-flash { 0% { opacity: 0; } 12% { opacity: 1; } 100% { opacity: 0; } }

/* replay banner */
.hud-replay-banner {
  position: absolute; top: calc(20px + var(--safe-t)); left: 50%; transform: translateX(-50%) translateY(-14px);
  display: flex; align-items: center; gap: 10px;
  background: rgba(9,22,29,.9); border: 1px solid var(--coral);
  padding: 9px 18px; border-radius: 30px;
  font-size: 13px; font-weight: 900; letter-spacing: .18em; color: var(--sand);
  opacity: 0; transition: opacity .3s ease, transform .3s ease;
}
.hud-replay-banner.is-visible { opacity: 1; transform: translateX(-50%); }
.replay-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--coral); animation: rec-blink 1s steps(1) infinite; }
@keyframes rec-blink { 0%,50% { opacity: 1; } 51%,100% { opacity: .18; } }
.replay-skip { font-size: 10px; font-weight: 600; letter-spacing: .04em; color: var(--text-faint); }
.replay-skip b { color: var(--sand); }

/* ============================================================
   Touch controls
   ============================================================ */

.touch-controls { position: absolute; inset: 0; pointer-events: none; opacity: 0; visibility: hidden; transition: opacity .25s ease, visibility .25s; }
.touch-controls.is-visible { opacity: 1; visibility: visible; }

.touch-stick {
  position: absolute;
  left: calc(22px + var(--safe-l)); bottom: calc(22px + var(--safe-b));
  width: 132px; height: 132px;
  pointer-events: auto; touch-action: none;
}
.touch-stick-base {
  width: 100%; height: 100%; border-radius: 50%;
  background: rgba(13,31,40,.34); border: 2px solid rgba(244,241,232,.22);
  display: grid; place-items: center;
  transition: opacity .3s ease, background .2s ease;
  opacity: .55;
}
.touch-stick.is-active .touch-stick-base { opacity: 1; background: rgba(13,31,40,.5); }
.touch-stick-knob {
  width: 54px; height: 54px; border-radius: 50%;
  background: rgba(42,157,143,.75); border: 2px solid rgba(244,241,232,.55);
  will-change: transform;
}

.touch-look { position: absolute; right: 0; top: 0; width: 50%; height: 74%; pointer-events: auto; touch-action: none; }

.touch-buttons {
  position: absolute; right: calc(20px + var(--safe-r)); bottom: calc(20px + var(--safe-b));
  display: grid; grid-template-columns: repeat(3, auto); gap: 10px;
  justify-items: end; align-items: end;
  pointer-events: none;
}
.touch-btn {
  pointer-events: auto; touch-action: none;
  width: 74px; height: 74px; border-radius: 50%;
  background: rgba(13,31,40,.5); border: 2px solid rgba(244,241,232,.26);
  color: var(--text); font-family: inherit; font-size: 11px; font-weight: 800; letter-spacing: .06em;
  opacity: .62; transition: opacity .2s ease, transform .1s ease, background .15s ease;
  cursor: pointer;
}
.touch-btn:active, .touch-btn.is-down { opacity: 1; transform: scale(.92); background: rgba(42,157,143,.55); }
.touch-btn.is-relevant { opacity: 1; border-color: var(--yellow); }
.touch-btn-small { width: 58px; height: 58px; font-size: 10px; }
.touch-btn-primary { background: rgba(231,111,81,.55); border-color: rgba(244,201,93,.45); width: 88px; height: 88px; font-size: 12px; }
.touch-btn-accent { background: rgba(244,201,93,.4); }
.touch-btn[hidden] { display: none; }

/* Top-centre is the timer's, so the touch pause sits under the score on the
   right where a thumb can reach it. */
.touch-pause {
  position: absolute;
  top: calc(58px + var(--safe-t)); right: calc(16px + var(--safe-r));
  pointer-events: auto;
  width: 46px; height: 38px; border-radius: 9px;
  background: rgba(13,31,40,.6); border: 1px solid rgba(244,241,232,.26);
  color: var(--text); font-size: 12px; letter-spacing: 2px; opacity: .8; cursor: pointer;
}
.touch-pause:active { opacity: 1; transform: scale(.94); }

/* The touch overlay carries its own, larger pause control. */
.touch-controls.is-visible ~ * .hud-pause-btn,
body.touch-active .hud-pause-btn { display: none; }

/* ============================================================
   Results
   ============================================================ */

.results-head { text-align: center; margin-bottom: 18px; }
.results-title {
  font-size: clamp(32px, 7vw, 46px); font-weight: 900; letter-spacing: .05em;
  text-shadow: 0 3px 0 rgba(0,0,0,.3);
}
.results-title.is-victory { color: var(--yellow); text-shadow: 0 3px 0 var(--terracotta); }
.results-title.is-defeat { color: var(--coral); }
.results-reason { color: var(--text-dim); font-size: 14px; margin-top: 5px; }

.results-score-wrap { text-align: center; padding: 16px 0 20px; border-top: 1px solid rgba(244,241,232,.09); border-bottom: 1px solid rgba(244,241,232,.09); }
.results-score-label { font-size: 10px; letter-spacing: .22em; color: var(--text-faint); font-weight: 700; }
.results-score { font-size: clamp(44px, 11vw, 68px); font-weight: 900; color: var(--sand); font-variant-numeric: tabular-nums; line-height: 1.05; }
.results-highscore-badge {
  display: none; margin: 6px auto 0; width: fit-content;
  background: var(--yellow); color: #3a2408;
  font-size: 11px; font-weight: 900; letter-spacing: .14em;
  padding: 4px 13px; border-radius: 20px;
  animation: badge-pop .5s cubic-bezier(.2,.9,.3,1.4) both;
}
.results-highscore-badge.is-visible { display: block; }
@keyframes badge-pop { 0% { transform: scale(0) rotate(-8deg); } 60% { transform: scale(1.15) rotate(3deg); } 100% { transform: scale(1); } }
.results-best { font-size: 12px; color: var(--text-faint); margin-top: 8px; letter-spacing: .04em; }

.results-stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 2px 20px; margin: 18px 0 4px;
}
.results-stats div { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px dashed rgba(244,241,232,.08); font-size: 13px; }
.results-stats dt { color: var(--text-dim); }
.results-stats dd { color: var(--sand); font-weight: 800; font-variant-numeric: tabular-nums; }

/* ============================================================
   Boot screen
   ============================================================ */

.boot-screen {
  z-index: 100;
  background: linear-gradient(165deg, #1b3b48, #0b1d25 70%);
  pointer-events: auto;
  transition: opacity .5s ease, visibility .5s;
}
.boot-inner { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 20px; padding: 20px; }

.boot-logo { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.boot-logo-mark { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.boot-logo-mark .stone { display: block; border-radius: 3px; animation: stone-stack 2.4s ease-in-out infinite; }
.boot-logo-mark .s1 { width: 62px; height: 12px; background: var(--sand); animation-delay: 0s; }
.boot-logo-mark .s2 { width: 46px; height: 11px; background: var(--terracotta); animation-delay: .18s; }
.boot-logo-mark .s3 { width: 32px; height: 10px; background: var(--yellow); animation-delay: .36s; }
@keyframes stone-stack { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }

.boot-title { font-size: clamp(30px, 8vw, 46px); font-weight: 900; letter-spacing: .07em; color: var(--sand); line-height: .95; }
.boot-title span { display: block; color: var(--teal-bright); }

.boot-bar { width: min(280px, 70vw); height: 5px; border-radius: 3px; background: rgba(244,241,232,.12); overflow: hidden; }
.boot-bar-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--teal), var(--yellow)); transition: width .3s ease; }
.boot-status { font-size: 12px; letter-spacing: .12em; color: var(--text-faint); text-transform: uppercase; min-height: 16px; }
.boot-play { min-width: 210px; animation: panel-in .4s cubic-bezier(.2,.9,.3,1.3) both; }
.boot-error { color: var(--coral); font-size: 13px; max-width: 420px; line-height: 1.55; }
.boot-credit { position: absolute; bottom: calc(20px + var(--safe-b)); font-size: 11px; letter-spacing: .14em; color: var(--text-faint); text-transform: uppercase; }

/* ============================================================
   Rotate hint & misc
   ============================================================ */

.rotate-hint {
  position: absolute; inset: 0; z-index: 60;
  display: none; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  background: rgba(9,22,29,.96); text-align: center; padding: 30px;
  pointer-events: auto;
}
.rotate-hint.is-visible { display: flex; }
.rotate-hint p { color: var(--text-dim); font-size: 15px; max-width: 280px; line-height: 1.5; }
.rotate-icon {
  width: 46px; height: 72px; border: 3px solid var(--sand); border-radius: 8px;
  animation: rotate-nudge 2s ease-in-out infinite;
}
@keyframes rotate-nudge { 0%,40% { transform: rotate(0); } 60%,100% { transform: rotate(-90deg); } }

.noscript-msg { position: fixed; inset: 0; display: grid; place-content: center; text-align: center; gap: 12px; background: #0d1f28; color: #f4f1e8; font-family: var(--font); z-index: 999; }

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 720px) {
  :root { --hud-scale: .88; }
  .menu-panel { padding: 24px 20px 20px; }
  .setting-row { grid-template-columns: 1fr 110px 44px; font-size: 13px; }
  .toggle-row { grid-template-columns: 1fr 46px; }
  .hud-timer { font-size: 27px; }
  .hud-score { font-size: 21px; }
  .controls-list { grid-template-columns: 1fr; }
  .results-stats { grid-template-columns: 1fr; }
}

/* Landscape phones: the arena needs the vertical space, so compress the HUD. */
@media (max-height: 480px) and (orientation: landscape) {
  :root { --hud-scale: .78; }
  .menu-panel { padding: 18px 20px 16px; max-height: 94vh; }
  .game-title { font-size: clamp(26px, 6vh, 38px); }
  .game-tagline { margin-bottom: 14px; font-size: 12px; }
  .btn { padding: 9px 16px; min-height: 38px; font-size: 13px; }
  .menu-nav { gap: 7px; }
  .hud-objective-wrap { top: calc(62px + var(--safe-t)); }
  .hud-objective { font-size: 12px; padding: 5px 14px; }
  .touch-stick { width: 108px; height: 108px; }
  .touch-stick-knob { width: 46px; height: 46px; }
  .touch-btn { width: 60px; height: 60px; font-size: 10px; }
  .touch-btn-primary { width: 72px; height: 72px; }
  .touch-btn-small { width: 48px; height: 48px; font-size: 9px; }
  .howto-steps { gap: 7px; }
  .howto-steps li { font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
