@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@500;700;900&family=Space+Mono:wght@700&display=swap');

:root { color-scheme: dark; font-family: "DM Sans", system-ui, sans-serif; }
* { box-sizing: border-box; }
html, body, #game { width: 100%; height: 100%; margin: 0; overflow: hidden; overscroll-behavior: none; }
body { background: #6fc0e4; }
#game { position: relative; isolation: isolate; min-height: 100dvh; background: linear-gradient(#83d1ee, #b7e9dc); touch-action: none; -webkit-user-select: none; user-select: none; }
canvas { position: absolute; inset: 0; width: 100%; height: 100%; outline: none; touch-action: none; }
.sky-glow { position: absolute; z-index: 0; width: 52vw; height: 52vw; top: -32vw; left: 24vw; border-radius: 50%; background: #fff8d1; filter: blur(70px); opacity: .45; pointer-events: none; }

.hud { position: absolute; z-index: 5; top: 0; left: 0; width: 100%; display: flex; align-items: center; justify-content: space-between; padding: 26px 34px; pointer-events: none; }
.brand { display: flex; align-items: center; gap: 11px; color: #123b42; text-decoration: none; font-size: 17px; font-weight: 900; letter-spacing: -.04em; pointer-events: auto; }
.brand em { color: #fff; font-style: normal; text-shadow: 0 2px 0 #3f857c; }
.brand-mark { width: 34px; height: 34px; display: grid; place-items: center; color: white; background: #ff6b5f; border-radius: 10px 10px 13px 9px; box-shadow: 0 4px 0 #b84d46; transform: rotate(-3deg); }
.scores { display: flex; gap: 9px; position: absolute; left: 50%; transform: translateX(-50%); }
.scores > div { min-width: 78px; padding: 8px 15px 7px; text-align: center; border: 1px solid rgba(255,255,255,.35); border-radius: 14px; background: rgba(24,70,78,.16); backdrop-filter: blur(10px); box-shadow: inset 0 1px rgba(255,255,255,.18); }
.scores span { display: block; color: rgba(20,59,66,.62); font: 700 8px/1 "Space Mono"; letter-spacing: .16em; }
.scores strong { color: #17454c; font: 900 20px/1.25 "DM Sans"; }
.scores .current { background: rgba(255,255,255,.7); border-color: rgba(255,255,255,.8); box-shadow: 0 8px 24px rgba(24,67,75,.12); transform: translateY(4px) scale(1.08); }
.hud-actions { display: flex; align-items: center; gap: 8px; pointer-events: auto; }
.sound, .fullscreen { width: 38px; height: 38px; display: grid; place-items: center; padding: 0; border: 1px solid rgba(255,255,255,.45); border-radius: 50%; color: #184850; background: rgba(255,255,255,.28); cursor: pointer; backdrop-filter: blur(8px); }
.sound { font: 900 18px serif; }
.sound[aria-pressed="false"] { opacity: .45; text-decoration: line-through; }
.fullscreen svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.fullscreen .exit-icon { display: none; }
.fullscreen.is-fullscreen .enter-icon { display: none; }
.fullscreen.is-fullscreen .exit-icon { display: block; }
#game:fullscreen, #game:-webkit-full-screen { width: 100vw; height: 100vh; min-height: 100vh; }

.start-panel, .game-over { position: absolute; z-index: 6; top: 50%; left: clamp(25px, 8vw, 120px); transform: translateY(-50%); width: min(410px, calc(100vw - 50px)); color: #153f46; transition: .45s cubic-bezier(.22,.8,.2,1); }
.start-panel.is-hidden { opacity: 0; transform: translate(-40px, -50%); pointer-events: none; }
.eyebrow { margin: 0 0 12px; color: #ff5f55; font: 700 10px/1 "Space Mono"; letter-spacing: .22em; }
h1, h2 { margin: 0; color: white; font-size: clamp(48px, 6.2vw, 88px); line-height: .84; letter-spacing: -.075em; text-shadow: 0 5px 0 rgba(35,98,98,.24); }
h1 em { color: #17464d; font-style: normal; }
.start-panel > p:not(.eyebrow) { max-width: 330px; margin: 24px 0; color: rgba(18,60,67,.7); font-size: 14px; line-height: 1.6; }
.start-panel button, .game-over button { border: 0; border-radius: 14px; padding: 16px 18px; color: white; background: #ff6258; box-shadow: 0 6px 0 #b74742, 0 14px 30px rgba(133,61,58,.24); font: 900 13px "DM Sans"; letter-spacing: .08em; cursor: pointer; transition: .15s; }
.start-panel button:hover, .game-over button:hover { transform: translateY(-2px); box-shadow: 0 8px 0 #b74742, 0 16px 30px rgba(133,61,58,.26); }
.start-panel button:active, .game-over button:active { transform: translateY(4px); box-shadow: 0 2px 0 #b74742; }
.start-panel button { min-width: 182px; display: flex; justify-content: space-between; align-items: center; }
.start-panel .skin-button, .game-over .skin-button { width: 250px; min-width: 0; min-height: 54px; margin-top: 16px; padding: 7px 9px; gap: 9px; color: #17464d; border: 1px solid rgba(255,255,255,.72); border-radius: 14px; background: rgba(238,250,238,.72); box-shadow: 0 4px 0 rgba(46,103,89,.22), 0 10px 24px rgba(34,82,76,.12); letter-spacing: 0; text-align: left; backdrop-filter: blur(10px); }
.start-panel .skin-button:hover, .game-over .skin-button:hover { transform: translateY(-1px); box-shadow: 0 5px 0 rgba(46,103,89,.22), 0 12px 26px rgba(34,82,76,.14); }
.start-panel .skin-button:active, .game-over .skin-button:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(46,103,89,.22); }
.skin-preview { width: 38px; height: 38px; flex: 0 0 38px; display: grid; place-items: center; color: #7c5414; border: 1px solid rgba(255,255,255,.75); border-radius: 11px; background: linear-gradient(145deg,#ffe177,#e6a92f); box-shadow: inset 0 1px rgba(255,255,255,.65); font-size: 20px; }
.skin-copy { min-width: 0; flex: 1; }
.skin-copy strong { display: block; color: #17464d; font: 900 10px/1.2 "DM Sans"; letter-spacing: .04em; }
.skin-copy small { display: block; margin-top: 3px; color: #718b84; font: 700 7px/1 "Space Mono"; letter-spacing: .12em; }
.skin-action { color: #b27816; font: 700 8px/1 "Space Mono"; letter-spacing: .08em; }
.skin-button.is-owned .skin-preview { color: #fff6cc; box-shadow: 0 0 18px rgba(255,202,65,.35), inset 0 1px rgba(255,255,255,.65); }
.skin-button.is-equipped { border-color: rgba(255,205,76,.8); background: rgba(255,246,206,.84); }
.skin-button.is-equipped .skin-action { color: #4d7c62; }
.game-over .skin-button { margin: 18px auto 0; }
kbd { padding: 4px 8px; color: #963c38; border-radius: 6px; background: rgba(255,255,255,.85); font: 700 8px "Space Mono"; }
.how-to { display: flex; gap: 18px; margin-top: 28px; color: rgba(17,58,64,.55); font-size: 9px; font-weight: 900; letter-spacing: .06em; text-transform: uppercase; }
.how-to span { display: flex; align-items: center; gap: 4px; }
.how-to i { width: 20px; height: 20px; display: grid; place-items: center; color: #214f55; border: 1px solid rgba(31,78,83,.22); border-radius: 5px; background: rgba(255,255,255,.33); font-style: normal; }
.mobile-how-to { display: none; }

.game-over { left: 50%; width: min(390px, calc(100vw - 42px)); padding: 34px; text-align: center; transform: translate(-50%, -50%); border: 1px solid rgba(255,255,255,.5); border-radius: 28px; background: rgba(232,250,241,.88); box-shadow: 0 26px 80px rgba(26,71,73,.25), inset 0 1px white; backdrop-filter: blur(18px); }
.game-over[hidden] { display: none; }
.game-over h2 { color: #17464d; font-size: 42px; text-shadow: none; }
.result-score { margin: 24px 0 5px; }
.result-score strong { display: block; color: #ff6158; font-size: 76px; line-height: .8; letter-spacing: -.07em; }
.result-score span { color: #6a8886; font: 700 9px "Space Mono"; letter-spacing: .2em; }
.game-over > p:not(.eyebrow) { margin: 16px 0 24px; color: #627e7d; font-size: 12px; }

.toast { position: absolute; z-index: 5; top: 29%; left: 50%; opacity: 0; transform: translate(-50%, 16px) scale(.9); color: white; font: 900 30px "DM Sans"; text-shadow: 0 3px 0 rgba(27,74,76,.25); pointer-events: none; transition: .2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0) scale(1); }
.warning { position: absolute; z-index: 5; top: 114px; left: 50%; opacity: 0; transform: translateX(-50%); color: #ff5f55; text-align: center; text-shadow: 0 2px 0 rgba(103,32,29,.18); font: 900 16px/1 "Space Mono"; letter-spacing: .18em; transition: opacity .2s; }
.warning.show { opacity: 1; }
.warning i { display: block; width: 132px; height: 6px; margin: 11px auto 0; overflow: hidden; border: 1px solid rgba(255,255,255,.22); border-radius: 9px; background: rgba(91,41,39,.25); }
.warning i::after { content: ""; display: block; width: 100%; height: 100%; transform: scaleX(var(--danger, 0)); transform-origin: left center; border-radius: inherit; background: #ff5f55; will-change: transform; }
.idle-danger { position: absolute; z-index: 4; inset: 0; opacity: 0; pointer-events: none; border: 9px solid rgba(255,72,64,.92); contain: strict; transform: translateZ(0); will-change: opacity; transition: opacity .18s ease-out; }
.idle-danger::before { content: ""; position: absolute; inset: 0; border: 18px solid rgba(255,72,64,.16); }
.idle-danger.show { animation: danger-pulse .72s ease-in-out infinite alternate; }
@keyframes danger-pulse {
  from { opacity: .32; }
  to { opacity: .68; }
}
@media (prefers-reduced-motion: reduce) { .idle-danger.show { animation-duration: 1.25s; } }

.swipe-coach { position: absolute; z-index: 7; left: 50%; bottom: max(18px, calc(env(safe-area-inset-bottom) + 14px)); opacity: 0; transform: translate(-50%, 12px); padding: 9px 13px; color: rgba(255,255,255,.92); border: 1px solid rgba(255,255,255,.3); border-radius: 999px; background: rgba(20,61,68,.38); font: 700 8px/1 "Space Mono"; letter-spacing: .12em; white-space: nowrap; pointer-events: none; backdrop-filter: blur(9px); transition: opacity .25s, transform .25s; }
.swipe-coach span { color: #ffdb76; }
.swipe-coach.show { opacity: 1; transform: translate(-50%, 0); }
footer { position: absolute; z-index: 4; bottom: 22px; left: 34px; right: 34px; display: flex; justify-content: space-between; color: rgba(20,60,67,.48); font: 700 8px "Space Mono"; letter-spacing: .15em; pointer-events: none; }

@media (max-width: 720px), (pointer: coarse) {
  .hud { padding: max(12px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 12px max(14px, env(safe-area-inset-left)); }
  .brand > span:last-child { display: none; }
  .scores { top: 14px; gap: 4px; }
  .scores > div { min-width: 58px; padding: 7px 8px; border-radius: 11px; }
  .scores strong { font-size: 16px; }
  .scores .current { transform: translateY(2px); }
  .start-panel { top: max(112px, calc(env(safe-area-inset-top) + 92px)); left: max(20px, env(safe-area-inset-left)); width: min(410px, calc(100vw - max(40px, env(safe-area-inset-left) + env(safe-area-inset-right) + 24px))); transform: none; }
  .start-panel.is-hidden { transform: translateX(-30px); }
  h1 { font-size: clamp(45px, 15vw, 68px); }
  .how-to { display: none; }
  .mobile-how-to { display: flex; align-items: center; gap: 10px; margin-top: 22px; color: rgba(17,58,64,.62); }
  .mobile-how-to .swipe-symbol { width: 34px; height: 34px; display: grid; place-items: center; color: #fff; border: 1px solid rgba(255,255,255,.45); border-radius: 11px; background: rgba(19,65,71,.28); font-size: 21px; box-shadow: inset 0 1px rgba(255,255,255,.2); }
  .mobile-how-to strong, .mobile-how-to small { display: block; }
  .mobile-how-to strong { font: 900 10px/1.3 "DM Sans"; letter-spacing: .08em; }
  .mobile-how-to small { margin-top: 3px; color: rgba(17,58,64,.43); font: 700 7px/1 "Space Mono"; letter-spacing: .1em; }
  #playButton { justify-content: center; }
  #playButton kbd { display: none; }
  .start-panel .skin-button { margin-top: 13px; }
  footer { display: none; }
  .warning { top: 76px; }
  .game-over { width: min(390px, calc(100vw - max(28px, env(safe-area-inset-left) + env(safe-area-inset-right) + 20px))); padding: 26px 22px; }
}

@media (max-height: 690px) and (pointer: coarse) {
  .start-panel { top: max(88px, calc(env(safe-area-inset-top) + 70px)); }
  h1 { font-size: clamp(39px, 12vw, 54px); }
  .start-panel > p:not(.eyebrow) { margin: 14px 0; line-height: 1.4; }
  .mobile-how-to { margin-top: 16px; }
  .game-over { padding-top: 20px; padding-bottom: 20px; }
  .result-score { margin-top: 16px; }
  .game-over > p:not(.eyebrow) { margin: 12px 0 18px; }
}

@media (max-width: 480px) {
  .hud-actions { flex-direction: column-reverse; gap: 6px; }
}
