/* =====================================================================
   MENU THEME: every look-and-layout setting for the main menu lives here.
   Based on the reference pictures in /reference (chunky outlined buttons,
   raised "lip", top highlight, heavy rounded font with a dark outline),
   with the green buttons turned BLACK.
   ===================================================================== */
:root {
  --font: "Fredoka", "Trebuchet MS", system-ui, sans-serif;
  --btn-top: #3b3f47;          /* black button gradient, top    */
  --btn-mid: #1e2025;          /*                        middle */
  --btn-bot: #121316;          /*                        bottom */
  --btn-hover-top: #565b65;    /* hover: lighter black / dark grey */
  --btn-hover-bot: #26292f;
  --btn-outline: #000000;      /* thick outline around everything */
  --btn-lip: #050506;          /* raised 3D lip under each button */
  --btn-lip-size: 6px;
  --btn-border: 3px;
  --btn-radius: 14px;          /* corner rounding on buttons */
  --tile-radius: 16px;         /* square tile buttons */
  --pill-radius: 999px;        /* pill buttons / bars */
  --gap: 10px;                 /* spacing between buttons */
  --text: #ffffff;
  --text-stroke: 3px;          /* dark outline around white text */
  --stat: #ffd84a;             /* yellow stat text like the reference */
  --panel: rgba(46, 51, 61, 0.92);
  --panel-row: rgba(84, 92, 108, 0.85);
  --panel-radius: 20px;
  --selected-ring: #ffffff;    /* selected tab / choice */
  --title-size: clamp(42px, 7vw, 92px);
  --menu-width: 400px;
}

@font-face { font-display: swap; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #9cc4e8; }
body { font-family: var(--font); color: var(--text); -webkit-tap-highlight-color: transparent; user-select: none; }

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

/* outlined chunky text (white with a dark stroke, like the reference) */
.outlined, .btn, .tile, .pill, .title, .track-name, .tab, .panel h2 {
  color: var(--text);
  -webkit-text-stroke: var(--text-stroke) #000;
  paint-order: stroke fill;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.55);
}

/* ------------------------------------------------------------------ title */
.title {
  position: fixed; top: max(14px, env(safe-area-inset-top)); left: 0; right: 0; z-index: 5;
  text-align: center; font-weight: 700; font-size: var(--title-size); line-height: 1;
  letter-spacing: 0.02em; -webkit-text-stroke: 7px #000; pointer-events: none;
  text-shadow: 0 7px 0 rgba(0, 0, 0, 0.55);
  transition: transform 0.5s ease, opacity 0.5s ease;
}
.title small { display: block; font-size: 0.26em; letter-spacing: 0.18em; -webkit-text-stroke: 4px #000; margin-top: 6px; }

/* ------------------------------------------------------------------ black buttons */
.btn, .tile, .pill, .tab, .choice {
  font-family: var(--font); font-weight: 700; cursor: pointer; border: var(--btn-border) solid var(--btn-outline);
  background: linear-gradient(180deg, var(--btn-top) 0%, var(--btn-mid) 52%, var(--btn-bot) 100%);
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, 0.16), inset 0 -3px 0 rgba(0, 0, 0, 0.35),
              0 var(--btn-lip-size) 0 var(--btn-lip), 0 calc(var(--btn-lip-size) + 4px) 12px rgba(0, 0, 0, 0.35);
  transition: transform 0.08s ease, box-shadow 0.08s ease, filter 0.15s ease, background 0.15s ease;
  position: relative;
}
.btn:hover, .tile:hover, .pill:hover, .tab:hover, .choice:hover {
  background: linear-gradient(180deg, var(--btn-hover-top) 0%, #34373e 52%, var(--btn-hover-bot) 100%);
}
.btn:active, .tile:active, .pill:active, .tab:active, .choice:active {
  transform: translateY(calc(var(--btn-lip-size) - 1px));
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, 0.12), 0 1px 0 var(--btn-lip), 0 3px 6px rgba(0, 0, 0, 0.3);
}
.btn:focus-visible, .tile:focus-visible, .pill:focus-visible, .tab:focus-visible, .choice:focus-visible {
  outline: 4px solid #7cf3ff; outline-offset: 3px;
}
[aria-pressed="true"].choice, [aria-pressed="true"].tab {
  background: linear-gradient(180deg, #5c616c 0%, #3a3e46 55%, #2a2d33 100%);
  box-shadow: inset 0 0 0 3px var(--selected-ring), inset 0 3px 0 rgba(255, 255, 255, 0.2), 0 var(--btn-lip-size) 0 var(--btn-lip);
}
.btn { border-radius: var(--btn-radius); padding: 12px 22px; font-size: 22px; }
.btn.big { font-size: 30px; padding: 14px 28px; }

/* ------------------------------------------------------------------ main menu cluster */
.screen { position: fixed; z-index: 6; transition: opacity 0.45s ease, transform 0.45s ease; }
.screen.hidden { opacity: 0; pointer-events: none; transform: translateX(-40px); }
#main-menu {
  left: max(28px, env(safe-area-inset-left)); top: 50%; transform: translateY(-38%);
  width: var(--menu-width); display: grid; gap: var(--gap); grid-template-columns: minmax(0, 1fr);
}
#main-menu.hidden { transform: translate(-60px, -38%); }

