/* =========================================================
   TUPIDLY — global styles
   Tokens, shell, HUD, buttons, cards, toasts, overlays.
   ========================================================= */

:root {
  --bg:        #0e0e14;
  --bg-2:      #15151f;
  --surface:   #1b1b27;
  --surface-2: #23232f;
  --line:      #32323f;
  --ink:       #f4f2ff;
  --ink-dim:   #a6a3bd;

  --lime:  #d6ff3f;
  --pink:  #ff5fa2;
  --cyan:  #5fe3ff;
  --gold:  #ffd23f;
  --red:   #ff6a5e;
  --grape: #a98bff;

  --accent: var(--lime);
  --accent-ink: #11110a;

  --r-sm: 10px;
  --r:    16px;
  --r-lg: 24px;

  --pad: clamp(16px, 4vw, 32px);
  --shadow-soft: 0 18px 40px -20px rgba(0,0,0,.9);

  --font: "Trebuchet MS", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Arial Black", "Segoe UI Black", "Trebuchet MS", system-ui, sans-serif;

  --hud-h: 60px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(1100px 600px at 12% -10%, #1e1b33 0%, transparent 60%),
    radial-gradient(900px 500px at 100% 0%, #241a2b 0%, transparent 55%),
    var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.5;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

img, svg { max-width: 100%; }

a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 {
  font-family: var(--font-display);
  line-height: 1.02;
  letter-spacing: -0.02em;
  margin: 0 0 .4em;
  text-transform: uppercase;
}

p { margin: 0 0 1em; }

button { font: inherit; color: inherit; }

/* ---------- a11y helpers ---------- */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: 8px; top: -60px; z-index: 200;
  background: var(--accent); color: var(--accent-ink);
  padding: 10px 16px; border-radius: 0 0 var(--r-sm) var(--r-sm);
  font-weight: bold;
}
.skip-link:focus { top: 0; }

:focus-visible {
  outline: 3px solid var(--cyan);
  outline-offset: 3px;
}

/* =========================================================
   HUD
   ========================================================= */
.hud {
  position: sticky; top: 0; z-index: 60;
  background: rgba(14,14,20,.86);
  backdrop-filter: blur(10px);
  border-bottom: 2px solid var(--line);
}

.hud-inner {
  max-width: 1120px;
  margin: 0 auto;
  min-height: var(--hud-h);
  padding: 8px var(--pad);
  display: flex; align-items: center; gap: 12px;
  justify-content: space-between;
}

.brand {
  display: flex; align-items: center; gap: 10px;
  color: var(--ink); text-decoration: none;
  min-width: 0;
  min-height: 44px;              /* hit area, not visual size */
}
.brand:hover { text-decoration: none; }
.brand:hover .brand-mark { transform: rotate(-12deg) scale(1.12); }

.brand-mark {
  font-size: 26px; line-height: 1;
  transition: transform .18s ease;
}

.brand-text {
  display: flex; flex-direction: column;
  font-family: var(--font-display);
  font-size: 12px; line-height: 1.08;
  letter-spacing: .02em;
  text-transform: uppercase;
  white-space: nowrap;
}
.brand-text i { font-style: normal; color: var(--accent); }

.hud-stats { display: flex; align-items: center; gap: 8px; }

/* The HUD stats are links to the profile, so they carry a full
   touch target. The 60px HUD absorbs it without looking chunkier. */
.stat {
  display: flex; align-items: center; gap: 7px;
  min-height: 44px;
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  color: var(--ink); text-decoration: none;
  font-weight: bold; font-size: 14px;
  white-space: nowrap;
}
.stat:hover { text-decoration: none; border-color: var(--accent); }

.stat-ico { font-size: 15px; }
.stat-lv { font-size: 12px; letter-spacing: .04em; color: var(--ink-dim); }
.stat-lv b { color: var(--ink); font-size: 14px; }

.stat.pop { animation: pop .38s ease; }
@keyframes pop {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.18); border-color: var(--gold); }
  100% { transform: scale(1); }
}

