@font-face { font-family: 'Bevan'; font-style: normal; font-weight: 400; font-display: swap; src: url(fonts/font_bevan_00a499c30e510288.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Nunito Sans'; font-style: normal; font-weight: 200 1000; font-stretch: 100%; font-display: swap; src: url(fonts/font_nunito_sans_16838be1ea215296.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Chivo Mono'; font-style: normal; font-weight: 100 900; font-display: swap; src: url(fonts/font_chivo_mono_43c0ef85ef5d8e44.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  --night: #0a1618;
  --deep: #12362f;
  --reed: #2f6b4f;
  --mist: #8fc0ae;
  --butter: #ffd27d;
  --ember: #ff8f2e;
  --warning: #e0442c;
  --cream: #f3ecdc;
  --display: 'Bevan', Georgia, serif;
  --body: 'Nunito Sans', system-ui, sans-serif;
  --mono: 'Chivo Mono', 'Courier New', monospace;
  --pad-x: max(12px, 2.4vw);
  --pad-y: max(10px, 2vh);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--night);
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  font-family: var(--body);
  color: var(--cream);
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

#app { position: fixed; inset: 0; overflow: hidden; background: var(--night); }

#game { position: absolute; inset: 0; }
#game canvas { display: block; }

/* ---------- HUD ---------- */
#hud {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

#brand {
  position: absolute;
  left: var(--pad-x);
  top: var(--pad-y);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}
#gameTitle {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(20px, 5.2vh, 62px);
  line-height: 0.99;
  letter-spacing: 0.045em;
  text-transform: uppercase;
  color: var(--cream);
  white-space: nowrap;
  pointer-events: none;
}
#gameTitle .brk { display: none; }
#titleRule {
  display: block;
  width: 100%;
  min-width: 60px;
  height: clamp(2px, 0.45vh, 5px);
  background: var(--ember);
  border-radius: 3px;
  opacity: 0.92;
  transform-origin: left center;
}

#scoreWrap {
  position: absolute;
  right: var(--pad-x);
  top: var(--pad-y);
  display: flex;
  align-items: center;
  gap: clamp(6px, 1.2vw, 14px);
}
#scoreIcon { display: block; height: clamp(26px, 5.6vh, 50px); width: auto; }
#scoreText {
  font-family: var(--mono);
  font-weight: 700;
  font-size: clamp(20px, 4.5vh, 42px);
  letter-spacing: 0.09em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  color: var(--cream);
  text-shadow: 0 0 1px rgba(10, 22, 24, 0.6);
}
#scoreText.bump { animation: scoreBump 200ms ease-out; }

#lives {
  position: absolute;
  left: var(--pad-x);
  bottom: calc(var(--pad-y) + env(safe-area-inset-bottom));
  display: flex;
  align-items: flex-end;
  gap: clamp(4px, 1vw, 10px);
  height: clamp(26px, 5vh, 44px);
}
.life {
  display: block;
  height: 100%;
  width: auto;
  transition: opacity 300ms ease, transform 300ms ease, filter 300ms ease;
}
.life.lost { opacity: 0.2; filter: grayscale(1) brightness(0.75); transform: translateY(2px) scale(0.92); }
.life.pop { animation: lifePop 320ms ease-out; }

#buttons {
  position: absolute;
  right: var(--pad-x);
  bottom: calc(var(--pad-y) + env(safe-area-inset-bottom));
  display: flex;
  align-items: flex-end;
  gap: clamp(2px, 1.4vw, 14px);
  pointer-events: auto;
}
.iconBtn {
  -webkit-appearance: none;
  appearance: none;
  border: 0;
  background: none;
  padding: 0;
  margin: 0;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--cream);
  opacity: 0.92;
  transition: opacity 140ms ease, transform 140ms ease;
  -webkit-tap-highlight-color: transparent;
}
.iconBtn img { display: block; width: auto; pointer-events: none; }
.iconBtn:hover { opacity: 1; }
.iconBtn:active { transform: scale(0.94); }
.iconBtn:focus-visible { outline: 2px solid var(--butter); outline-offset: 2px; border-radius: 6px; }
.iconBtn[disabled] { opacity: 0.35; }
.pauseMark { display: flex; gap: 14%; height: clamp(22px, 4.4vh, 38px); }
.pauseMark img { height: 100%; width: auto; }
.soundMark { display: flex; align-items: center; height: clamp(22px, 4.4vh, 38px); }
.soundMark img.speaker { height: 82%; width: auto; }
.soundMark img.waves { height: 100%; width: auto; margin-left: -8%; }
.iconBtn img.solo { height: clamp(22px, 4.4vh, 38px); width: auto; }

