:root{
  --bg-peach:#f2b8a0;
  --bg-peach-deep:#db977b;
  --bg-peach-dark:#be765f;
  --sky:#87CEEB;
  --sky-deep:#4ea7d6;
  --cream:#fffaf3;
  --panel:#fffdfaee;
  --panel-solid:#fffdfa;
  --panel-border:rgba(77, 99, 115, 0.16);
  --shadow:0 20px 60px rgba(37, 49, 58, 0.18);
  --ink:#294051;
  --ink-soft:#5d7380;
  --ink-faint:#8a9aa4;
  --overlay:rgba(18, 26, 33, 0.52);
  --success:#34b56f;
  --gold:#f7c85d;
  --silver:#c3d0dc;
  --bronze:#d69061;
  --diamond:#7ce4ff;
  --danger:#d96d6a;
  --radius-lg:28px;
  --radius-md:20px;
  --radius-sm:14px;
  --safe-top:max(env(safe-area-inset-top), 16px);
  --safe-bottom:max(env(safe-area-inset-bottom), 16px);
  --grain:url('/assets/texture/grain.svg');
}

*{box-sizing:border-box}
html,body{
  width:100%;
  height:100%;
  margin:0;
  overflow:hidden;
  background:var(--bg-peach);
  font-family:Inter,ui-rounded,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;
  -webkit-user-select:none;
  user-select:none;
  -webkit-touch-callout:none;
  -webkit-tap-highlight-color:transparent;
  overscroll-behavior:none;
}
body{
  color:var(--ink);
  touch-action:none;
}
button,input,textarea,select{font:inherit}
a{color:inherit;text-decoration:none}
.hidden{display:none !important}
.app-shell{
  position:fixed;
  inset:0;
  overflow:hidden;
  background:
    radial-gradient(circle at 20% 18%, rgba(255,255,255,0.45), transparent 26%),
    radial-gradient(circle at 85% 12%, rgba(255,255,255,0.18), transparent 22%),
    linear-gradient(180deg, #f5c3b2 0%, var(--bg-peach) 38%, #e9aa8f 100%);
}
#gameCanvas{
  position:absolute;
  inset:0;
  width:100%;
  height:100%;
  display:block;
  outline:none;
}

.top-ui{
  position:absolute;
  inset:0;
  pointer-events:none;
  z-index:5;
}
.icon-button{
  appearance:none;
  border:0;
  padding:0;
  width:52px;
  height:52px;
  border-radius:50%;
  pointer-events:auto;
  background:rgba(255,255,255,0.78);
  box-shadow:0 10px 26px rgba(38,48,58,0.18);
  color:var(--ink);
  display:grid;
  place-items:center;
  backdrop-filter:blur(14px);
  cursor:pointer;
  transition:transform .15s ease, background .15s ease, box-shadow .15s ease;
}
.icon-button:hover{transform:translateY(-1px);background:rgba(255,255,255,0.9)}
.icon-button:active{transform:scale(.96)}
.gear-button{
  position:absolute;
  top:var(--safe-top);
  left:16px;
}
.close-button{
  width:44px;height:44px;border-radius:16px;font-size:20px;background:rgba(255,255,255,0.88)
}
.icon-gear{
  font-size:22px;
  line-height:1;
}
.distance-hud{
  position:absolute;
  top:var(--safe-top);
  left:50%;
  transform:translateX(-50%);
  min-width:120px;
  padding:12px 20px;
  border-radius:999px;
  background:rgba(255,255,255,0.78);
  color:var(--ink);
  font-weight:800;
  letter-spacing:.04em;
  box-shadow:0 16px 36px rgba(38,48,58,0.16);
  backdrop-filter:blur(16px);
  text-align:center;
  font-variant-numeric:tabular-nums;
  pointer-events:none;
}

