/* ==========================================================================
   style.css — the chrome around the game. Cartoon, chunky, high contrast,
   and out of the way of the town.
   ========================================================================== */

:root {
  --ink: #1b2233;
  --ink-soft: #3d4a63;
  --paper: #fdf7e8;
  --amber: #f0a92c;
  --amber-deep: #d0791a;
  --brick: #c4644d;
  --sky: #9fd8f2;
  --mint: #4ade80;
  --rose: #ff6b6b;
  --shadow: 0 14px 0 rgba(27, 34, 51, 0.22);
  --radius: 22px;
  font-synthesis: none;
}

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

html,
body {
  height: 100%;
  overflow: hidden;
  background: var(--sky);
  color: var(--ink);
  font-family: "Trebuchet MS", "Segoe UI", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  touch-action: none;
  /* A mis-timed tap on a button should not select its label. */
  user-select: none;
  -webkit-user-select: none;
}

#app {
  position: fixed;
  inset: 0;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.hidden {
  display: none !important;
}

/* ---------------------------------------------------------------- overlays */

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: max(18px, env(safe-area-inset-top)) 18px max(18px, env(safe-area-inset-bottom));
  background: radial-gradient(120% 90% at 50% 0%, rgba(159, 216, 242, 0.5), rgba(27, 34, 51, 0.62));
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 20;
}

.loader-card,
.menu-card {
  width: min(560px, 100%);
  max-height: 100%;
  overflow-y: auto;
  text-align: center;
  padding: clamp(22px, 4vw, 38px);
  border-radius: var(--radius);
  background: var(--paper);
  border: 4px solid var(--ink);
  box-shadow: var(--shadow);
}

.logo-mark {
  font-size: clamp(1.9rem, 7vw, 3rem);
  font-weight: 900;
  letter-spacing: 0.06em;
  line-height: 0.95;
  color: var(--ink);
}

.logo-sub {
  font-size: clamp(2.4rem, 11vw, 4.4rem);
  font-weight: 900;
  letter-spacing: 0.02em;
  line-height: 0.95;
  color: var(--amber-deep);
  -webkit-text-stroke: 3px var(--ink);
  paint-order: stroke fill;
  margin-bottom: 0.35em;
}

.kicker {
  font-size: clamp(1.4rem, 6vw, 2.2rem);
  font-weight: 900;
  letter-spacing: 0.04em;
  color: var(--rose);
  -webkit-text-stroke: 2px var(--ink);
  paint-order: stroke fill;
  margin-bottom: 0.4em;
}

.tagline {
  color: var(--ink-soft);
  font-size: clamp(0.95rem, 2.6vw, 1.06rem);
  line-height: 1.5;
  margin: 0 auto 1.1em;
  max-width: 42ch;
}

.controls-line {
  margin-top: 0.9em;
  font-size: 0.88rem;
  color: var(--ink-soft);
}

.rules {
  list-style: none;
  margin: 1.1em auto 0;
  display: grid;
  gap: 8px;
  text-align: left;
  max-width: 34ch;
  font-size: 0.88rem;
  color: var(--ink-soft);
}