#restartHint {
  position: absolute;
  left: 50%;
  top: 47%;
  transform: translate(-50%, -50%);
  font-family: var(--body);
  font-weight: 700;
  font-size: clamp(10px, 1.6vh, 14px);
  letter-spacing: 0.16em;
  color: var(--butter);
  opacity: 0;
  transition: opacity 160ms ease;
  text-align: center;
  white-space: nowrap;
  pointer-events: none;
}
#restartHint.show { opacity: 0.9; }

#hint {
  position: absolute;
  left: 50%;
  bottom: calc(var(--pad-y) + env(safe-area-inset-bottom) + 50px);
  transform: translateX(-50%);
  width: min(64vw, 600px);
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 0;
  font-size: clamp(10px, 1.7vh, 13px);
  font-weight: 400;
  line-height: 1.45;
  letter-spacing: 0.015em;
  color: rgba(243, 236, 220, 0.58);
  text-align: center;
  text-wrap: balance;
  pointer-events: none;
}
#hint .touchOnly { display: none; }
body.is-touch #hint .touchOnly { display: inline; }
body.is-touch #hint .mouseOnly { display: none; }
body.is-touch #hint { width: min(78vw, 480px); bottom: calc(var(--pad-y) + env(safe-area-inset-bottom) + 50px); }

#wave {
  position: absolute;
  left: 50%;
  top: 34%;
  transform: translate(-50%, -50%);
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(30px, 7.4vh, 84px);
  letter-spacing: 0.045em;
  color: var(--mist);
  opacity: 0;
  white-space: nowrap;
  pointer-events: none;
  text-shadow: 0 2px 0 rgba(10, 22, 24, 0.25);
  transition: opacity 520ms ease, letter-spacing 900ms ease;
}
#wave.show { opacity: 0.92; letter-spacing: 0.075em; }

/* ---------- overlays ---------- */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 9;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: rgba(8, 18, 20, 0.48);
  opacity: 1;
  transition: opacity 420ms ease;
  padding: calc(var(--pad-y) + 70px) var(--pad-x) calc(var(--pad-y) + 60px);
}
.overlay.hidden { opacity: 0; pointer-events: none; }
.overlayInner { display: flex; flex-direction: column; align-items: center; max-width: 640px; }

.kicker {
  margin: 0 0 clamp(10px, 1.8vh, 20px);
  font-family: var(--body);
  font-weight: 700;
  font-size: clamp(10px, 1.6vh, 14px);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--mist);
  opacity: 0.9;
}

.textBtn {
  -webkit-appearance: none;
  appearance: none;
  border: 0;
  background: none;
  padding: 4px 10px 10px;
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(42px, 8.6vh, 96px);
  line-height: 1;
  letter-spacing: 0.055em;
  color: var(--cream);
  cursor: pointer;
  position: relative;
  -webkit-tap-highlight-color: transparent;
  transition: transform 160ms ease, color 160ms ease;
}
.textBtn::after {
  content: '';
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: 2px;
  height: clamp(3px, 0.5vh, 6px);
  background: var(--ember);
  border-radius: 3px;
  transform: scaleX(0.82);
  transform-origin: center;
  transition: transform 200ms ease, opacity 200ms ease;
  opacity: 0.95;
}
.textBtn:hover { transform: translateY(-2px); }
.textBtn:hover::after, .textBtn:focus-visible::after { transform: scaleX(1); }
.textBtn:focus-visible { outline: 2px solid var(--butter); outline-offset: 4px; border-radius: 8px; }
.textBtn:active { transform: scale(0.97); }
.textBtn[disabled] { opacity: 0.3; cursor: default; transform: none; }