.meter {
  display: block;
  background: #0c0c12;
  border: 2px solid var(--line);
  border-radius: 999px;
  height: 14px; width: 100%;
  overflow: hidden;
}
.meter-sm { width: 64px; height: 10px; border-width: 1px; }
.meter-fill {
  display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, var(--cyan), var(--lime));
  border-radius: 999px;
  transition: width .45s cubic-bezier(.2,.9,.2,1);
}
.meter-fill.danger { background: linear-gradient(90deg, var(--gold), var(--red)); }

.icon-btn {
  display: grid; place-items: center;
  width: 40px; height: 40px;
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: 12px;
  cursor: pointer; font-size: 17px;
  transition: transform .12s ease, border-color .12s ease;
}
.icon-btn:hover { border-color: var(--accent); }
.icon-btn:active { transform: scale(.92); }

/* =========================================================
   LAYOUT
   ========================================================= */
.app {
  flex: 1 0 auto;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: var(--pad) var(--pad) 40px;
}
.app:focus { outline: none; }

.site-foot {
  border-top: 2px solid var(--line);
  padding: 22px var(--pad) 34px;
  text-align: center;
  color: var(--ink-dim);
  font-size: 13px;
}
.site-foot p { margin: 0 0 6px; }
.foot-links { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
/* Padding grows the tap area; the text stays the same size. */
.foot-links a {
  color: var(--ink-dim);
  display: inline-flex; align-items: center;
  min-height: 44px; padding: 0 4px;
}

/* Reserved slot for future between-games promos. Renders nothing today. */
.promo-slot { display: none; }

/* =========================================================
   BUTTONS
   ========================================================= */
.btn {
  --btn-bg: var(--surface-2);
  --btn-ink: var(--ink);
  display: inline-flex; align-items: center; justify-content: center;
  gap: 10px;
  min-height: 52px;
  padding: 12px 22px;
  background: var(--btn-bg);
  color: var(--btn-ink);
  border: 2px solid var(--line);
  border-radius: var(--r);
  box-shadow: 0 5px 0 rgba(0,0,0,.45);
  font-family: var(--font-display);
  font-size: 15px;
  letter-spacing: .04em;
  text-transform: uppercase;
  text-align: center;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform .1s ease, box-shadow .1s ease, background .15s ease, border-color .15s ease;
}
.btn:hover { text-decoration: none; border-color: var(--accent); }
.btn:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 rgba(0,0,0,.45);
}
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

.btn-primary {
  --btn-bg: var(--accent);
  --btn-ink: var(--accent-ink);
  border-color: transparent;
}
.btn-primary:hover { filter: brightness(1.07); border-color: transparent; }

.btn-ghost {
  --btn-bg: transparent;
  box-shadow: none;
}
.btn-ghost:active { transform: translateY(2px); box-shadow: none; }

.btn-block { width: 100%; }
.btn-lg { min-height: 64px; font-size: 19px; padding: 16px 28px; }
/* 44px, not 40 — these are real in-game controls (snail upgrades,
   scene answers, the button's escape hatch), not decorative chrome,
   and 44 is the smallest comfortable touch target. */
.btn-sm { min-height: 44px; font-size: 12px; padding: 8px 14px; border-radius: var(--r-sm); }

.btn-row { display: flex; flex-wrap: wrap; gap: 12px; }
.btn-row .btn { flex: 1 1 190px; }

/* =========================================================
   CARDS / PANELS
   ========================================================= */
.panel {
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--r-lg);
  padding: clamp(16px, 3vw, 26px);
}

/* A pill used as a link is navigation (the "back to the games" chips on
   the profile, trophy and collection pages) and needs a real target.
   Decorative pills — stat and reward badges — stay compact. */
a.pill {
  min-height: 44px;
  padding: 4px 16px;
}

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface-2);
  border: 2px solid var(--line);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 12px; font-weight: bold;
  letter-spacing: .05em; text-transform: uppercase;
  color: var(--ink-dim);
}
.pill-accent { border-color: var(--accent); color: var(--accent); }
.pill-gold { border-color: var(--gold); color: var(--gold); }

.section-head {
  display: flex; align-items: baseline; gap: 12px;
  flex-wrap: wrap;
  margin: 34px 0 16px;
}
.section-head h2 { font-size: clamp(20px, 3.4vw, 28px); margin: 0; }
.section-head p { margin: 0; color: var(--ink-dim); font-size: 14px; }