/* pill bar with an icon bubble overlapping the left end (like the reference's top bars) */
.pill {
  display: flex; align-items: center; width: 100%; min-height: 76px; border-radius: var(--pill-radius);
  padding: 8px 26px 8px 92px; font-size: 38px; text-align: left; overflow: visible;
}
.pill .bubble {
  position: absolute; left: -10px; top: 50%; transform: translateY(-50%);
  width: 92px; height: 92px; border-radius: 50%; border: 4px solid #000;
  background: radial-gradient(circle at 35% 30%, #5d626c, #1b1d22 70%);
  box-shadow: inset 0 4px 0 rgba(255, 255, 255, 0.2), 0 5px 0 #000;
  display: grid; place-items: center; font-size: 46px; -webkit-text-stroke: 0; text-shadow: none;
}
.pill .sub { font-size: 16px; -webkit-text-stroke: 3px #000; color: var(--stat); display: block; line-height: 1.1; }
.pill .lbl { display: flex; flex-direction: column; line-height: 1.05; min-width: 0; }
.pill .sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; padding: 0 2px 4px; }
.pill .go { margin-left: auto; font-size: 40px; }

.ride-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); }
.choice { border-radius: var(--btn-radius); padding: 10px 8px; font-size: 22px; display: flex; align-items: center; justify-content: center; gap: 8px; }
.choice .ico { font-size: 26px; -webkit-text-stroke: 0; text-shadow: none; }
.ride-label { font-size: 18px; margin: 4px 0 -4px 4px; }

.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--gap); }
.tile {
  border-radius: var(--tile-radius); aspect-ratio: 1.08 / 1; display: flex; flex-direction: column;
  align-items: center; justify-content: space-between; padding: 10px 6px 8px; font-size: 19px; line-height: 1.05;
}
.tile .ico { font-size: 44px; -webkit-text-stroke: 0; text-shadow: 0 3px 0 rgba(0, 0, 0, 0.35); margin-top: 2px; }

/* ------------------------------------------------------------------ panels (track select, settings) */
.panel {
  background: var(--panel); border: 4px solid #000; border-radius: var(--panel-radius);
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, 0.12), 0 10px 0 rgba(0, 0, 0, 0.6), 0 18px 40px rgba(0, 0, 0, 0.4);
}
.panel h2 { margin: 0; font-size: 34px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px 8px 20px; }
.close { width: 52px; height: 52px; padding: 0; border-radius: 12px; font-size: 28px; flex: none; }