.overlay{
  position:absolute;
  inset:0;
  z-index:12;
  display:grid;
  place-items:center;
}
.overlay-backdrop{
  position:absolute;
  inset:0;
  background:var(--overlay);
  backdrop-filter:blur(14px);
}
.menu-surface{
  position:relative;
  width:min(1180px, calc(100vw - 28px));
  height:min(760px, calc(100vh - 28px - var(--safe-top) - var(--safe-bottom)));
  border-radius:34px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.9), rgba(255,251,246,0.95)),
    var(--grain);
  border:1px solid var(--panel-border);
  box-shadow:var(--shadow);
  overflow:hidden;
  display:grid;
  grid-template-rows:auto 1fr auto;
}
.menu-header{
  padding:20px 22px 18px;
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:16px;
}
.brand-stack{display:flex;flex-direction:column;gap:10px}
.brand-logo{height:52px;max-width:320px}
.seed-line{display:flex;gap:12px;align-items:center;flex-wrap:wrap}
.google-slot{display:flex;align-items:center;justify-content:flex-end}
.google-slot.center{justify-content:center}
.menu-header-actions{display:flex;align-items:flex-start;gap:12px}
.menu-layout{
  min-height:0;
  display:grid;
  grid-template-columns:240px minmax(0,1fr);
  gap:0;
}
.menu-nav{
  padding:0 16px 18px 20px;
  display:flex;
  flex-direction:column;
  gap:12px;
}
.nav-button{
  appearance:none;
  border:1px solid rgba(67, 89, 104, 0.12);
  background:rgba(255,255,255,0.58);
  color:var(--ink);
  border-radius:22px;
  min-height:56px;
  padding:0 18px;
  text-align:left;
  font-weight:800;
  letter-spacing:.05em;
  cursor:pointer;
  transition:transform .14s ease, background .14s ease, box-shadow .14s ease;
}
.nav-button.active{
  background:linear-gradient(180deg, rgba(255,255,255,0.98), rgba(220,244,255,0.94));
  box-shadow:0 14px 26px rgba(48,92,117,0.12);
}
.nav-button:hover{transform:translateX(2px)}
.menu-content{
  min-height:0;
  padding:0 22px 22px 0;
  display:flex;
}
.pane{
  display:none;
  width:100%;
  min-height:0;
  flex-direction:column;
  gap:18px;
}
.pane.active{display:flex}
.hero-card,.table-card,.settings-card,.history-card,.info-card,.stat-card,.crash-card,.username-card{
  background:
    linear-gradient(180deg, rgba(255,255,255,0.95), rgba(255,250,246,0.96)),
    var(--grain);
  border:1px solid var(--panel-border);
  box-shadow:0 16px 34px rgba(56,77,87,0.08);
}
.hero-card{
  border-radius:28px;
  padding:24px;
  display:grid;
  grid-template-columns:1fr auto;
  gap:20px;
  align-items:center;
}
.hero-copy h1{
  margin:0 0 10px;
  font-size:clamp(28px, 4vw, 40px);
  line-height:1;
  letter-spacing:-.02em;
}
.hero-copy p{
  margin:0;
  color:var(--ink-soft);
  max-width:60ch;
  line-height:1.5;
}
.hero-meta{display:flex;gap:10px;flex-wrap:wrap;margin-top:16px}
.hero-actions{display:flex;flex-direction:column;gap:12px;min-width:200px}
.section-head{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:14px;
}
.section-head h2,.info-card h2,.info-card h3,.history-card h3{
  margin:0 0 8px;
  font-size:22px;
}
.section-head p,.info-card p{
  margin:0;
  color:var(--ink-soft);
  line-height:1.45;
}
.segmented{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
}
.segmented-button{
  appearance:none;
  border:1px solid rgba(67,89,104,.12);
  background:rgba(255,255,255,.7);
  border-radius:999px;
  min-height:40px;
  padding:0 16px;
  font-weight:800;
  letter-spacing:.04em;
  color:var(--ink);
  cursor:pointer;
}
.segmented-button.active{
  background:linear-gradient(180deg,#95dfff,#6fc8f1);
  color:#17384b;
}
.table-card{
  border-radius:24px;
  overflow:hidden;
  min-height:0;
}
.leaderboard-table{
  width:100%;
  border-collapse:collapse;
  table-layout:fixed;
  font-variant-numeric:tabular-nums;
}
.leaderboard-table thead th{
  text-align:left;
  color:var(--ink-soft);
  font-size:12px;
  letter-spacing:.08em;
  font-weight:800;
  padding:14px 18px 12px;
  border-bottom:1px solid rgba(78,100,114,.1);
}
.leaderboard-table tbody td{
  padding:12px 18px;
  border-bottom:1px solid rgba(78,100,114,.08);
  font-size:14px;
}
.leaderboard-table tbody tr:last-child td{border-bottom:0}
.leaderboard-table tbody tr:nth-child(1){background:rgba(255,213,106,.12)}
.leaderboard-table tbody tr:nth-child(2){background:rgba(195,208,220,.14)}
.leaderboard-table tbody tr:nth-child(3){background:rgba(214,144,97,.12)}
.rank-col{width:52px}
.distance-col,.points-col{width:122px;text-align:right}
.center-col{text-align:center;width:54px}
.player-row,.chip-row{display:flex;gap:10px;flex-wrap:wrap}
.chip{
  display:inline-flex;
  align-items:center;
  gap:8px;
  min-height:34px;
  padding:0 14px;
  border-radius:999px;
  background:rgba(255,255,255,.74);
  border:1px solid rgba(67,89,104,.12);
  color:var(--ink);
  font-size:13px;
  font-weight:700;
}
.chip.subtle{
  color:var(--ink-soft);
  background:rgba(255,255,255,.56);
}
.chip.success{
  background:rgba(52,181,111,.15);
  color:#1f7d4b;
}
.btn{
  appearance:none;
  border:0;
  min-height:50px;
  padding:0 18px;
  border-radius:18px;
  font-weight:800;
  letter-spacing:.05em;
  cursor:pointer;
  transition:transform .14s ease, filter .14s ease, box-shadow .14s ease;
}
.btn:hover{transform:translateY(-1px)}
.btn:active{transform:scale(.98)}
.btn-primary{
  background:linear-gradient(180deg, #ffffff, #d8f0fb 95%);
  color:#1e4358;
  box-shadow:0 14px 28px rgba(74, 124, 150, .18);
}
.btn-secondary{
  background:rgba(255,255,255,.75);
  color:var(--ink);
  border:1px solid rgba(67,89,104,.12);
}
.btn-danger{
  background:linear-gradient(180deg, #f8a8a2, #eb867d);
  color:#5a1717;
  box-shadow:0 12px 22px rgba(188, 91, 86, .18);
}
.btn.wide{width:100%}
.button-row{display:flex;gap:12px;flex-wrap:wrap}
.button-row.center{justify-content:center}
.stats-grid,.info-grid{
  display:grid;
  gap:14px;
}
.stats-grid{
  grid-template-columns:repeat(2, minmax(0, 1fr));
}
.info-grid{
  grid-template-columns:repeat(2, minmax(0,1fr));
}
.info-grid.compact .info-card{padding:18px 20px}
.info-card,.history-card,.settings-card{
  border-radius:24px;
  padding:20px;
}
.stat-card{
  border-radius:22px;
  padding:18px;
  display:flex;
  flex-direction:column;
  gap:8px;
}
.stat-label{
  color:var(--ink-soft);
  font-size:12px;
  letter-spacing:.08em;
  font-weight:800;
  text-transform:uppercase;
}
.stat-value{
  font-size:24px;
  font-weight:900;
  letter-spacing:-.02em;
  font-variant-numeric:tabular-nums;
}
.medal-strip{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
}
.medal-pill{
  display:inline-flex;
  min-height:36px;
  padding:0 14px;
  border-radius:999px;
  align-items:center;
  font-weight:800;
  letter-spacing:.03em;
}
.medal-gold{background:rgba(247,200,93,.18);color:#8b6715}
.medal-silver{background:rgba(195,208,220,.24);color:#4b5b66}
.medal-bronze{background:rgba(214,144,97,.18);color:#88553a}
.medal-diamond{background:rgba(124,228,255,.2);color:#0c6b86}
.helper-text{
  color:var(--ink-soft);
  line-height:1.45;
  font-size:14px;
}
.history-list{
  list-style:none;
  padding:0;
  margin:12px 0 0;
  display:flex;
  flex-direction:column;
  gap:10px;
}
.history-item{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  min-height:42px;
  padding:0 14px;
  border-radius:16px;
  background:rgba(255,255,255,.55);
  border:1px solid rgba(67,89,104,.08);
  font-size:14px;
}
.menu-footer{
  padding:16px 22px 18px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
  color:var(--ink-soft);
  font-size:13px;
}
.footer-links{
  display:flex;
  gap:16px;
  flex-wrap:wrap;
}
.footer-links a:hover{color:var(--ink)}
.crash-overlay,.username-gate{
  position:absolute;
  inset:0;
  z-index:14;
  display:grid;
  place-items:center;
  background:rgba(16,24,30,.48);
  backdrop-filter:blur(14px);
}
.crash-card{
  width:min(540px, calc(100vw - 28px));
  border-radius:34px;
  padding:28px;
  text-align:center;
}
.crash-logo,.gate-logo{height:48px;max-width:100%}
.crash-name{
  margin-top:16px;
  color:var(--ink-soft);
  font-weight:800;
  letter-spacing:.06em;
  text-transform:uppercase;
}
.crash-distance{
  margin-top:10px;
  font-size:clamp(42px, 10vw, 70px);
  font-weight:900;
  letter-spacing:-.04em;
  line-height:1;
  font-variant-numeric:tabular-nums;
}
.crash-line{
  margin-top:10px;
  font-size:15px;
  color:var(--ink);
  line-height:1.4;
}
.crash-line.subtle{color:var(--ink-soft)}
.guest-prompt{
  margin-top:18px;
  padding:16px;
  border-radius:22px;
  background:rgba(255,255,255,.62);
  border:1px solid rgba(67,89,104,.08);
}
.guest-copy{
  color:var(--ink-soft);
  font-size:14px;
  margin-bottom:12px;
}
.username-card{
  width:min(460px, calc(100vw - 28px));
  border-radius:34px;
  padding:28px;
  text-align:center;
}
.username-card h2{
  margin:18px 0 10px;
  font-size:30px;
  letter-spacing:-.03em;
}
.username-card p{
  margin:0 0 18px;
  color:var(--ink-soft);
  line-height:1.5;
}
.username-form{
  display:flex;
  flex-direction:column;
  gap:12px;
}
.text-input{
  appearance:none;
  width:100%;
  min-height:56px;
  border-radius:18px;
  border:1px solid rgba(67,89,104,.14);
  background:rgba(255,255,255,.82);
  padding:0 18px;
  color:var(--ink);
  outline:none;
  box-shadow:inset 0 1px 0 rgba(255,255,255,.9);
}
.text-input:focus{
  border-color:rgba(78,167,214,.45);
  box-shadow:0 0 0 4px rgba(78,167,214,.16), inset 0 1px 0 rgba(255,255,255,.9);
}
.setting-toggle{
  appearance:none;
  width:100%;
  border:1px solid rgba(67,89,104,.12);
  background:rgba(255,255,255,.78);
  min-height:64px;
  border-radius:20px;
  padding:0 18px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  cursor:pointer;
}
.setting-label{
  font-weight:800;
  letter-spacing:.05em;
}
.setting-value{
  font-weight:900;
  color:var(--ink-soft);
}
.toast{
  position:absolute;
  left:50%;
  bottom:calc(var(--safe-bottom) + 14px);
  transform:translateX(-50%);
  z-index:20;
  min-height:42px;
  max-width:min(90vw, 560px);
  padding:0 18px;
  display:flex;
  align-items:center;
  justify-content:center;
  border-radius:999px;
  background:rgba(28, 40, 49, .82);
  color:#fff;
  box-shadow:0 18px 36px rgba(16,22,30,.24);
  backdrop-filter:blur(14px);
  font-size:14px;
  font-weight:700;
  letter-spacing:.02em;
  pointer-events:none;
}

@media (max-width: 980px){
  .menu-surface{
    width:min(100vw - 16px, 860px);
    height:min(100vh - 16px - var(--safe-top) - var(--safe-bottom), 820px);
    border-radius:30px;
  }
  .menu-layout{
    grid-template-columns:1fr;
    grid-template-rows:auto 1fr;
  }
  .menu-nav{
    padding:0 14px 12px;
    flex-direction:row;
    overflow:hidden;
  }
  .nav-button{
    flex:1 1 0;
    text-align:center;
    min-height:50px;
    font-size:12px;
    padding:0 10px;
  }
  .menu-content{
    padding:0 14px 14px;
  }
  .hero-card{
    grid-template-columns:1fr;
  }
  .hero-actions{
    min-width:0;
    width:100%;
  }
}

@media (max-width: 760px){
  .menu-header{
    padding:14px 14px 12px;
  }
  .brand-logo{
    height:42px;
    max-width:220px;
  }
  .seed-line{
    gap:8px;
  }
  .menu-surface{
    width:calc(100vw - 12px);
    height:calc(100vh - 12px - var(--safe-top) - var(--safe-bottom));
    border-radius:28px;
  }
  .segmenteds{}
  .section-head{
    flex-direction:column;
  }
  .stats-grid,.info-grid{
    grid-template-columns:1fr;
  }
  .leaderboard-table thead th,
  .leaderboard-table tbody td{
    padding-left:12px;
    padding-right:12px;
    font-size:12px;
  }
  .distance-col,.points-col{
    width:96px;
  }
  .center-col{
    width:44px;
  }
  .menu-footer{
    padding:12px 14px 14px;
    flex-direction:column;
    align-items:flex-start;
  }
  .footer-links{
    gap:12px;
  }
  .btn{
    min-height:46px;
    font-size:13px;
  }
  .icon-button{
    width:48px;
    height:48px;
  }
  .gear-button{
    left:12px;
  }
  .distance-hud{
    min-width:110px;
    padding:10px 18px;
  }
}

@media (max-height: 740px){
  .menu-surface{
    height:min(100vh - 10px - var(--safe-top) - var(--safe-bottom), 680px);
  }
  .hero-copy h1{font-size:26px}
  .info-card,.history-card,.settings-card,.hero-card,.stat-card,.crash-card,.username-card{
    padding:16px;
  }
  .leaderboard-table thead th,.leaderboard-table tbody td{
    padding-top:9px;
    padding-bottom:9px;
  }
  .nav-button{min-height:46px}
}


/* ==== 2026-03 portrait-stage + artifact cleanup overrides ==== */
html,body{
  display:flex;
  align-items:center;
  justify-content:center;
  background:
    radial-gradient(circle at 20% 18%, rgba(255,255,255,0.45), transparent 26%),
    radial-gradient(circle at 85% 12%, rgba(255,255,255,0.18), transparent 22%),
    linear-gradient(180deg, #f5c3b2 0%, var(--bg-peach) 38%, #e9aa8f 100%);
}

.app-shell{
  position:relative;
  inset:auto;
  width:100vw;
  height:100svh;
  max-width:100vw;
  max-height:100svh;
  overflow:hidden;
  box-shadow:none;
  border-radius:0;
}

@media (orientation: landscape), (min-width: 900px) and (min-aspect-ratio: 1/1){
  body{
    padding:12px;
  }
  .app-shell{
    width:auto;
    height:min(calc(100svh - 24px), 920px);
    aspect-ratio:9 / 16;
    max-width:calc(100vw - 24px);
    max-height:calc(100svh - 24px);
    border-radius:32px;
    box-shadow:0 26px 70px rgba(37,49,58,0.28);
  }
}

#gameCanvas{
  width:100%;
  height:100%;
}

.menu-surface{
  width:calc(100% - 16px);
  height:calc(100% - 16px);
  max-width:none;
  max-height:none;
  border-radius:28px;
  grid-template-rows:auto 1fr auto;
}

.menu-header{
  padding:14px 14px 12px;
  flex-direction:column;
  align-items:stretch;
  gap:12px;
}

.brand-logo{
  height:56px;
  max-width:min(72vw, 320px);
  object-fit:contain;
  object-position:left center;
}

.seed-line{
  gap:8px;
}

.menu-header-actions{
  width:100%;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  flex-wrap:nowrap;
}

.google-slot{
  min-height:44px;
  flex:1 1 auto;
  width:100%;
  max-width:100%;
  justify-content:flex-start;
  overflow:hidden;
}

.google-slot.center{
  justify-content:center;
}

.menu-layout{
  grid-template-columns:1fr;
  grid-template-rows:auto 1fr;
  min-height:0;
  gap:0;
}

.menu-nav{
  padding:0 14px 12px;
  flex-direction:row;
  gap:8px;
  overflow-x:auto;
  scrollbar-width:none;
}

.menu-nav::-webkit-scrollbar{
  display:none;
}

.nav-button{
  flex:1 0 auto;
  min-width:0;
  text-align:center;
  min-height:50px;
  font-size:12px;
  padding:0 10px;
}

.menu-content{
  padding:0 14px 14px;
  display:block;
  overflow-y:auto;
  -webkit-overflow-scrolling:touch;
  touch-action:pan-y;
}

.pane{
  min-height:0;
  padding-bottom:4px;
}

.hero-card{
  grid-template-columns:1fr;
  padding:18px;
}

.hero-copy h1{
  font-size:clamp(22px, 7vw, 34px);
}

.hero-copy p{
  max-width:none;
  font-size:14px;
}

.hero-actions{
  min-width:0;
  width:100%;
}

.section-head{
  flex-direction:column;
  gap:10px;
}

.stats-grid,.info-grid{
  grid-template-columns:1fr;
}

.table-card{
  overflow:auto;
}

.leaderboard-table{
  table-layout:auto;
  min-width:100%;
}

.leaderboard-table thead th,
.leaderboard-table tbody td{
  padding-left:12px;
  padding-right:12px;
}

.distance-col,.points-col{
  width:96px;
}

.center-col{
  width:44px;
}

.menu-footer{
  padding:12px 14px 14px;
  flex-direction:column;
  align-items:flex-start;
}

.footer-links{
  gap:12px;
}

.crash-card,
.username-card{
  width:calc(100% - 24px);
  max-width:520px;
  padding:22px;
}

.crash-logo,.gate-logo{
  height:54px;
  width:auto;
  object-fit:contain;
}

.guest-prompt{
  padding:14px;
}

.guest-copy{
  margin-bottom:10px;
}

.icon-button{
  width:48px;
  height:48px;
}

.gear-button{
  left:12px;
  top:max(env(safe-area-inset-top), 12px);
}

.distance-hud{
  top:max(env(safe-area-inset-top), 12px);
  min-width:110px;
  padding:10px 18px;
}

.setting-toggle{
  min-height:56px;
}

.history-item{
  padding:10px 12px;
  min-height:0;
  align-items:flex-start;
  flex-direction:column;
}

@media (max-width: 420px){
  .brand-logo{
    height:48px;
  }
  .btn{
    min-height:46px;
    font-size:13px;
  }
  .leaderboard-table thead th,
  .leaderboard-table tbody td{
    font-size:12px;
  }
}
