:root {
  --ink: #07152d;
  --navy: #09264e;
  --blue: #0874d1;
  --cyan: #1bb8f0;
  --cream: #fff8dc;
  --yellow: #ffc928;
  --red: #ef3340;
  --green: #158341;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: #087ab8; }
body {
  color: var(--cream);
  font-family: "Arial Black", Impact, system-ui, sans-serif;
  touch-action: pinch-zoom;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
}
button, a { font: inherit; }
button:focus-visible, a:focus-visible, canvas:focus-visible { outline: 5px solid #fff231; outline-offset: 4px; }
.game { position: fixed; inset: 0; min-width: 280px; overflow: hidden; background: #20a9e7; touch-action: pinch-zoom; isolation: isolate; }
.game::after {
  position: absolute; z-index: 30; inset: 0; content: ""; pointer-events: none;
  opacity: .075; mix-blend-mode: multiply;
  background: repeating-linear-gradient(0deg, transparent 0 3px, #001126 4px);
}
canvas { position: absolute; z-index: 3; inset: 0; width: 100%; height: 100%; display: block; image-rendering: pixelated; touch-action: pinch-zoom; }
#entity-canvas { z-index: 6; pointer-events: none; }

.pixel-panel {
  color: #fff; background: var(--navy); border: 4px solid #f8f6e8;
  outline: 4px solid var(--ink); box-shadow: inset 0 0 0 3px #168ac8, 7px 7px 0 rgba(4, 16, 37, .9);
}
.hotel-lockup {
  position: absolute; z-index: 5; top: max(13px, env(safe-area-inset-top)); right: max(18px, env(safe-area-inset-right));
  width: min(34vw, 440px); text-align: center; color: #fff7dd; pointer-events: none;
  filter: drop-shadow(5px 6px 0 var(--ink)); transform: rotate(.5deg);
}
.hotel-lockup b { display: block; font: 900 clamp(24px, 4.2vw, 62px)/.82 Impact, "Arial Black", sans-serif; letter-spacing: .025em; -webkit-text-stroke: 2px var(--ink); }
.hotel-lockup span { display: inline-block; margin-top: 6px; padding: 0 1.2em; font: 900 clamp(12px, 1.8vw, 25px)/1 Arial, sans-serif; letter-spacing: .32em; color: #fff; text-shadow: 3px 3px var(--ink); border-bottom: 4px solid #fff; }
.scene-sign { position: absolute; z-index: 2; pointer-events: none; text-align: center; text-transform: uppercase; transform: rotate(-2deg); }
.scene-sign--plett { left: 1.8%; top: 51%; width: clamp(68px, 9vw, 126px); padding: 8px 5px; color: #231814; background: #bf7a3a; border: 4px solid #2d1c19; box-shadow: inset 0 0 0 3px #e4a658, 5px 5px #07152d; }
.scene-sign--plett span { display: block; color: #fff2cf; font-size: clamp(9px, 1vw, 14px); letter-spacing: .12em; }
.scene-sign--plett b { font: 900 clamp(11px, 1.3vw, 18px)/.9 Arial, sans-serif; }
.scene-sign--chips { right: 1.2%; top: 64%; width: clamp(88px, 11vw, 156px); padding: 10px 6px; color: #fff6cb; background: #101b2d; border: 4px solid #6f4931; box-shadow: 5px 5px #07152d; transform: rotate(2deg); }
.scene-sign--chips b, .scene-sign--chips span { display: block; font: 900 clamp(9px, 1vw, 14px)/1.05 Arial, sans-serif; }
.scene-sign--chips span { margin-top: 5px; color: #51dbea; font-size: clamp(7px, .75vw, 11px); }
.chip-warning { position: absolute; z-index: 13; left: 65%; top: 62%; padding: 9px 12px; color: #fff; background: var(--red); border: 4px solid #fff; outline: 4px solid var(--ink); text-align: center; font-size: clamp(15px, 2.2vw, 28px); line-height: .82; text-shadow: 3px 3px var(--ink); opacity: 0; transform: translateY(15px) rotate(-5deg) scale(.7); pointer-events: none; }
.chip-warning.show { animation: chip-warning .7s steps(4, end); }
@keyframes chip-warning { 0% { opacity: 0; transform: translateY(18px) rotate(-5deg) scale(.65); } 18%, 72% { opacity: 1; transform: translateY(0) rotate(3deg) scale(1); } 100% { opacity: 0; transform: translateY(-18px) rotate(-3deg) scale(.9); } }

.hud { position: absolute; z-index: 9; inset: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) auto max(12px, env(safe-area-inset-left)); pointer-events: none; }
.chip-panel { position: absolute; left: 0; top: 0; width: clamp(210px, 29vw, 355px); min-height: 92px; padding: 10px 12px 8px 92px; }
.chip-panel strong { display: block; margin-top: 4px; font-size: clamp(17px, 2.1vw, 27px); line-height: 1; letter-spacing: .04em; text-shadow: 3px 3px #000; white-space: nowrap; }
.fries-icon { position: absolute; left: 14px; bottom: 11px; width: 58px; height: 43px; background: #e62e3b; border: 4px solid var(--ink); transform: skew(3deg); }
.fries-icon::after { content: ""; position: absolute; inset: 8px -4px auto; border-top: 4px solid #fff4dc; }
.fries-icon i { position: absolute; bottom: 36px; width: 9px; height: 32px; background: #ffd32f; border: 3px solid var(--ink); }
.fries-icon i:nth-child(1) { left: 2px; transform: rotate(-8deg); }.fries-icon i:nth-child(2) { left: 13px; height: 38px; }.fries-icon i:nth-child(3) { left: 25px; height: 42px; transform: rotate(4deg); }.fries-icon i:nth-child(4) { left: 37px; height: 35px; }.fries-icon i:nth-child(5) { left: 46px; transform: rotate(9deg); }
.heart-rack { display: flex; gap: 12px; height: 36px; align-items: center; }
.heart-rack i { position: relative; display: block; width: 28px; height: 25px; background: var(--red); border: 3px solid var(--ink); transform: rotate(45deg); box-shadow: inset 3px 3px rgba(255,255,255,.55); transition: opacity .2s; }
.heart-rack i::before, .heart-rack i::after { content: ""; position: absolute; width: 17px; height: 17px; border-radius: 50%; background: inherit; }
.heart-rack i::before { left: -10px; top: 5px; border-left: 3px solid var(--ink); border-bottom: 3px solid var(--ink); }
.heart-rack i::after { top: -10px; left: 5px; border-top: 3px solid var(--ink); border-right: 3px solid var(--ink); }
.heart-rack i.empty { background: #263a5b; box-shadow: none; opacity: .72; }
.timer-panel { position: absolute; left: 50%; top: 0; transform: translateX(-50%); min-width: clamp(150px, 19vw, 245px); padding: 8px 18px; text-align: center; }
.timer-panel span, .score-panel span { display: block; font: 900 clamp(11px, 1.5vw, 18px)/1 Arial, sans-serif; letter-spacing: .12em; }
.timer-panel strong { display: block; color: var(--yellow); font-size: clamp(27px, 4vw, 48px); line-height: 1; letter-spacing: .08em; text-shadow: 4px 4px #000; }
.score-panel { position: absolute; right: 0; top: 104px; padding: 6px 12px; min-width: 112px; text-align: center; }
.score-panel strong { color: var(--yellow); font-size: clamp(18px, 2.2vw, 27px); text-shadow: 3px 3px #000; }

.back-link, .sound-button {
  position: absolute; z-index: 20; bottom: max(10px, env(safe-area-inset-bottom)); min-width: 44px; min-height: 44px;
  display: flex; align-items: center; justify-content: center; padding: 8px 11px; border: 3px solid #fff; color: #fff;
  background: #09274c; box-shadow: 4px 4px 0 var(--ink); text-decoration: none; cursor: pointer; touch-action: manipulation;
  font: 900 10px/1 Arial, sans-serif; letter-spacing: .08em;
}
.back-link { left: max(10px, env(safe-area-inset-left)); }.sound-button { right: max(10px, env(safe-area-inset-right)); }

.overlay { position: absolute; z-index: 25; inset: 0; }
.start-screen {
  display: grid; place-items: center; pointer-events: none; overflow: hidden;
  background: #07152d;
}
.start-screen::before {
  position: absolute; inset: -14px; content: "";
  background: linear-gradient(rgba(3,18,42,.42), rgba(3,18,42,.42)), url("./beacon-island-bg.png") center 42% / cover no-repeat;
  filter: blur(5px) saturate(.8); transform: scale(1.04); opacity: .9;
}
.reference-stage {
  position: absolute; z-index: 2; left: 50%; top: 50%;
  width: min(100vw, calc(100vh * 4 / 3)); aspect-ratio: 4 / 3;
  transform: translate(-50%, -50%); overflow: visible;
  background: #159fe5; box-shadow: 0 0 0 5px #07152d, 14px 14px 0 rgba(0,0,0,.42);
}
.reference-scene {
  display: block; width: 100%; height: 100%; object-fit: cover; object-position: center 42%;
  image-rendering: pixelated; pointer-events: none;
}
.start-title {
  position: absolute; z-index: 4; left: 4%; top: 5%; width: 50%; color: #fff; pointer-events: none;
  filter: drop-shadow(5px 6px 0 #07152d); transform: rotate(-1deg);
}
.start-title span, .start-title b { display: block; font: 900 clamp(36px, 6.3vw, 86px)/.78 Impact, "Arial Black", sans-serif; letter-spacing: .015em; -webkit-text-stroke: 2px #07152d; }
.start-title span { color: #fff231; }.start-title b { color: #fff; font-size: clamp(44px, 7.5vw, 102px); }
.start-title small { display: inline-block; margin-top: 10px; padding: 6px 10px; color: #fff; background: #ef3340; border: 3px solid #fff; outline: 3px solid #07152d; font: 900 clamp(9px, 1.3vw, 17px)/1 Arial,sans-serif; letter-spacing: .08em; }
.reference-start-button {
  position: absolute; z-index: 5; left: 50%; bottom: 5%; width: min(48%, 430px); min-height: 74px;
  margin: 0; padding: 10px 44px 10px 18px; border: 4px solid #fff; outline: 5px solid #07152d; opacity: 1;
  color: #fff; background: #0878d5; box-shadow: inset 0 -9px #064f9b, inset 0 6px #20b4ef, 8px 8px 0 #07152d;
  cursor: pointer; pointer-events: auto; touch-action: manipulation; transform: translateX(-50%);
  font: 900 clamp(18px, 3vw, 34px)/1 Arial,sans-serif; text-shadow: 3px 3px #001a42;
}
.reference-start-button span, .reference-start-button small { display: block; }.reference-start-button small { margin-top: 6px; color: #fff231; font-size: clamp(8px, 1vw, 12px); letter-spacing: .07em; }
.reference-start-button::after { content: "▶"; position: absolute; right: 20px; top: 50%; color: #fff231; transform: translateY(-50%); }
.reference-start-button:hover { filter: brightness(1.12); }.reference-start-button:active { transform: translate(-50%, 4px); box-shadow: inset 0 -5px #064f9b, inset 0 5px #20b4ef, 4px 4px 0 #07152d; }
.reference-start-button:focus-visible { outline: 6px solid #fff231; outline-offset: 3px; }
.instructions {
  position: absolute; z-index: 4; right: max(12px, env(safe-area-inset-right)); bottom: max(10px, env(safe-area-inset-bottom));
  margin: 0; padding: 7px 10px; color: #fff; background: rgba(7,21,45,.82); border: 2px solid #fff;
  font: 900 clamp(9px, 1vw, 13px)/1 Arial,sans-serif; text-shadow: 2px 2px #06152d; text-transform: uppercase;
}

.arcade-button, .continue-button {
  min-width: 44px; min-height: 44px; border: 4px solid #fff; outline: 5px solid var(--ink);
  color: #fff; background: #0878d5; box-shadow: inset 0 -7px #054f9a, inset 0 5px #20b4ef, 8px 8px 0 rgba(2,15,35,.8);
  text-shadow: 3px 3px #001a42; cursor: pointer; touch-action: manipulation; text-transform: uppercase;
}

.dennis-modal { background: rgba(2,19,41,.42); cursor: default; }
.dennis-wrap { position: absolute; left: 1%; bottom: -8%; width: min(36vw, 430px); height: min(68vh, 650px); filter: drop-shadow(8px 2px 0 var(--ink)); }
.dennis-portrait { width: 100%; height: 100%; object-fit: contain; object-position: bottom; image-rendering: pixelated; }
.speech { position: absolute; left: 31%; bottom: 14%; width: min(58vw, 720px); padding: 24px 28px; color: var(--ink); background: #fffdf0; border: 6px solid var(--ink); box-shadow: 9px 9px 0 #13713a; }
.speech::before { content: ""; position: absolute; left: -55px; bottom: 25px; border: 24px solid transparent; border-right: 38px solid var(--ink); }
.speech strong { color: #0875c9; letter-spacing: .12em; }.speech blockquote { margin: 10px 0 18px; font-size: clamp(20px,3vw,39px); line-height: 1.14; }.continue-button { padding: 12px 24px; font-size: 15px; }
.game-over { display: grid; place-items: center; background: rgba(0,17,39,.7); padding: 20px; overflow: auto; }
.over-card { width: min(92vw, 680px); padding: 20px 24px; text-align: center; margin: auto; }.over-card .kicker { color: #49d5f3; letter-spacing: .15em; }.over-card h2 { color: var(--yellow); font-size: clamp(36px,6vw,58px); line-height: .88; margin: 6px; text-shadow: 5px 5px #000; }.over-quote { min-height: 2em; margin: 8px; }.results { display: flex; justify-content: center; gap: 25px; }.results p { font-size: 12px; margin: 5px; }.results strong { display: block; color: var(--yellow); font-size: 25px; }.over-card .arcade-button { padding: 12px 30px; font-size: 18px; }
.leaderboard { margin: 10px auto 14px; padding: 9px 14px; max-width: 500px; color: var(--ink); background: #fffdf0; border: 4px solid var(--ink); box-shadow: 5px 5px 0 #13713a; }
.leaderboard h3 { margin: 0 0 6px; color: #0875c9; font-size: 17px; letter-spacing: .12em; }
.leaderboard ol { counter-reset: rank; display: grid; grid-template-columns: 1fr 1fr; gap: 2px 22px; margin: 0; padding: 0; list-style: none; text-align: left; }
.leaderboard li { counter-increment: rank; display: flex; min-width: 0; gap: 6px; font-size: 12px; line-height: 1.35; }
.leaderboard li::before { content: counter(rank) "."; flex: 0 0 1.6em; color: #0875c9; }
.leaderboard li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leaderboard li strong { margin-left: auto; color: #b53028; }
.leaderboard .leaderboard-note { display: block; grid-column: 1 / -1; text-align: center; }
.leaderboard .leaderboard-note::before { content: none; }
.leaderboard-form { margin-top: 8px; padding-top: 8px; border-top: 2px dashed #0875c9; }
.leaderboard-form label { display: block; margin-bottom: 6px; color: #b53028; font-size: 11px; }
.leaderboard-form div { display: flex; justify-content: center; gap: 10px; }
.leaderboard-form input { min-width: 0; width: 240px; border: 3px solid var(--ink); padding: 8px; font: 900 16px Arial,sans-serif; color: var(--ink); background: #fff; }
.leaderboard-form .arcade-button { min-height: 40px; padding: 6px 15px; font-size: 13px; }
.leaderboard-message { min-height: 1.2em; margin: 6px 0 0; color: #33506b; font-size: 11px; }
.play-again-button { margin-bottom: 4px; }
.arcade-button:disabled { cursor: wait; filter: grayscale(.7); opacity: .75; }
.rotate-note { display: none; }.sr-only { position: absolute!important; width: 1px!important; height: 1px!important; padding: 0!important; margin: -1px!important; overflow: hidden!important; clip: rect(0,0,0,0)!important; white-space: nowrap!important; border: 0!important; }

@media (orientation: portrait) {
  .scene-sign { max-width: 30vw; }
}
@media (max-width: 520px) and (orientation: portrait) {
  .hotel-lockup { top: 31%; right: 4%; width: 58vw; }.hotel-lockup b { font-size: clamp(22px, 7vw, 38px); }
  .hotel-lockup span { font-size: 11px; }
  .scene-sign--plett { top: 57%; left: 2%; transform: scale(.78) rotate(-2deg); transform-origin: left center; }
  .scene-sign--chips { top: 60%; right: 1%; transform: scale(.76) rotate(2deg); transform-origin: right center; }
  .game-title { top: 7.5%; left: 5%; width: 90%; }.game-title span { font-size: clamp(52px, 18vw, 78px); }.game-title b { font-size: clamp(62px, 22vw, 94px); }
  .start-dennis { left: -12%; bottom: 2%; width: 66vw; height: 40vh; }
  .intro-bubble { left: 6%; bottom: 31%; width: 88%; padding: 12px 14px; }.intro-bubble::before { display: none; }
  .intro-bubble h2 { font-size: 24px; }.intro-bubble p:last-child { font-size: 13px; }
  .start-screen > .arcade-button { right: 5%; bottom: max(84px, calc(env(safe-area-inset-bottom) + 74px)); width: 86%; min-height: 72px; padding: 7px 50px 7px 12px; }.start-screen > .arcade-button::after { right: 8px; font-size: 38px; }
  .arcade-button span { font-size: 20px; }.instructions { display: none; }
  .hud { top: max(8px, env(safe-area-inset-top)); }
  .chip-panel { width: 176px; min-height: 70px; padding: 7px 6px 4px 68px; }.fries-icon { left: 7px; transform: scale(.7); transform-origin: bottom left; }.heart-rack { gap: 7px; transform: scale(.68); transform-origin: left center; height: 26px; }.chip-panel strong { font-size: 14px; }
  .timer-panel { left: auto; right: 0; transform: none; min-width: 126px; padding: 7px 10px; }.timer-panel strong { font-size: 26px; }
  .score-panel { top: 79px; right: 0; min-width: 99px; }
  .dennis-wrap { left: -15%; bottom: -5%; width: 66vw; height: 45vh; }.speech { left: 6%; bottom: 40%; width: 88%; padding: 16px; }.speech::before { display: none; }.speech blockquote { font-size: clamp(18px, 6vw, 27px); }
  .chip-warning { left: auto; right: 8%; top: 67%; }
}
@media (max-width: 520px) and (max-height: 500px) and (orientation: portrait) {
  .game-title { top: 3%; }
  .game-title span { font-size: clamp(42px, 15vw, 58px); }
  .game-title b { font-size: clamp(50px, 18vw, 68px); }
  .hotel-lockup { top: 25%; }
  .intro-bubble { bottom: 35%; padding: 7px 10px; }
  .intro-bubble .kicker { font-size: 8px; }
  .intro-bubble h2 { margin-bottom: 2px; font-size: 18px; }
  .intro-bubble p:last-child { margin-top: 2px; font-size: 10px; line-height: 1.05; }
  .start-dennis { bottom: 0; height: 34vh; }
  .start-screen > .arcade-button { bottom: max(58px, calc(env(safe-area-inset-bottom) + 52px)); min-height: 56px; padding-top: 4px; padding-bottom: 4px; }
  .start-screen > .arcade-button::after { top: 1px; font-size: 32px; }
  .arcade-button span { font-size: 17px; }
  .arcade-button small { font-size: 7px; }
}
@media (max-height: 430px) and (orientation: landscape) {
  .game-title { left: 5%; top: 4%; width: 42vw; }.game-title span { font-size: clamp(40px, 8vw, 68px); }.game-title b { font-size: clamp(48px, 9.6vw, 82px); }
  .hotel-lockup { top: 4%; right: 3%; width: 31vw; }.hotel-lockup b { font-size: clamp(23px, 4vw, 36px); }
  .scene-sign--plett { top: 48%; transform: scale(.7) rotate(-2deg); transform-origin: left center; }.scene-sign--chips { top: 57%; transform: scale(.7) rotate(2deg); transform-origin: right center; }
  .start-dennis { left: -.5%; bottom: -14%; width: 27vw; height: 59vh; }
  .intro-bubble { left: 25%; bottom: 22%; width: 34vw; padding: 8px 12px; border-width: 4px; }.intro-bubble::before { left: -34px; border-width: 12px 34px 7px 0; }.intro-bubble .kicker { font-size: 9px; }.intro-bubble h2 { font-size: clamp(17px, 2.5vw, 23px); }.intro-bubble p:last-child { font-size: clamp(10px, 1.45vw, 13px); }
  .start-screen > .arcade-button { right: 4%; bottom: max(50px, calc(env(safe-area-inset-bottom) + 44px)); width: 37vw; min-height: 57px; padding: 5px 43px 6px 9px; }.start-screen > .arcade-button::after { right: 7px; font-size: 32px; }.arcade-button span { font-size: clamp(17px, 2.5vw, 24px); }.arcade-button small { font-size: 8px; }.instructions { display: none; }
  .chip-panel { min-height: 68px; transform: scale(.72); transform-origin: top left; }.timer-panel { transform: translateX(-50%) scale(.72); transform-origin: top center; }.score-panel { top: 67px; transform: scale(.72); transform-origin: top right; }
  .back-link, .sound-button { bottom: max(7px, env(safe-area-inset-bottom)); min-height: 40px; }
  .dennis-wrap { left: 0; bottom: -17%; width: 28vw; height: 64vh; }.speech { left: 25%; bottom: 12%; width: 58vw; padding: 12px 16px; }.speech blockquote { margin: 5px 0 8px; font-size: clamp(16px, 2.6vw, 25px); }.continue-button { padding: 8px 18px; }
  .over-card { max-height: 94vh; padding: 10px 18px; }.over-card h2 { font-size: 38px; }.over-card p { margin: 6px; }.over-card .arcade-button { padding: 8px 25px; font-size: 17px; }
}
@media (min-width: 521px) and (orientation: portrait) {
  .game-title { left: 8%; top: 6%; width: 84%; }
  .hotel-lockup { top: 30%; right: 4%; width: 48vw; }
  .start-dennis { width: 52vw; bottom: 0; }.intro-bubble { left: 9%; bottom: 34%; width: 82%; }.intro-bubble::before { display: none; }
  .start-screen > .arcade-button { right: 6%; bottom: 6%; width: 80%; }
}
@media (orientation: portrait) {
  .start-screen { place-items: start center; }
  .reference-stage {
    top: max(56px, calc(env(safe-area-inset-top) + 48px));
    width: min(100vw, 760px); height: auto; transform: translateX(-50%); aspect-ratio: 4 / 3;
  }
  .reference-start-button {
    left: 50%; top: calc(100% + 26px); bottom: auto; width: 84%; height: 74px; opacity: 1;
    border: 4px solid #fff; outline: 5px solid #07152d; border-radius: 0;
    color: #fff; background: #0878d5; box-shadow: inset 0 -9px #064f9b, inset 0 6px #20b4ef, 8px 8px 0 #07152d;
    font: 900 clamp(18px, 6vw, 30px)/1 Arial,sans-serif; text-shadow: 3px 3px #001a42;
  }
  .start-title { left: 5%; top: 6%; width: 64%; }
  .start-title span { font-size: clamp(32px, 11vw, 64px); }.start-title b { font-size: clamp(40px, 14vw, 78px); }
  .reference-start-button::after { content: "▶"; color: #fff231; }
  .instructions {
    left: 50%; right: auto; bottom: max(18px, env(safe-area-inset-bottom)); transform: translateX(-50%);
    width: max-content; max-width: 92%; text-align: center;
  }
}

@media (max-height: 650px) and (orientation: portrait) {
  .reference-stage { top: 42px; width: min(82vw, 500px); }
  .reference-start-button { top: calc(100% + 18px); height: 58px; }
}

@media (prefers-reduced-motion: reduce) {
  .game::after { display: none; }
  .chip-warning.show { animation-duration: .01ms; }
}
