:root {
  color-scheme: dark;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --outline: #101a18;
  --cream: #fffef0;
  --red: #f01810;
}

* { box-sizing: border-box; }

html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: #091d29; }
body { display: grid; place-items: center; }
button { font: inherit; }

#game-shell {
  position: relative;
  width: min(100vw, 177.7778vh);
  height: min(100vh, 56.25vw);
  overflow: hidden;
  isolation: isolate;
  container-type: size;
  background: #13c9ee;
  color: var(--cream);
  box-shadow: 0 18px 56px rgba(2, 28, 49, .3);
}

#game-canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }
.screen { position: absolute; z-index: 3; inset: 0; }
.screen[hidden], .hud[hidden], .touch-pad[hidden], .pause-button[hidden] { display: none; }

.menu-screen { text-align: center; }
#game-title {
  position: absolute;
  top: 11.7%;
  left: 4%;
  width: 92%;
  margin: 0;
  font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  font-size: clamp(52px, 9.4cqw, 126px);
  font-weight: 900;
  line-height: .9;
  letter-spacing: -.035em;
  text-transform: uppercase;
  filter: drop-shadow(0 6px 0 rgba(24, 34, 17, .38));
}
.title-aircraft, .title-super { display: block; paint-order: stroke fill; }
.title-aircraft {
  color: #5b930b;
  -webkit-text-stroke: 5px #15200c;
  text-shadow: 2px 3px 0 #25420c, 0 -2px 0 rgba(193, 237, 60, .85);
}
.title-super {
  margin-top: .04em;
  font-size: .86em;
  color: #f22b0f;
  -webkit-text-stroke: 5px #111a18;
  text-shadow: 2px 3px 0 #6b180e, 0 -2px 0 #fff6d6;
}