#track-select {
  right: max(24px, env(safe-area-inset-right)); top: 130px; bottom: 24px; width: min(640px, 52vw);
  display: flex; flex-direction: column;
}
#track-select.hidden { transform: translateX(60px); }
.tabs { display: flex; flex-wrap: wrap; gap: 8px; padding: 4px 16px 12px; }
.tab { border-radius: 12px; padding: 7px 12px; font-size: 17px; display: inline-flex; align-items: center; gap: 6px; }
.tab svg { width: 18px; height: 18px; }
.track-list { overflow-y: auto; padding: 0 14px 14px; display: grid; gap: 10px; scrollbar-width: thin; -webkit-overflow-scrolling: touch; }
.track-row {
  display: grid; grid-template-columns: 74px 1fr auto; align-items: center; gap: 12px;
  background: var(--panel-row); border: 3px solid #000; border-radius: 16px; padding: 10px 12px;
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, 0.1); cursor: pointer; transition: background 0.15s;
}
.track-row:hover, .track-row.hl { background: rgba(110, 120, 140, 0.95); }
.track-row .icon {
  width: 74px; height: 74px; border-radius: 14px; border: 3px solid #000; display: grid; place-items: center;
  background: linear-gradient(180deg, #f7f9fc, #c9d6e6); box-shadow: inset 0 3px 0 #fff, 0 4px 0 #000;
}
.track-row .icon svg { width: 46px; height: 46px; }
.track-name { font-size: 25px; line-height: 1.05; }
.stats { color: var(--stat); font-size: 16px; -webkit-text-stroke: 3px #000; paint-order: stroke fill; font-weight: 700; margin-top: 3px; }
.desc { font-size: 13px; color: #e8edf5; font-weight: 500; margin-top: 3px; line-height: 1.25; }
.track-row .btn { font-size: 21px; padding: 10px 16px; }
.track-row.last-track { box-shadow: inset 0 0 0 3px #7cf3ff, inset 0 3px 0 rgba(255, 255, 255, 0.1); }

#settings { left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(520px, 92vw); padding-bottom: 18px; }
#settings.hidden { transform: translate(-50%, -46%); }
.setting { padding: 8px 22px; }
.setting h3 { margin: 6px 0 8px; font-size: 22px; -webkit-text-stroke: 3px #000; paint-order: stroke fill; }
.setting .row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.setting .hint { font-size: 13px; color: #dfe6ef; margin-top: 6px; }
input[type=range] { width: 100%; accent-color: #ffffff; height: 30px; }
.range-row { display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 18px; -webkit-text-stroke: 2px #000; paint-order: stroke fill; }

/* ------------------------------------------------------------------ fly-in result card */
#track-card {
  left: max(24px, env(safe-area-inset-left)); top: 50%; transform: translateY(-50%);
  width: min(430px, 94vw); padding: 16px 18px; display: grid; grid-template-columns: 84px 1fr; gap: 6px 16px; align-items: center;
}
#track-card.hidden { transform: translate(-50px, -50%); }
#track-card .icon { width: 84px; height: 84px; grid-row: span 2; }
#track-card .track-name { font-size: 34px; }
#track-card .actions { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 2fr; gap: 12px; margin-top: 8px; }
.skip-hint {
  position: fixed; left: 0; right: 0; bottom: 18px; text-align: center; z-index: 6; font-size: 18px; font-weight: 700;
  -webkit-text-stroke: 3px #000; paint-order: stroke fill; pointer-events: none; transition: opacity 0.3s;
}
.skip-hint.hidden { opacity: 0; }

.toast {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%) scale(0.9); z-index: 20; padding: 22px 30px;
  font-size: 30px; text-align: center; opacity: 0; pointer-events: none; transition: opacity 0.25s, transform 0.25s;
}
.toast.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }

/* ------------------------------------------------------------------ loading screen */
#loading {
  position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; text-align: center;
  background: linear-gradient(180deg, #2f6fbf 0%, #9cc6ee 70%, #e9f2fb 100%); transition: opacity 0.6s ease;
}
#loading.done { opacity: 0; pointer-events: none; }
#loading .title { position: static; margin-bottom: 26px; }
.bar {
  width: min(460px, 80vw); height: 38px; border-radius: 999px; border: 4px solid #000; background: #1a1c20; overflow: hidden;
  box-shadow: inset 0 4px 0 rgba(255, 255, 255, 0.08), 0 6px 0 #000; margin: 0 auto;
}
.bar > div { height: 100%; width: 0%; background: linear-gradient(180deg, #8ee8ff, #2aa8e0 60%, #1b7fb3); box-shadow: inset 0 4px 0 rgba(255, 255, 255, 0.45); transition: width 0.25s; }
#loading .msg { margin-top: 14px; font-size: 22px; font-weight: 700; -webkit-text-stroke: 3px #000; paint-order: stroke fill; }
#loading.error .bar { display: none; }

/* ------------------------------------------------------------------ phones: one column */
@media (max-width: 820px) {
  :root { --title-size: clamp(36px, 11vw, 60px); --menu-width: calc(100vw - 32px); }
  #main-menu { left: 16px; right: 16px; top: auto; bottom: max(16px, env(safe-area-inset-bottom)); transform: none; }
  #main-menu.hidden { transform: translateY(40px); }
  .pill { min-height: 64px; font-size: 30px; padding-left: 82px; }
  .pill .bubble { width: 78px; height: 78px; font-size: 38px; }
  .tile .ico { font-size: 34px; }
  .tile { font-size: 15px; aspect-ratio: 1.25 / 1; }
  #track-select { left: 10px; right: 10px; width: auto; top: 96px; bottom: 10px; }
  #track-select.hidden { transform: translateY(40px); }
  .track-row { grid-template-columns: 56px 1fr; }
  .track-row .icon { width: 56px; height: 56px; }
  .track-row .icon svg { width: 34px; height: 34px; }
  .track-row .btn { grid-column: 1 / -1; }
  .track-name { font-size: 21px; }
  #track-card { grid-template-columns: 64px 1fr; left: 10px; right: 10px; width: auto; top: max(10px, env(safe-area-inset-top)); transform: none; }
  #track-card.hidden { transform: translateY(-40px); }
  #track-card .desc { display: none; }
  #track-card .icon { width: 64px; height: 64px; }
  #track-card .track-name { font-size: 26px; }
  .panel h2 { font-size: 28px; }
}
@media (max-height: 560px) and (min-width: 821px) {
  #main-menu { transform: translateY(-30%) scale(0.82); transform-origin: left center; }
}