.controls {
  margin: clamp(14px, 2.6vh, 30px) 0 0;
  font-family: var(--body);
  font-weight: 400;
  font-size: clamp(12px, 1.9vh, 16px);
  line-height: 1.65;
  color: rgba(243, 236, 220, 0.82);
}
.controls b { font-weight: 700; color: var(--cream); }
.controls .touchOnly { display: none; }
body.is-touch .controls .touchOnly { display: inline; }
body.is-touch .controls .mouseOnly { display: none; }

.bestLine {
  margin: clamp(8px, 1.6vh, 16px) 0 0;
  font-family: var(--mono);
  font-size: clamp(12px, 1.9vh, 16px);
  letter-spacing: 0.12em;
  color: rgba(243, 236, 220, 0.62);
}
.bestLine:empty { display: none; }

#overTitle {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(30px, 6.2vh, 72px);
  line-height: 1.02;
  letter-spacing: 0.035em;
  color: var(--cream);
  max-width: 12ch;
}
#overScore {
  margin: clamp(14px, 2.4vh, 26px) 0 0;
  font-family: var(--mono);
  font-weight: 700;
  font-size: clamp(26px, 4.6vh, 44px);
  letter-spacing: 0.16em;
  color: var(--butter);
}
#overBest {
  margin: 8px 0 0;
  font-family: var(--mono);
  font-size: clamp(11px, 1.7vh, 15px);
  letter-spacing: 0.14em;
  color: rgba(243, 236, 220, 0.6);
}
#overScreen .textBtn { font-size: clamp(30px, 5.6vh, 58px); margin-top: clamp(18px, 3vh, 34px); }

#pauseScreen { background: rgba(8, 18, 20, 0.66); }
#pauseScreen .textBtn { font-size: clamp(30px, 5.6vh, 58px); }
#pauseTitle {
  margin: 0 0 clamp(8px, 1.6vh, 18px);
  font-family: var(--display);
  font-size: clamp(40px, 8vh, 92px);
  letter-spacing: 0.06em;
  color: var(--mist);
}

/* ---------- danger edge ---------- */
#danger {
  position: absolute;
  inset: 0;
  z-index: 7;
  pointer-events: none;
  box-shadow: inset 0 0 0 0 rgba(224, 68, 44, 0);
}
#danger.flash { animation: dangerFlash 280ms ease-out; }

@keyframes dangerFlash {
  0% { box-shadow: inset 0 0 min(22vw, 150px) min(9vw, 60px) rgba(224, 68, 44, 0.62); }
  100% { box-shadow: inset 0 0 min(22vw, 150px) min(9vw, 60px) rgba(224, 68, 44, 0); }
}
@keyframes scoreBump {
  0% { transform: scale(1); }
  40% { transform: scale(1.09); color: var(--butter); }
  100% { transform: scale(1); }
}
@keyframes lifePop {
  0% { transform: scale(1); }
  45% { transform: scale(1.22); }
  100% { transform: scale(1); }
}

.hidden { opacity: 0; pointer-events: none; }

@media (max-aspect-ratio: 21/20) {
  #gameTitle { font-size: clamp(20px, 7vw, 44px); white-space: normal; }
  #gameTitle .brk { display: inline; }
  #brand { max-width: 62vw; }
}

@media (max-height: 430px) {
  #gameTitle { font-size: clamp(16px, 5.6vh, 30px); }
  #hint { display: none; }
  .overlay { padding-top: 50px; padding-bottom: 40px; }
}

@media (prefers-reduced-motion: reduce) {
  #wave { transition: opacity 200ms linear; letter-spacing: 0.045em; }
  .textBtn, .iconBtn, .life { transition: none; }
}