.button-stack {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
}
.menu-button {
  position: absolute;
  left: 50%;
  display: flex;
  width: min(252px, 38%);
  min-width: 0;
  height: 59px;
  min-height: 59px;
  align-items: center;
  justify-content: center;
  padding: 0;
  white-space: nowrap;
  border: 0;
  background: transparent;
  color: var(--red);
  cursor: pointer;
  font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  font-size: clamp(29px, 3.7cqw, 45px);
  font-style: italic;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -.015em;
  text-transform: uppercase;
  -webkit-text-stroke: 1.4px #fff;
  text-shadow: 2px 3px 0 #111, -1px -1px 0 #111, 1px -1px 0 #111, -1px 1px 0 #111;
  transform: translateX(-50%);
  transition: transform .14s ease, filter .14s ease;
}
.menu-button:nth-child(1) { top: 44.5%; }
.menu-button:nth-child(2) { top: 55.5%; }
.menu-button:nth-child(3) { top: 66.5%; }
.menu-button[data-action="sound"] span { margin-left: .22em; }
.menu-button:hover { transform: translateX(-50%) scale(1.08) rotate(-1deg); filter: brightness(1.12); }
.menu-button:active { transform: translateX(-50%) scale(.96) translateY(2px); }
.custom-mode-button { font-size: clamp(15px, 2.5cqw, 28px); -webkit-text-stroke-width: .7px; }
.menu-button:focus-visible, .button:focus-visible, .pause-button:focus-visible, .touch-pad button:focus-visible {
  outline: 3px solid #fff6b3;
  outline-offset: 4px;
}
.menu-button:focus-visible {
  z-index: 1;
  border: 3px solid #ffd735;
  border-radius: 7px;
  background: linear-gradient(180deg, #17546a 0%, #0a344b 100%);
  color: #fff4bd;
  -webkit-text-stroke: 1px #361b12;
  text-shadow: 0 2px 0 #351b12, 0 0 8px rgba(255, 226, 105, .5);
  outline: 3px solid #fff8df;
  outline-offset: 4px;
  box-shadow: 0 0 0 8px rgba(7, 28, 42, .94), 0 0 0 12px rgba(255, 205, 39, .96), 0 9px 0 #152a2d, 0 0 28px 10px rgba(255, 209, 47, .55);
  transform: translateX(-50%) scale(1.06);
  filter: none;
}
.best-score {
  position: absolute;
  bottom: 9.3%;
  left: 0;
  width: 100%;
  color: #8f4b16;
  font-family: "Courier New", monospace;
  font-size: clamp(20px, 2.65cqw, 32px);
  font-weight: 900;
  letter-spacing: .18em;
  text-shadow: 1px 2px 0 #fff7d9, -1px -1px 0 #fff7d9, 2px 3px 0 rgba(67, 44, 22, .6);
  text-transform: uppercase;
}
.best-score strong { margin-left: .65em; }

.tutorial-screen { overflow: hidden; background: transparent; color: #f4f5ef; }
.tutorial-screen h2 {
  position: absolute;
  top: 8%;
  left: 0;
  width: 100%;
  margin: 0;
  font-family: "Courier New", monospace;
  font-size: clamp(17px, 2.35cqw, 30px);
  font-weight: 700;
  letter-spacing: .34em;
  text-align: center;
  text-transform: uppercase;
}
.tutorial-screen p {
  position: absolute;
  margin: 0;
  font-family: "Courier New", monospace;
  font-size: clamp(11px, 1.7cqw, 22px);
  font-weight: 700;
  letter-spacing: .17em;
  line-height: 1.12;
  text-transform: uppercase;
}
.tutorial-move { top: 22%; left: 30%; width: 40%; }
.tutorial-gold { top: 58%; left: 19%; width: 52%; }
.tutorial-shoot { top: 79%; left: 10%; width: 37%; }
.tutorial-skip-hint { right: 1.5%; bottom: 2%; color: rgba(245, 246, 239, .48); font-size: clamp(9px, 1.05cqw, 13px) !important; letter-spacing: .06em !important; text-transform: uppercase !important; }

.dialog-screen { display: grid; place-items: center; padding: 30px; background: rgba(7, 31, 42, .64); backdrop-filter: blur(4px); }
.dialog-card {
  width: min(500px, 100%);
  padding: 30px 34px 26px;
  border: 2px solid rgba(255, 255, 255, .84);
  border-radius: 8px;
  background: rgba(18, 44, 54, .94);
  box-shadow: 0 12px 0 rgba(20, 39, 35, .28);
  color: #fffef0;
}
.eyebrow { margin: 0 0 9px; color: #ffe06a; font-size: 11px; font-weight: 900; letter-spacing: .18em; text-transform: uppercase; }
h2, p { margin-top: 0; }
.dialog-card h2 { margin-bottom: 12px; font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif; font-size: clamp(34px, 5cqw, 54px); line-height: .96; text-transform: uppercase; }
.dialog-card > p:not(.eyebrow) { color: #e0f1e8; font-size: 14px; line-height: 1.6; }
.button { min-height: 40px; padding: 9px 15px; border: 2px solid #fff8d6; border-radius: 5px; background: #ffe16b; color: #182f30; cursor: pointer; font-size: 13px; font-weight: 900; letter-spacing: .035em; text-align: center; transition: transform .14s ease, background .14s ease; }
.button:hover { transform: translateY(-1px); background: #fff0a2; }
.button:active { transform: translateY(2px) scale(.98); }
.button-quiet { border-color: rgba(255, 255, 255, .6); background: transparent; color: #fffef0; }
.dialog-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 10px; margin-top: 24px; }
.dialog-actions .button { min-width: 108px; }
.settings-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 12px 0; border-top: 1px solid rgba(233, 247, 236, .2); font-size: 14px; font-weight: 800; }
.toggle-button { min-width: 82px !important; }
.compact-card { text-align: center; }
.compact-card .dialog-actions { justify-content: center; }
.result-score { margin: 25px 0 5px; color: #d7eeee !important; font-size: 14px !important; letter-spacing: .08em; text-transform: uppercase; }
.result-score strong { display: block; color: #ffe16b; font-family: Impact, Haettenschweiler, sans-serif; font-size: 56px; line-height: 1.1; }
.result-best { margin-bottom: 10px; }

.hud { position: absolute; z-index: 2; inset: 14px 28px auto; display: flex; align-items: flex-start; gap: 27px; pointer-events: none; }
.health-frame, .gold-frame { display: flex; height: 66px; align-items: center; gap: 5px; padding: 5px; border: 4px solid #a64c08; border-radius: 9px; background: #f29a19; box-shadow: inset 0 0 0 2px #ffd041, 0 3px 0 rgba(100, 43, 3, .42); }
.health-heart, .coin-mark { display: grid; width: 54px; height: 54px; flex: 0 0 54px; place-items: center; border: 4px solid #9dd509; border-radius: 9px; background: #63ad09; box-shadow: inset 0 0 0 2px #285400; }
.health-heart svg { width: 42px; height: 42px; filter: drop-shadow(1px 3px 0 #761d11); }
.health-meter { display: flex; min-width: 120px; height: 38px; align-items: center; gap: 3px; padding: 4px; border: 4px solid #743708; border-radius: 6px; background: #502500; }
.health-meter span { height: 23px; min-width: 0; flex: 1; border-radius: 4px; background: linear-gradient(180deg, #ffdb28, #ff9509 62%, #e35b08); box-shadow: inset 0 2px 0 rgba(255, 247, 129, .7); }
.health-meter span.empty { background: #653509; box-shadow: none; }
.mode-label { position: absolute; top: 58px; left: 50%; padding: 5px 10px; border: 1px solid rgba(255,255,255,.7); border-radius: 99px; background: rgba(25, 47, 52, .72); color: #fff; font: 700 12px/1.1 "Trebuchet MS", sans-serif; letter-spacing: .08em; text-transform: uppercase; transform: translateX(-50%); }
.mode-label[hidden] { display: none; }
.gold-frame { min-width: 197px; }
.coin-mark { color: #ffed36; font-size: 29px; line-height: 1; text-shadow: 1px 2px 0 #9d6200; background: linear-gradient(145deg, #fffca4 0%, #ffc50a 45%, #ff7f08 100%); }
.coin-mark svg { width: 43px; height: 43px; filter: drop-shadow(1px 2px 0 #9d6200); }
.score-readout { display: flex; min-width: 112px; flex: 1; flex-direction: column; align-items: center; justify-content: center; gap: 1px; }
.score-label { color: #fff2bd; font-size: 9px; font-weight: 900; line-height: 1; letter-spacing: .12em; text-shadow: 0 1px 2px #4b260d; text-transform: uppercase; }
.gold-frame strong { display: grid; width: 100%; min-width: 112px; height: 31px; place-items: center; border: 3px solid #733708; border-radius: 6px; background: #5a2a08; color: #fff2bd; font-family: "Courier New", monospace; font-size: 20px; line-height: 1; }
.pause-button { width: 42px; height: 42px; margin-left: auto; border: 2px solid #f8ecb9; border-radius: 6px; background: rgba(33, 57, 54, .82); color: #fff9d4; cursor: pointer; font-size: 16px; font-weight: 900; pointer-events: auto; }

.touch-pad { position: absolute; z-index: 2; right: 22px; bottom: 20px; display: none; grid-template: repeat(2, 46px) / repeat(3, 46px); gap: 5px; }
.touch-pad button { border: 2px solid rgba(255, 255, 255, .88); border-radius: 7px; background: rgba(27, 79, 77, .78); color: white; font-size: 15px; font-weight: 900; touch-action: none; }
.touch-pad button[data-direction="up"] { grid-column: 2; grid-row: 1; }
.touch-pad button[data-direction="left"] { grid-column: 1; grid-row: 2; }
.touch-pad button[data-direction="down"] { grid-column: 2; grid-row: 2; }
.touch-pad button[data-direction="right"] { grid-column: 3; grid-row: 2; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; clip-path: inset(50%); border: 0; }

#whale-player { position: fixed; inset: 0; z-index: 10000; width: 100vw; height: 100vh; min-width: 100vw; background: #000; }
#whale-player[hidden] { display: none; }
#whale-player.is-active { display: block; }

@media (pointer: coarse), (max-width: 760px) {
  .touch-pad { display: grid; }
  .hud { inset: 6px 7px auto; gap: 5px; }
  .health-frame, .gold-frame { height: 45px; gap: 3px; padding: 2px; border-width: 2px; border-radius: 5px; }
  .health-heart, .coin-mark { width: 35px; height: 35px; flex-basis: 35px; border-width: 2px; border-radius: 5px; }
  .health-heart svg { width: 28px; height: 28px; }
  .health-meter { min-width: 77px; height: 30px; gap: 2px; padding: 3px; border-width: 2px; }
  .health-meter span { height: 18px; }
  .gold-frame { min-width: 100px; }
  .coin-mark { font-size: 18px; }
  .coin-mark svg { width: 29px; height: 29px; }
  .gold-frame strong { min-width: 52px; height: 29px; border-width: 2px; font-size: 15px; }
  .pause-button { width: 34px; height: 34px; }
  .menu-button { width: min(252px, 52%); height: 40px; min-height: 40px; font-size: clamp(18px, 5.2cqw, 32px); }
  #game-title { font-size: clamp(38px, 9.6cqw, 72px); -webkit-text-stroke-width: 0; }
  .title-aircraft { -webkit-text-stroke: 3px #15200c; }
  .title-super { -webkit-text-stroke: 3px #111a18; }
  .best-score { bottom: 5%; font-size: clamp(16px, 3.5cqw, 24px); }
  .dialog-screen { padding: 12px; }
  .dialog-card { padding: 18px 18px 15px; }
  .dialog-card h2 { font-size: 34px; }
  .dialog-card > p:not(.eyebrow) { font-size: 12px; }
  .button { min-height: 34px; padding: 7px 10px; font-size: 11px; }
  .tutorial-screen p { font-size: clamp(9px, 1.65cqw, 13px); letter-spacing: .08em; }
  .tutorial-screen h2 { font-size: clamp(13px, 2.2cqw, 19px); letter-spacing: .2em; }
  .tutorial-move { left: 30%; width: 44%; }
  .tutorial-gold { left: 18%; width: 60%; }
  .tutorial-shoot { left: 8%; width: 39%; }
  .tutorial-skip-hint { font-size: 8px !important; }
  .touch-pad { right: 12px; bottom: 12px; grid-template: repeat(2, 36px) / repeat(3, 36px); gap: 4px; }
}

@media (orientation: portrait) and (max-width: 760px) {
  #game-shell {
    position: absolute;
    top: 50%;
    left: 50%;
    width: min(100vh, 177.7778vw);
    height: min(100vw, 56.25vh);
    transform: translate(-50%, -50%) rotate(90deg);
  }
  .touch-pad { grid-template: repeat(2, 68px) / repeat(3, 68px); gap: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
