:root {
  --bg: #0d1b2a;
  --panel: rgba(13, 27, 42, 0.82);
  --line: rgba(255, 255, 255, 0.12);
  --text: #f0f4f8;
  --muted: #98b4c9;
  --ocean: #1b4965;
  --ocean-light: #3a8bb3;
  --sand: #e9c46a;
  --gold: #f4a261;
  --coral: #e76f51;
  --green: #2a9d8f;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #0a1622; }
body {
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
button { font: inherit; }
.game-shell { width: 100%; height: 100%; display: flex; flex-direction: column; background: radial-gradient(ellipse at 50% 100%, #1b4965 0%, #0d1b2a 45%, #070e17 100%); }
.game-bar {
  height: 50px; flex: 0 0 auto; display: flex; align-items: center; gap: .85rem;
  padding: 0 max(14px, env(safe-area-inset-left)) 0 max(14px, env(safe-area-inset-left));
  background: rgba(7, 14, 23, .88); border-bottom: 1px solid rgba(255,255,255,.08);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); z-index: 30;
}
.back-link { display: inline-flex; align-items: center; gap: .25rem; color: var(--muted); text-decoration: none; font-size: .85rem; font-weight: 700; white-space: nowrap; }
.back-link:hover { color: var(--text); }
.game-bar-title { flex: 1; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-pill { max-width: 145px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ocean-light); font-size: .75rem; padding: .35rem .55rem; border: 1px solid rgba(58,139,179,.25); border-radius: 999px; background: rgba(58,139,179,.08); }
.icon-btn, .hud-btn { width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--line); color: var(--text); background: rgba(255,255,255,.06); cursor: pointer; display: grid; place-items: center; }
.icon-btn:hover, .hud-btn:hover { background: rgba(255,255,255,.12); }
.game-wrap { flex: 1; position: relative; overflow: hidden; display: grid; place-items: start center; background: #000; }
#game-canvas { width: 100%; height: 100%; display: block; image-rendering: auto; }
.screen { position: absolute; inset: 0; z-index: 20; display: none; align-items: center; justify-content: center; padding: 18px; background: radial-gradient(ellipse at 50% 100%, rgba(27,73,101,.5), rgba(7,14,23,.75) 60%, rgba(7,14,23,.88)); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.screen-active { display: flex; }
.panel { width: min(520px, calc(100vw - 28px)); max-height: min(760px, calc(100% - 30px)); overflow: auto; padding: clamp(20px, 4vw, 34px); border-radius: 28px; background: linear-gradient(180deg, rgba(13,27,42,.88), rgba(7,14,23,.78)); border: 1px solid rgba(255,255,255,.14); box-shadow: 0 24px 100px rgba(0,0,0,.55), 0 0 45px rgba(58,139,179,.16); text-align: center; }
.panel-sm { width: min(410px, calc(100vw - 28px)); }
.menu-panel h1 { font-size: clamp(2.4rem, 9vw, 4.8rem); line-height: .9; letter-spacing: -.06em; text-shadow: 0 0 28px rgba(42,157,143,.45); }
.panel h2 { font-size: clamp(2rem, 8vw, 3.2rem); letter-spacing: -.05em; margin-bottom: 10px; }
.panel h3 { margin: 18px 0 8px; color: var(--muted); font-size: .9rem; text-transform: uppercase; letter-spacing: .18em; }
.eyebrow { color: var(--ocean-light); font-weight: 900; font-size: .76rem; letter-spacing: .24em; text-transform: uppercase; margin-bottom: 10px; }
.subtitle, .panel p { color: var(--muted); line-height: 1.5; }
.logo-orb { width: 80px; height: 80px; margin: 0 auto 18px; border-radius: 50%; background: radial-gradient(circle, #e9c46a 0%, #f4a261 30%, #e76f51 55%, transparent 72%); box-shadow: 0 0 45px rgba(233,196,106,.5), 0 0 90px rgba(231,111,81,.25); animation: pulse 1.7s ease-in-out infinite; display: grid; place-items: center; }
.logo-orb .coconut-icon { font-size: 2.4rem; filter: drop-shadow(0 0 8px rgba(233,196,106,.6)); }
@keyframes pulse { 50% { transform: scale(1.07); filter: brightness(1.3); } }
.stat-strip { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; margin: 18px 0; }
.stat-strip span { padding: .55rem .78rem; border-radius: 999px; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.1); color: var(--muted); font-size: .85rem; }
.stat-strip b { color: var(--gold); }
.menu-actions { display: grid; gap: 11px; margin-top: 20px; }
.menu-actions.compact { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
.menu-actions button { min-height: 48px; border: 1px solid rgba(255,255,255,.14); border-radius: 15px; cursor: pointer; color: var(--text); background: rgba(255,255,255,.07); box-shadow: inset 0 1px rgba(255,255,255,.07); font-weight: 900; letter-spacing: .02em; }
.menu-actions button:hover, .menu-actions button:focus-visible { transform: translateY(-1px); background: rgba(255,255,255,.11); outline: none; }
.menu-actions .primary { border: none; background: linear-gradient(135deg, var(--coral), var(--gold)); box-shadow: 0 16px 40px rgba(231,111,81,.28); }
.readable { text-align: left; }
.readable h2, .readable .eyebrow { text-align: center; }
.how-grid { display: grid; gap: 10px; margin-top: 18px; }
.how-grid div { padding: 13px; border-radius: 16px; border: 1px solid rgba(255,255,255,.1); background: rgba(255,255,255,.05); }
.how-grid b { display: block; color: var(--text); margin-bottom: 5px; }
.how-grid span { display: block; color: var(--muted); line-height: 1.45; font-size: .92rem; }
.hud { position: absolute; z-index: 12; top: 12px; left: 12px; right: 12px; pointer-events: none; display: grid; gap: 8px; }
.hud.hidden { display: none; }
.hud-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.hud-row.top { justify-content: center; }
.hud-row.bottom { justify-content: center; }
.hud span { min-height: 28px; display: inline-flex; align-items: center; gap: 4px; padding: .35rem .55rem; border-radius: 999px; background: rgba(7,14,23,.62); border: 1px solid rgba(255,255,255,.11); color: var(--muted); font-weight: 800; font-size: clamp(.68rem, 2vw, .82rem); backdrop-filter: blur(12px); }
.hud b { color: var(--text); }
.hud-btn { pointer-events: all; width: 32px; height: 32px; }
.wind-indicator { display: inline-flex; align-items: center; gap: 6px; }
.wind-label { color: var(--muted); font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; }
.wind-arrow { font-size: 1rem; transition: transform .3s ease; }
.wind-value { font-family: 'Courier New', monospace; min-width: 2.2em; }
.toast { position: absolute; left: 50%; top: 112px; transform: translateX(-50%); z-index: 13; pointer-events: none; color: var(--sand); font-weight: 1000; text-shadow: 0 0 18px rgba(233,196,106,.7), 0 2px 8px rgba(0,0,0,.5); opacity: 0; transition: opacity .18s, transform .18s; white-space: nowrap; font-size: 1.2rem; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-6px); }
.stars-display { font-size: 2.8rem; letter-spacing: .15em; margin: 8px 0 4px; }
.final-score { font-size: clamp(2.8rem, 14vw, 5rem); font-weight: 1000; letter-spacing: -.06em; background: linear-gradient(135deg, var(--gold), var(--coral), var(--green)); -webkit-background-clip: text; background-clip: text; color: transparent; margin: 6px 0 12px; }
.summary-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.summary-grid div, .leaderboard-row { padding: 10px 12px; border: 1px solid rgba(255,255,255,.1); border-radius: 14px; background: rgba(255,255,255,.055); }
.summary-grid b { color: var(--text); display: block; font-size: 1.05rem; }
.summary-grid span { color: var(--muted); font-size: .74rem; text-transform: uppercase; letter-spacing: .12em; }
.leaderboard-list { display: grid; gap: 8px; }
.leaderboard-row { display: grid; grid-template-columns: 34px 1fr auto; gap: 8px; align-items: center; text-align: left; }
.leaderboard-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leaderboard-row small { display: block; color: var(--muted); font-size: .72rem; }
.leaderboard-row .score { color: var(--gold); font-weight: 1000; }
.nn-score-nudge { margin-top: 16px; padding: 16px; border-radius: 16px; background: rgba(42,157,143,.12); border: 1px solid rgba(42,157,143,.25); }
.nn-score-nudge p { color: var(--text); font-weight: 700; margin-bottom: 10px; }
.nn-nudge-btns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.nn-nudge-signup { display: inline-block; padding: .5rem 1.2rem; border-radius: 999px; background: linear-gradient(135deg, var(--green), var(--ocean-light)); color: #fff; text-decoration: none; font-weight: 900; font-size: .85rem; }
.nn-nudge-later { padding: .5rem 1.2rem; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--muted); cursor: pointer; font-size: .85rem; }
.nn-nudge-later:hover { color: var(--text); }
@media (max-width: 700px) {
  .game-bar { height: 46px; gap: .45rem; padding-inline: 10px; }
  .player-pill { display: none; }
  .hud { top: 8px; left: 8px; right: 8px; }
  .hud span { padding: .32rem .45rem; }
  .screen { padding: 10px; }
  .panel { border-radius: 22px; }
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-height: 560px) {
  .hud-row.bottom span:nth-child(1), .hud-row.bottom span:nth-child(2) { display: none; }
  .panel { padding: 18px; }
  .menu-panel h1 { font-size: 2.6rem; }
}