.rules li {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chip {
  flex: none;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  border: 2px solid var(--ink);
  font-size: 0.8rem;
  color: var(--ink);
  background: var(--amber);
}
.chip.turn { background: #7dd3fc; }
.chip.big { background: #ffd070; }
.chip.ghost { background: #7dd3fc; }
.chip.arch { background: var(--brick); color: var(--paper); }

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

.btn {
  appearance: none;
  cursor: pointer;
  display: inline-block;
  margin-top: 0.5em;
  padding: 14px 30px;
  font: inherit;
  font-weight: 900;
  font-size: clamp(1rem, 3.4vw, 1.2rem);
  letter-spacing: 0.06em;
  border-radius: 16px;
  border: 4px solid var(--ink);
  color: var(--ink);
  background: var(--amber);
  box-shadow: 0 6px 0 var(--ink);
  transition: transform 0.08s, box-shadow 0.08s;
}

.btn:active {
  transform: translateY(5px);
  box-shadow: 0 1px 0 var(--ink);
}

.btn.primary {
  background: var(--amber);
}

.btn.ghost {
  background: var(--paper);
  margin-left: 8px;
}

.back-link {
  display: block;
  margin-top: 1.1em;
  color: var(--ink-soft);
  font-size: 0.86rem;
  text-decoration: none;
}
.back-link:hover { text-decoration: underline; }

/* -------------------------------------------------------------------- HUD */

#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

.hud-top {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.hud-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.pill {
  display: inline-flex;
  align-items: baseline;
  gap: 7px;
  padding: 7px 14px;
  border-radius: 999px;
  border: 3px solid var(--ink);
  background: var(--paper);
  box-shadow: 0 4px 0 rgba(27, 34, 51, 0.28);
  font-weight: 900;
  font-size: clamp(0.95rem, 3vw, 1.15rem);
  font-variant-numeric: tabular-nums;
}

.pill .cap {
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  font-weight: 900;
  color: var(--ink-soft);
}

.pill.score { background: var(--amber); }
.pill.lives { color: var(--rose); letter-spacing: 0.06em; }

.icon-btn {
  pointer-events: auto;
  cursor: pointer;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  font-size: 1.05rem;
  border-radius: 14px;
  border: 3px solid var(--ink);
  background: var(--paper);
  box-shadow: 0 4px 0 rgba(27, 34, 51, 0.28);
}
.icon-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(27, 34, 51, 0.28); }

.hud-left {
  position: absolute;
  left: 12px;
  bottom: max(12px, env(safe-area-inset-bottom));
  display: grid;
  gap: 8px;
  justify-items: center;
}

#minimap {
  width: clamp(96px, 17vw, 168px);
  aspect-ratio: 28 / 31;
  height: auto;
  border-radius: 14px;
  border: 3px solid var(--ink);
  background: rgba(253, 247, 232, 0.86);
  box-shadow: 0 5px 0 rgba(27, 34, 51, 0.28);
}

.left-count { padding: 4px 12px; font-size: 0.92rem; }

.banner {
  position: absolute;
  left: 50%;
  top: 22%;
  transform: translateX(-50%);
  padding: 12px 28px;
  border-radius: 18px;
  border: 4px solid var(--ink);
  background: var(--paper);
  box-shadow: 0 7px 0 rgba(27, 34, 51, 0.3);
  font-weight: 900;
  font-size: clamp(1.1rem, 5vw, 1.9rem);
  letter-spacing: 0.05em;
  white-space: nowrap;
  animation: pop 0.28s cubic-bezier(0.2, 1.5, 0.4, 1);
}

@keyframes pop {
  from { transform: translateX(-50%) scale(0.6); opacity: 0; }
  to { transform: translateX(-50%) scale(1); opacity: 1; }
}

/* ------------------------------------------------------------- touch pad */

/* Three buttons, not a d-pad: steering is relative, so "north" is not a
   thing you can press. */
.touch-pad {
  position: absolute;
  right: max(14px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  display: flex;
  gap: 10px;
  pointer-events: auto;
  opacity: 0.92;
}

.pad {
  cursor: pointer;
  width: 66px;
  height: 66px;
  display: grid;
  place-content: center;
  gap: 1px;
  border-radius: 18px;
  border: 3px solid var(--ink);
  background: rgba(253, 247, 232, 0.88);
  box-shadow: 0 4px 0 rgba(27, 34, 51, 0.3);
  color: var(--ink);
  font: inherit;
}
.pad span { font-size: 1.6rem; line-height: 1; }
.pad small { font-size: 0.52rem; font-weight: 900; letter-spacing: 0.12em; opacity: 0.65; }
.pad:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(27, 34, 51, 0.3); }

#pad-reverse { background: rgba(240, 169, 44, 0.9); }

/* ------------------------------------------------------------------ misc */

.loader-track {
  width: 100%;
  height: 14px;
  margin: 18px 0 12px;
  border-radius: 999px;
  border: 3px solid var(--ink);
  background: #ede3cc;
  overflow: hidden;
}

#loader-fill {
  height: 100%;
  width: 6%;
  background: linear-gradient(90deg, var(--amber), var(--amber-deep));
  transition: width 0.3s ease;
}

#loading-status {
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.result-scores {
  display: flex;
  justify-content: center;
  gap: clamp(14px, 5vw, 34px);
  margin: 0.6em 0 0.4em;
}

.result-block {
  display: grid;
  gap: 2px;
}

.result-num {
  font-size: clamp(1.5rem, 7vw, 2.3rem);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.result-cap {
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  color: var(--ink-soft);
  font-weight: 900;
}

@media (max-width: 520px) {
  .hud-top .pill:nth-child(2) { display: none; } /* BEST — the map matters more */
  #minimap { width: 92px; }
}

@media (prefers-reduced-motion: reduce) {
  .banner { animation: none; }
  .btn, .icon-btn, .pad { transition: none; }
}
