:root {
  --ink: #102a2e;
  --ink-soft: #52696c;
  --card: rgba(255, 255, 255, 0.86);
  --line: rgba(16, 42, 46, 0.12);
  --accent: #ff6a1a;
  --accent-dark: #c9480a;
  --teal: #1a7f86;
  --gold: #ffd23a;
  --good: #1f9d62;
  --bad: #d8232f;
  --radius: 16px;
  font-family: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0c2226; }
body { -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, canvas:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
canvas:focus { outline: none; }
kbd { display: inline-block; min-width: 1.6em; padding: 1px 5px; border-radius: 6px; background: rgba(16, 42, 46, 0.08); border-bottom: 2px solid rgba(16, 42, 46, 0.18); font: 700 11px/1.5 ui-monospace, SFMono-Regular, monospace; text-align: center; }

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

.loading { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 18px; letter-spacing: 0.02em; background: radial-gradient(circle at 50% 40%, #1f6f76, #0c2226); }
.loading[hidden] { display: none; }

.hud { position: absolute; top: max(10px, env(safe-area-inset-top)); left: 10px; right: 10px; display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; pointer-events: none; }
.hud[hidden] { display: none; }
.hud-card { display: grid; min-width: 104px; padding: 6px 14px 7px; border-radius: var(--radius); background: var(--card); backdrop-filter: blur(8px); box-shadow: 0 6px 20px rgba(8, 24, 26, 0.18); font-variant-numeric: tabular-nums; }
.hud-title { font-size: 24px; letter-spacing: -0.02em; line-height: 1.1; white-space: nowrap; }
.hud-title small { font-size: 13px; color: var(--ink-soft); }
.hud-small { font-size: 12px; font-weight: 700; color: var(--ink-soft); white-space: nowrap; }
.hud-small b { color: var(--ink); }
.hull { display: flex; gap: 6px; padding: 9px 12px; border-radius: 999px; background: var(--card); backdrop-filter: blur(8px); box-shadow: 0 6px 20px rgba(8, 24, 26, 0.18); }
.hull i { width: 22px; height: 12px; border-radius: 12px 12px 5px 5px; background: var(--accent); box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.18); transition: background 0.3s, transform 0.3s; }
.hull i.is-lost { background: rgba(16, 42, 46, 0.16); box-shadow: none; transform: scale(0.85); }
.hull.is-hit { animation: shake 0.35s; }
@keyframes shake { 20% { transform: translateX(-5px); } 40% { transform: translateX(5px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(2px); } }
.hud-right { display: flex; gap: 8px; align-items: center; pointer-events: auto; }
.icon-button { width: 42px; height: 42px; border: 0; border-radius: 50%; background: var(--card); backdrop-filter: blur(8px); box-shadow: 0 6px 20px rgba(8, 24, 26, 0.18); font-size: 17px; line-height: 1; }
.streak { height: 42px; display: flex; align-items: center; gap: 6px; padding: 0 14px; border-radius: 999px; background: var(--card); backdrop-filter: blur(8px); box-shadow: 0 6px 20px rgba(8, 24, 26, 0.18); font-size: 12px; font-weight: 700; color: var(--ink-soft); }
.streak[hidden] { display: none; }
.streak b { font-size: 17px; color: var(--good); }

.speedo { position: absolute; left: 50%; bottom: max(22px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; align-items: baseline; gap: 5px; padding: 6px 16px; border-radius: 999px; background: rgba(8, 24, 26, 0.62); color: #fff; font-variant-numeric: tabular-nums; pointer-events: none; }
.speedo[hidden] { display: none; }
.speedo strong { font-size: 24px; letter-spacing: -0.02em; }
.speedo span { font-size: 12px; font-weight: 700; opacity: 0.75; }

.prompt { position: absolute; left: 50%; bottom: max(84px, calc(env(safe-area-inset-bottom) + 68px)); transform: translateX(-50%); margin: 0; padding: 10px 20px; border-radius: 999px; background: var(--card); backdrop-filter: blur(8px); font-weight: 800; box-shadow: 0 8px 24px rgba(8, 24, 26, 0.2); white-space: nowrap; pointer-events: none; max-width: calc(100% - 24px); overflow: hidden; text-overflow: ellipsis; }
.prompt[hidden] { display: none; }

.toast { position: absolute; left: 50%; top: 18%; transform: translate(-50%, -8px) scale(0.96); padding: 9px 20px; border-radius: 999px; background: var(--card); backdrop-filter: blur(8px); font-size: 20px; font-weight: 800; box-shadow: 0 10px 30px rgba(8, 24, 26, 0.2); opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.25s cubic-bezier(0.2, 0.9, 0.3, 1.4); white-space: nowrap; }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0) scale(1); }
.toast.is-bad { color: var(--bad); }
.toast.is-good { color: var(--good); }
.toast.is-warn { color: var(--accent-dark); }
.flash { position: absolute; inset: 0; pointer-events: none; background: radial-gradient(ellipse at center, transparent 45%, rgba(216, 35, 47, 0.45)); opacity: 0; transition: opacity 0.4s; }
.flash.is-on { opacity: 1; transition: none; }

.touch { position: absolute; left: 0; right: 0; bottom: max(14px, env(safe-area-inset-bottom)); display: flex; justify-content: space-between; align-items: flex-end; padding: 0 14px; pointer-events: none; }
.touch[hidden] { display: none; }
.paddle-button { pointer-events: auto; width: 96px; height: 96px; border: 0; border-radius: 50%; background: rgba(255, 255, 255, 0.72); backdrop-filter: blur(6px); box-shadow: 0 8px 22px rgba(8, 24, 26, 0.22); display: grid; place-items: center; align-content: center; gap: 2px; color: var(--ink); touch-action: none; }
.paddle-button svg { width: 42px; height: 42px; }
.paddle-button small { font-size: 11px; font-weight: 800; letter-spacing: 0.08em; opacity: 0.7; }
.paddle-button.is-down { background: #fff; transform: scale(0.94); color: var(--accent-dark); }

.panel { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(560px, calc(100% - 24px)); max-height: calc(100% - 24px); overflow-y: auto; padding: 22px 24px 20px; border-radius: 24px; background: rgba(255, 255, 255, 0.94); backdrop-filter: blur(12px); box-shadow: 0 24px 60px rgba(8, 24, 26, 0.35); }
.panel[hidden] { display: none; }
.panel--menu { left: max(12px, 4vw); transform: translateY(-50%); width: min(460px, calc(100% - 24px)); }
.panel--small { width: min(360px, calc(100% - 24px)); text-align: center; }
.panel--result { width: min(440px, calc(100% - 24px)); text-align: center; }
.eyebrow { margin: 0 0 2px; font-size: 12px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--teal); }
h1 { margin: 0; font-size: clamp(40px, 9vw, 58px); letter-spacing: -0.04em; line-height: 1; }
h1 em { font-style: normal; color: var(--accent); }
h2 { margin: 2px 0 8px; font-size: 26px; letter-spacing: -0.02em; }
h2 small { font-size: 0.5em; color: var(--ink-soft); }
#over-title { font-size: 54px; letter-spacing: -0.04em; font-variant-numeric: tabular-nums; }
.section-title { margin: 16px 0 8px; font-size: 13px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-soft); }
.panel-copy { margin: 8px 0 0; color: var(--ink-soft); line-height: 1.45; font-size: 15px; }
.boat-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.boat-swatch { display: flex; align-items: center; gap: 8px; padding: 6px 14px 6px 6px; border: 2px solid var(--line); border-radius: 999px; background: #fff; font-size: 13px; font-weight: 700; }
.boat-swatch i { width: 26px; height: 26px; border-radius: 50%; background: conic-gradient(var(--s1) 0 55%, var(--s2) 55% 80%, var(--s3) 80%); box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.1); }
.boat-swatch[aria-pressed="true"] { border-color: var(--ink); }
.menu-row { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.menu-row button { flex: 1 1 200px; }
.primary, .secondary, .ghost { min-height: 48px; padding: 10px 18px; border-radius: 14px; border: 0; font-weight: 800; font-size: 16px; }
.primary { background: var(--accent); color: #fff; box-shadow: 0 6px 0 var(--accent-dark); }
.primary small { display: block; font-size: 11px; font-weight: 700; opacity: 0.85; }
.primary:active { transform: translateY(2px); box-shadow: 0 4px 0 var(--accent-dark); }
.secondary { background: #eaf3f3; color: var(--ink); }
.ghost { background: transparent; color: var(--ink-soft); }
.keys { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; margin: 16px 0 0; font-size: 13px; }
.keys div { display: flex; gap: 8px; align-items: center; }
.keys dt { white-space: nowrap; font-size: 12px; font-weight: 700; color: var(--ink-soft); }
.keys dd { margin: 0; }
.tip { margin: 12px 0 0; padding: 8px 12px; border-radius: 12px; background: #eaf3f3; font-size: 13px; color: var(--ink-soft); }
.save-note { margin: 10px 0 0; font-size: 12px; color: var(--ink-soft); }
.panel-actions { display: grid; gap: 8px; margin-top: 14px; }
.panel-actions--row { grid-template-columns: 2fr 1fr; }
.result-note { margin: 0; color: var(--ink-soft); font-weight: 700; }
.result-note.is-record { color: var(--good); }
.points { display: grid; grid-template-columns: 1fr auto; gap: 6px 16px; margin: 14px auto 0; max-width: 300px; text-align: left; font-variant-numeric: tabular-nums; }
.points dt { color: var(--ink-soft); font-weight: 700; }
.points dd { margin: 0; text-align: right; font-weight: 800; }
.points .total { border-top: 1px solid var(--line); padding-top: 6px; font-size: 18px; color: var(--ink); }

body.is-touch .keys, body.is-touch .tip { display: none; }
@media (max-width: 600px) {
  .panel--menu { left: 50%; transform: translate(-50%, -50%); }
  .keys { grid-template-columns: 1fr; }
  .hud-title { font-size: 20px; }
  .hull { padding: 8px 10px; }
  .hull i { width: 16px; }
  .streak { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .toast, .flash { transition: none; }
  .hull.is-hit { animation: none; }
}
body.has-pad .prompt { bottom: max(128px, calc(env(safe-area-inset-bottom) + 118px)); white-space: normal; text-align: center; width: max-content; max-width: calc(100% - 40px); }
body.has-pad .speedo { bottom: max(40px, calc(env(safe-area-inset-bottom) + 30px)); }
.settings { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.settings-wide { grid-column: 1 / -1; }
/* Screen-sides mode: the buttons become faint, untouchable hints; the canvas takes the taps. */
.touch.is-ghost .paddle-button { pointer-events: none; opacity: 0.38; transform: scale(0.8); }
.paddle-button.is-down, .touch.is-ghost .paddle-button.is-down { opacity: 0.85; }
.segmented { display: flex; padding: 3px; border-radius: 12px; background: #eaf3f3; }
.seg { flex: 1; min-height: 36px; padding: 6px 8px; border: 0; border-radius: 9px; background: transparent; font-size: 13px; font-weight: 800; color: var(--ink-soft); }
.seg[aria-pressed="true"] { background: #fff; color: var(--ink); box-shadow: 0 2px 6px rgba(8, 24, 26, 0.15); }
@media (max-width: 420px) { .settings { grid-template-columns: 1fr; } }
