/* ============================================================
   Dune Runner — Nordic-desert flat vector
   ============================================================ */
:root{
  --sand:#E4D3B4;
  --sand-d:#D8C4A2;
  --sand-dd:#CBB58F;
  --haze:#C7D3DA;
  --birch:#F2F4F1;
  --char:#2B2F33;
  --amber:#D98E4A;
  --night:#1E2A3A;
  --moon:#EDF1F4;
  --rust:#C4553F;
  --line:rgba(43,47,51,.16);
  --line-soft:rgba(43,47,51,.09);
}

*,*::before,*::after{ box-sizing:border-box; }

html,body{
  height:100%;
  margin:0;
  padding:0;
  background:var(--birch);
}

body{
  font-family:'Space Grotesk', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color:var(--char);
  -webkit-font-smoothing:antialiased;
  text-rendering:optimizeLegibility;
  overscroll-behavior:none;
  -webkit-tap-highlight-color:transparent;
}

button{ font-family:inherit; -webkit-tap-highlight-color:transparent; }
button, .pad, .sw, .seg{ user-select:none; -webkit-user-select:none; }

.hidden{ display:none !important; }

.game-root{
  position:relative;
  height:100vh;
  height:100dvh;
  display:flex;
  flex-direction:column;
  overflow:hidden;
  background:var(--birch);
}

/* ---------------------------------------------------------- HUD */
.hud{
  flex:0 0 auto;
  padding:7px 12px 7px;
  display:flex;
  flex-direction:column;
  gap:5px;
  background:var(--birch);
  border-bottom:1px solid var(--line);
  color:var(--char);
  z-index:20;
}
.hud-row{
  display:flex;
  align-items:center;
  gap:14px;
  min-width:0;
}
.hud-spacer{ flex:1 1 auto; min-width:4px; }

.stat{ display:flex; flex-direction:column; gap:1px; min-width:0; line-height:1; }
.k{
  font-size:8.5px;
  font-weight:600;
  letter-spacing:.19em;
  text-transform:uppercase;
  color:rgba(43,47,51,.55);
  white-space:nowrap;
}
.v{
  font-size:17px;
  font-weight:600;
  letter-spacing:.04em;
  font-variant-numeric:tabular-nums;
  white-space:nowrap;
}
.v.tiny{ font-size:11px; letter-spacing:.06em; color:rgba(43,47,51,.65); min-width:34px; text-align:right; }

.day-stat{ align-items:flex-end; }

.icon-btn{
  flex:0 0 auto;
  width:36px; height:36px;
  border-radius:11px;
  border:1px solid var(--line);
  background:var(--birch);
  color:var(--char);
  display:grid; place-items:center;
  padding:0; cursor:pointer;
  transition:background .12s ease, transform .1s ease;
}
.icon-btn svg{ width:16px; height:16px; fill:currentColor; }
.icon-btn:active{ background:var(--char); color:var(--birch); transform:scale(.95); }