/* =========================================================
   TOASTS
   ========================================================= */
.toast-stack {
  position: fixed;
  left: 50%; bottom: 18px;
  transform: translateX(-50%);
  z-index: 120;
  display: flex; flex-direction: column-reverse; gap: 8px;
  width: min(440px, calc(100vw - 24px));
  pointer-events: none;
}

.toast {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface-2);
  border: 2px solid var(--line);
  border-left-width: 8px;
  border-left-color: var(--accent);
  border-radius: var(--r);
  padding: 10px 14px;
  box-shadow: var(--shadow-soft);
  font-weight: bold; font-size: 14px;
  animation: toast-in .28s cubic-bezier(.2,1.2,.3,1);
}
.toast.out { animation: toast-out .22s ease forwards; }
.toast-ico { font-size: 20px; line-height: 1; }
.toast-body { min-width: 0; }
.toast-body small {
  display: block; font-weight: normal;
  color: var(--ink-dim); font-size: 12px;
}
.toast-coin   { border-left-color: var(--gold); }
.toast-trophy { border-left-color: var(--pink); }
.toast-level  { border-left-color: var(--cyan); }
.toast-rare   { border-left-color: var(--grape); }

@keyframes toast-in  { from { opacity: 0; transform: translateY(14px) scale(.96); } }
@keyframes toast-out { to   { opacity: 0; transform: translateY(8px) scale(.98); } }

/* =========================================================
   OVERLAY (game over, dialogs)
   ========================================================= */
.overlay-root:empty { display: none; }

.overlay {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center;
  padding: 18px;
  background: rgba(6,6,10,.78);
  backdrop-filter: blur(6px);
  animation: fade-in .2s ease;
}

.overlay-card {
  width: min(520px, 100%);
  max-height: calc(100vh - 36px);
  overflow: auto;
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-soft);
  padding: clamp(20px, 4vw, 30px);
  text-align: center;
  animation: card-in .32s cubic-bezier(.2,1.1,.25,1);
}

@keyframes fade-in { from { opacity: 0; } }
@keyframes card-in { from { opacity: 0; transform: translateY(18px) scale(.95); } }

.result-kicker {
  font-size: 12px; letter-spacing: .18em; text-transform: uppercase;
  color: var(--ink-dim); margin: 0 0 10px;
}
.result-score {
  font-family: var(--font-display);
  font-size: clamp(48px, 14vw, 74px);
  line-height: .95;
  margin: 0;
  color: var(--accent);
}
.result-score small {
  display: block;
  font-family: var(--font);
  font-size: 13px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink-dim); margin-top: 8px;
}
.result-title {
  font-size: clamp(19px, 4.4vw, 25px);
  margin: 18px 0 6px;
}
.result-msg { color: var(--ink-dim); margin: 0 0 4px; }

.result-rewards {
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: center;
  margin: 18px 0 22px;
}

.record-badge {
  display: inline-block;
  background: var(--gold); color: #201800;
  font-family: var(--font-display); font-size: 13px;
  letter-spacing: .08em;
  padding: 5px 14px; border-radius: 999px;
  margin-bottom: 14px;
  transform: rotate(-2deg);
}

.overlay-foot { margin: 16px 0 0; font-size: 13px; }
.overlay-foot a {
  display: inline-flex; align-items: center;
  min-height: 44px; padding: 0 10px;
}

/* =========================================================
   EMPTY / MISC
   ========================================================= */
.empty { text-align: center; color: var(--ink-dim); padding: 40px 10px; }
.nowrap { white-space: nowrap; }
.center { text-align: center; }

/* =========================================================
   MOTION PREFERENCES
   ========================================================= */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
body.no-motion *, body.no-motion *::before, body.no-motion *::after {
  animation-duration: .01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: .01ms !important;
}

/* =========================================================
   SMALL SCREENS
   ========================================================= */
@media (max-width: 560px) {
  body { font-size: 16px; }
  .brand-text { font-size: 10px; }
  .stat { padding: 6px 10px; font-size: 13px; }
  .btn-row .btn { flex: 1 1 100%; }
}
@media (max-width: 380px) {
  .brand-text { display: none; }
}