.meter-row{ gap:8px; }
.meter{
  flex:1 1 auto;
  height:6px;
  border-radius:99px;
  background:rgba(43,47,51,.11);
  overflow:hidden;
  min-width:40px;
}
.meter-fill{
  height:100%;
  width:100%;
  transform-origin:left center;
  transform:scaleX(0);
  background:var(--char);
  transition:background .25s ease;
}
.meter-fill.warn{ background:var(--amber); }
.meter-fill.danger{ background:var(--rust); }
.meter-fill.hunt{ background:#4E7F8C; }

.heat-line{
  height:3px;
  border-radius:99px;
  background:rgba(43,47,51,.10);
  overflow:hidden;
}
.heat-fill{
  height:100%; width:100%;
  transform-origin:left center;
  transform:scaleX(1);
  background:var(--amber);
}

/* ---------------------------------------------------------- stage */
.stage{
  position:relative;
  flex:1 1 auto;
  min-height:0;
  overflow:hidden;
  background:#BFD3DC;
}
#stageCanvas{ display:block; width:100%; height:100%; }

.grain{
  position:absolute; inset:0;
  pointer-events:none;
  z-index:3;
  opacity:.06;
  background-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/><feColorMatrix type='saturate' values='0'/></filter><rect width='140' height='140' filter='url(%23n)'/></svg>");
  background-size:140px 140px;
}

/* ---------------------------------------------------------- banner */
.banner{
  position:absolute; inset:0;
  display:flex; flex-direction:column;
  align-items:center; justify-content:center;
  gap:2px;
  pointer-events:none;
  z-index:8;
  opacity:0;
  transition:opacity .35s ease;
  color:var(--char);
  text-shadow:0 2px 26px rgba(242,244,241,.95), 0 0 12px rgba(242,244,241,.9);
}
.banner.show{ opacity:1; }
.banner-kicker{ font-size:10px; font-weight:700; letter-spacing:.42em; text-transform:uppercase; }
.banner-title{ font-size:42px; font-weight:700; letter-spacing:.02em; line-height:1; }

/* ---------------------------------------------------------- menus */
.menu{
  position:absolute; inset:0;
  display:flex;
  flex-direction:column;
  background:var(--birch);
  color:var(--char);
  overflow:hidden;
  z-index:40;
  border-radius:0;
}
.menu.dark{
  background:rgba(18,22,26,.80);
  -webkit-backdrop-filter:blur(14px);
  backdrop-filter:blur(14px);
  align-items:center;
  justify-content:center;
  padding:14px;
  overflow-y:auto;
}

/* garage ---------------------------------------------------- */
.garage{ padding:12px; }
.garage .garage-inner{ overscroll-behavior:contain; }
.garage-inner{
  flex:1 1 auto;
  min-height:0;
  overflow-y:auto;
  -webkit-overflow-scrolling:touch;
  display:flex;
  flex-direction:column;
  gap:14px;
  padding:2px 2px 18px;
}
.garage-head{ display:flex; flex-direction:column; gap:3px; }
.brand{
  margin:0;
  font-size:26px;
  font-weight:700;
  letter-spacing:.12em;
  line-height:1;
  color:var(--char);
}
.brand span{ color:var(--amber); }
.brand-sub{
  margin:0;
  font-size:11px;
  letter-spacing:.12em;
  text-transform:uppercase;
  color:rgba(43,47,51,.5);
}

.preview{
  position:relative;
  border-radius:16px;
  border:1px solid var(--line-soft);
  background:#F7F8F5;
  min-height:118px;
  display:flex;
  align-items:flex-end;
  justify-content:center;
  padding:12px 12px 6px;
  overflow:hidden;
}
.preview::after{
  content:'';
  position:absolute;
  left:0; right:0; bottom:0;
  height:32%;
  background:var(--sand);
  z-index:0;
}
.preview svg{
  position:relative;
  z-index:1;
  width:100%;
  max-width:330px;
  height:auto;
  display:block;
}

.field{ display:flex; flex-direction:column; gap:7px; }
.field-label{
  font-size:9px;
  font-weight:700;
  letter-spacing:.22em;
  text-transform:uppercase;
  color:rgba(43,47,51,.5);
}

.segmented{ display:flex; gap:6px; }
.seg{
  flex:1 1 0;
  min-height:44px;
  border-radius:11px;
  border:1px solid var(--line);
  background:#FFFFFF;
  color:var(--char);
  font-size:11px;
  font-weight:700;
  letter-spacing:.14em;
  cursor:pointer;
  padding:0 6px;
  transition:background .14s ease, color .14s ease, border-color .14s ease, transform .1s ease;
}
.seg:active{ transform:scale(.98); }
.seg.active{
  background:var(--char);
  color:var(--birch);
  border-color:var(--char);
}
.seg:focus-visible{ outline:2px solid var(--amber); outline-offset:2px; }

.swatches{ display:flex; gap:6px; flex-wrap:wrap; }
.sw{
  width:40px; height:40px;
  border-radius:12px;
  border:2px solid transparent;
  padding:0;
  cursor:pointer;
  box-shadow:inset 0 0 0 1px rgba(43,47,51,.20);
  transition:transform .12s ease, border-color .12s ease;
}
.sw:active{ transform:scale(.93); }
.sw.active{ border-color:var(--char); transform:translateY(-1px); }
.sw:focus-visible{ outline:2px solid var(--amber); outline-offset:2px; }

.start-btn{
  display:flex;
  align-items:center;
  justify-content:center;
  gap:10px;
  width:100%;
  min-height:56px;
  border:none;
  border-radius:14px;
  background:var(--char);
  color:var(--birch);
  font-size:13px;
  font-weight:700;
  letter-spacing:.18em;
  cursor:pointer;
  padding:0 18px;
  transition:transform .1s ease, background .18s ease;
}
.start-btn svg{ width:19px; height:19px; flex:0 0 auto; }
.start-btn:active{ transform:scale(.985); background:#1b1f22; }
.start-btn:focus-visible{ outline:2px solid var(--amber); outline-offset:2px; }

.ghost-btn{
  min-height:44px;
  border-radius:11px;
  border:1px solid var(--line);
  background:transparent;
  color:var(--char);
  font-size:11px;
  font-weight:700;
  letter-spacing:.16em;
  padding:0 14px;
  cursor:pointer;
  transition:background .14s ease, transform .1s ease;
}
.ghost-btn:active{ transform:scale(.97); background:rgba(43,47,51,.06); }
.ghost-btn.wide{ width:100%; min-height:50px; }

/* ranks ----------------------------------------------------- */
.ranks{
  display:flex;
  flex-direction:column;
  gap:7px;
  border-top:1px solid var(--line-soft);
  padding-top:12px;
}
.ranks-head{ display:flex; align-items:center; justify-content:space-between; gap:10px; }
.ranks-list{
  display:flex;
  flex-direction:column;
  gap:3px;
  max-height:118px;
  overflow-y:auto;
  -webkit-overflow-scrolling:touch;
}
.ranks-empty{
  margin:0;
  font-size:12px;
  color:rgba(43,47,51,.5);
  letter-spacing:.02em;
}
.rank-row{
  display:flex;
  align-items:center;
  gap:9px;
  font-size:12.5px;
  font-variant-numeric:tabular-nums;
  padding:2px 0;
}
.rank-row .rk{ width:16px; color:rgba(43,47,51,.42); font-weight:600; }
.rank-row .rh{ flex:1 1 auto; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.rank-row .rs{ font-weight:600; letter-spacing:.03em; }
.rank-row.you{ color:var(--amber); }
.rank-pb, .rank-note{
  font-size:10px;
  letter-spacing:.12em;
  text-transform:uppercase;
  color:rgba(43,47,51,.45);
  padding-top:3px;
}

/* panels ---------------------------------------------------- */
.panel{
  width:100%;
  max-width:420px;
  display:flex;
  flex-direction:column;
  gap:12px;
  background:var(--birch);
  color:var(--char);
  border-radius:18px;
  padding:22px 20px;
  margin:auto;
}
.panel-kicker{
  font-size:9px;
  font-weight:700;
  letter-spacing:.28em;
  text-transform:uppercase;
  color:var(--amber);
}
.panel-title{
  margin:0;
  font-size:23px;
  font-weight:700;
  letter-spacing:.01em;
  line-height:1.15;
}
.panel-body{
  margin:0;
  font-size:13.5px;
  line-height:1.55;
  color:rgba(43,47,51,.6);
}
.panel-actions{ display:flex; flex-direction:column; gap:8px; margin-top:4px; }

.score-row{ display:flex; gap:10px; }
.score-cell{
  flex:1 1 0;
  display:flex;
  flex-direction:column;
  gap:2px;
  background:#FFFFFF;
  border:1px solid var(--line-soft);
  border-radius:12px;
  padding:9px 10px;
  min-width:0;
}
.score-cell .v{ font-size:18px; overflow:hidden; text-overflow:ellipsis; }

.over-note{
  margin:0;
  font-size:11px;
  letter-spacing:.14em;
  text-transform:uppercase;
  color:rgba(43,47,51,.5);
}

/* sleep bar ------------------------------------------------- */
.sleepbar{
  position:absolute;
  left:0; right:0; bottom:0;
  z-index:9;
  padding:14px 18px 16px;
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:9px;
  pointer-events:none;
}
.sleep-hint{
  margin:0;
  font-size:10.5px;
  font-weight:600;
  letter-spacing:.2em;
  text-transform:uppercase;
  color:var(--moon);
  text-shadow:0 2px 14px rgba(0,0,0,.4);
}
.hold-btn{
  position:relative;
  overflow:hidden;
  pointer-events:auto;
  width:100%;
  max-width:320px;
  min-height:56px;
  border-radius:99px;
  border:1px solid rgba(237,241,244,.55);
  background:rgba(237,241,244,.10);
  color:var(--moon);
  font-size:11.5px;
  font-weight:700;
  letter-spacing:.22em;
  cursor:pointer;
  padding:0;
  -webkit-backdrop-filter:blur(8px);
  backdrop-filter:blur(8px);
  touch-action:none;
  transition:transform .1s ease;
}
.hold-btn.pressed{ transform:scale(.985); }
.hold-fill{
  position:absolute;
  inset:0;
  width:100%;
  transform-origin:left center;
  transform:scaleX(0);
  background:rgba(237,241,244,.32);
  z-index:0;
}
.hold-label{ position:relative; z-index:1; }

/* ---------------------------------------------------------- controls */
.controls{
  flex:0 0 auto;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:9px 16px 11px;
  background:var(--birch);
  border-top:1px solid var(--line);
  z-index:20;
}
.ctrl-group{ display:flex; gap:10px; }

.pad{
  width:72px;
  height:64px;
  border-radius:18px;
  border:1px solid rgba(43,47,51,.18);
  background:#FFFFFF;
  color:var(--char);
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:2px;
  padding:0;
  cursor:pointer;
  touch-action:none;
  box-shadow:0 1px 0 rgba(43,47,51,.10);
  transition:background .1s ease, color .1s ease, transform .08s ease, box-shadow .1s ease;
}
.pad svg{ width:26px; height:26px; }
.pad.boost{ width:86px; }
.pad-label{ font-size:8.5px; font-weight:700; letter-spacing:.16em; }
.pad:active, .pad.pressed{
  background:var(--char);
  color:var(--birch);
  transform:translateY(1px);
  box-shadow:none;
}
.pad:focus-visible{ outline:2px solid var(--amber); outline-offset:2px; }

/* ---------------------------------------------------------- small screens */
@media (max-width:430px){
  .hud{ padding:6px 10px 6px; gap:4px; }
  .hud-row{ gap:11px; }
  .v{ font-size:16px; }
  .v.tiny{ font-size:10.5px; min-width:30px; }
  .controls{ padding:8px 12px 10px; gap:8px; }
  .pad{ width:66px; height:60px; border-radius:16px; }
  .pad.boost{ width:78px; }
  .pad svg{ width:24px; height:24px; }
  .start-btn{ min-height:52px; font-size:12px; }
  .preview{ min-height:100px; }
  .brand{ font-size:22px; }
  .banner-title{ font-size:34px; }
}

@media (max-height:520px){
  .garage-inner{ gap:10px; }
  .preview{ min-height:84px; padding:6px 10px 4px; }
  .brand{ font-size:19px; }
  .brand-sub{ display:none; }
  .pad{ height:52px; }
  .controls{ padding:6px 12px 7px; }
  .hud{ padding:5px 10px 5px; gap:3px; }
  .v{ font-size:15px; }
}

@media (prefers-reduced-motion: reduce){
  *{ transition-duration:.01ms !important; animation-duration:.01ms !important; }
}