:root {
  --navy: #1d3a6e;
  --navy-dark: #12264a;
  --sky: #4fb3f0;
  --sun: #ffe066;
  --orange: #ffb347;
  --red: #e8453c;
  --ink: #f4f7ff;
  --muted: #b8c7e6;
  --line: rgba(244, 247, 255, 0.16);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { color: var(--ink); background: var(--navy-dark); font-family: "Fredoka", system-ui, sans-serif; }
button { font: inherit; }
[hidden] { display: none !important; }

/* One screen: the game on top, the ad banner below it, How to Play further down the page. */
.app { height: 100vh; height: 100dvh; display: flex; flex-direction: column; }
.game-shell { position: relative; flex: 1 1 auto; min-height: 0; overflow: hidden; background: #f6e7bf; }
canvas { display: block; width: 100%; height: 100%; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }

.top-buttons { position: absolute; top: max(8px, env(safe-area-inset-top)); right: max(8px, env(safe-area-inset-right)); display: flex; gap: 8px; z-index: 3; }
.round-btn { width: 42px; height: 42px; border: 2px solid rgba(255,255,255,.7); border-radius: 50%; background: rgba(20,32,64,.62); color: #fff; font-size: 18px; cursor: pointer; }
.round-btn:hover { background: rgba(20,32,64,.85); }
.round-btn.off { opacity: .45; }
.play-only { display: none; }
body.playing .play-only { display: block; }

/* SLIDE button: touch screens only, bottom-left, away from the ad banner below */
.slide-btn { position: absolute; left: max(12px, env(safe-area-inset-left)); bottom: 14px; z-index: 3; width: 78px; height: 78px; border: 3px solid rgba(255,255,255,.8);
  border-radius: 50%; background: rgba(20,32,64,.5); color: #fff; font-size: 24px; line-height: 1; cursor: pointer; touch-action: none; user-select: none; -webkit-user-select: none; }
.slide-btn span { display: block; font: 11px "Luckiest Guy", sans-serif; letter-spacing: .05em; margin-top: 4px; }
.slide-btn:active { background: rgba(79,179,240,.7); }
body.playing .slide-btn { display: none; }
@media (pointer: coarse) { body.playing .slide-btn { display: block; } }

/* JUMP button: touch screens only, bottom-right (mirror of the SLIDE button); hold for a higher jump */
.jump-btn { position: absolute; right: max(12px, env(safe-area-inset-right)); bottom: 14px; z-index: 3; width: 78px; height: 78px; border: 3px solid rgba(255,255,255,.8);
  border-radius: 50%; background: rgba(20,32,64,.5); color: #fff; font-size: 24px; line-height: 1; cursor: pointer; touch-action: none; user-select: none; -webkit-user-select: none; }
.jump-btn span { display: block; font: 11px "Luckiest Guy", sans-serif; letter-spacing: .05em; margin-top: 4px; }
.jump-btn:active { background: rgba(79,179,240,.7); }
body.playing .jump-btn { display: none; }
@media (pointer: coarse) { body.playing .jump-btn { display: block; } }

/* ---------- menu cards ---------- */
.overlay { position: absolute; inset: 0; z-index: 4; display: grid; place-items: center; padding: 12px; background: rgba(18, 38, 74, .55); overflow: auto; }
.card { width: min(440px, 100%); max-height: 100%; overflow: auto; padding: 20px 20px 18px; border-radius: 22px; background: var(--navy); border: 3px solid var(--sun);
  box-shadow: 0 10px 0 rgba(0,0,0,.25); text-align: center; }
.card h2, .card h3 { margin: 0 0 6px; font-family: "Luckiest Guy", sans-serif; font-weight: 400; letter-spacing: .02em; color: var(--sun); }
.card h2 { font-size: clamp(30px, 8vw, 42px); line-height: 1; }
.card h2 span { color: var(--sky); font-size: .8em; }
.card h3 { font-size: 30px; }
.kicker { margin: 0 0 6px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .1em; }
.lead { margin: 6px 0 14px; color: #dbe5fb; line-height: 1.4; }
.small { margin: 12px 0 0; color: var(--muted); font-size: 13px; }
.btn { display: block; width: 100%; margin: 8px 0 0; padding: 11px 14px; border: 0; border-radius: 14px; background: rgba(255,255,255,.14); color: #fff;
  font-size: 16px; font-weight: 600; text-decoration: none; cursor: pointer; }
.btn:hover:not([disabled]) { background: rgba(255,255,255,.24); }
.btn.primary { background: var(--sun); color: var(--navy-dark); font-family: "Luckiest Guy", sans-serif; font-weight: 400; font-size: 20px; letter-spacing: .03em; }
.btn.primary:hover:not([disabled]) { background: #fff08f; }
.btn.big { font-size: 26px; padding: 13px; }
.btn.reward { background: #2bb24c; }
.btn.reward:hover { background: #38c95b; }
.btn.ghost { background: transparent; color: var(--muted); }
.btn[disabled] { opacity: .55; cursor: default; }
.btn:focus-visible, .tile:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.row { display: flex; gap: 8px; }
.row .btn { flex: 1; }

.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.tile { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px; border: 2px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.08);
  color: #fff; font-size: 12px; cursor: pointer; }
.tile:hover:not([disabled]) { border-color: var(--sun); }
.tile[disabled] { opacity: .5; cursor: default; }
.tile-icon { font-size: 24px; }
.tile small { color: var(--muted); font-size: 11px; }
.btn.shop-entry { background: var(--sun); color: var(--navy-dark); font-family: "Luckiest Guy", sans-serif; font-weight: 400; }
.btn.shop-entry:hover:not([disabled]) { background: #fff08f; }
.shop-screen { width: min(520px, 100%); }
.shop-wallet { margin: 8px 0 12px; padding: 9px; border-radius: 12px; background: rgba(255, 224, 102, .13); color: var(--sun); }
.shop-items { display: grid; gap: 8px; }
.shop-group-title { margin: 12px 0 0; padding: 0 2px 4px; border-bottom: 1px solid var(--line); color: var(--sun); font: 16px "Luckiest Guy", sans-serif; text-align: left; }
.shop-group-title:first-child { margin-top: 0; }
.shop-item { display: flex; align-items: center; gap: 10px; padding: 9px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.06); text-align: left; }
.shop-icon { width: 40px; flex: 0 0 40px; font-size: 27px; text-align: center; }
.shop-copy { min-width: 0; flex: 1; display: grid; gap: 2px; }
.shop-copy small { color: var(--muted); font-size: 12px; }
.shop-buy { width: auto; min-width: 98px; margin: 0; padding: 8px 10px; font-size: 13px; }
.intro-card { width: min(620px, 100%); overflow: hidden; background: linear-gradient(160deg, #24538c, #12264a 78%); }
.intro-cover h2 { margin: 2px 0 12px; font-family: "Luckiest Guy", sans-serif; font-size: clamp(38px, 10vw, 54px); line-height: .9; color: #fff; text-shadow: 0 4px 0 #12264a; }
.intro-cover h2 span { color: var(--sun); }
.intro-scene { position: relative; aspect-ratio: 600 / 230; margin: 0 -20px 10px; overflow: hidden; background: #71d2f5; border-bottom: 5px solid #eabf5e; }
.intro-art { display: block; width: 100%; height: 100%; }
.intro-caught-art { position: absolute; z-index: 1; inset: 0; display: block; width: 100%; height: 100%; pointer-events: none; filter: drop-shadow(0 2px 2px rgba(24,40,65,.25)); }
.intro-game-art { position: absolute; z-index: 2; inset: 0; display: block; width: 100%; height: 100%; pointer-events: none; }
.intro-human-art { position: absolute; z-index: 3; inset: 0; display: block; width: 100%; height: 100%; overflow: visible; pointer-events: none; filter: drop-shadow(0 2px 2px rgba(24,40,65,.25)); }
.intro-evacuees { transform-box: view-box; transform-origin: 0 0; animation: intro-flee 4.4s linear both; }
.intro-human-person { transform-box: fill-box; transform-origin: center bottom; }
.intro-human-person:not(.intro-caught-one):not(.intro-caught-two) { animation: intro-run-bob .24s ease-in-out infinite alternate; }
.intro-run-limb { transform-box: fill-box; }
.intro-arm-left, .intro-leg-left { transform-origin: 100% 0%; animation: intro-run-swing .24s ease-in-out infinite alternate; }
.intro-arm-right, .intro-leg-right { transform-origin: 0% 0%; animation: intro-run-swing .24s ease-in-out infinite alternate-reverse; }
.intro-caught-one .intro-run-limb { animation-duration: .34s; }
.intro-caught-two .intro-run-limb { animation-duration: .42s; }
.intro-caught-person { transform-box: fill-box; transform-origin: center bottom; }
.intro-caught-one { animation: intro-caught-one 4.4s ease-in both; }
.intro-caught-two { animation: intro-caught-two 4.4s ease-in both; }
.intro-water-spin { opacity: 0; }
.intro-water-spin-one { animation: intro-spin-show 1.55s ease-in .25s both; }
.intro-water-spin-two { animation: intro-spin-show 1.65s ease-in .82s both; }
.intro-spinner { transform-box: fill-box; transform-origin: center; }
.intro-spinner-one { animation: intro-wheel-spin-one 1.55s linear .25s both; }
.intro-spinner-two { animation: intro-wheel-spin-two 1.65s linear .82s both; }
.intro-swirl { fill: none; stroke: rgba(235,250,255,.9); stroke-width: 2.5; stroke-dasharray: 34 13 8 12; transform-box: fill-box; transform-origin: center; }
.intro-water-spin-one .intro-swirl { animation: intro-swirl-spin 1.55s linear .25s both; }
.intro-water-spin-two .intro-swirl { animation: intro-swirl-spin 1.65s linear .82s both; }
.intro-story { min-height: 48px; display: grid; place-items: center; margin: 8px 0 10px; }
.intro-story p { grid-area: 1 / 1; margin: 0; color: #fff; font-size: clamp(16px, 4.5vw, 20px); font-weight: 600; opacity: 0; animation: intro-line 4.4s ease both; }
.intro-cover .small { margin-top: 8px; }
@keyframes intro-flee { from { transform: translateX(0); } to { transform: translateX(264px); } }
@keyframes intro-run-bob { from { transform: translateY(0); } to { transform: translateY(-3px); } }
@keyframes intro-run-swing { from { transform: rotate(-38deg); } to { transform: rotate(38deg); } }
@keyframes intro-caught-one { 0% { transform: translateX(0) rotate(0); } 4% { transform: translateX(6px) rotate(0); } 6% { transform: translateX(8px) rotate(-8deg); } 9% { transform: translateX(6px) rotate(12deg) translateY(2px); } 13% { transform: translateX(-3px) rotate(-20deg) translateY(15px) scale(.65); } 17%, 100% { transform: translateX(-8px) rotate(24deg) translateY(32px) scale(.25); opacity: 0; } }
@keyframes intro-caught-two { 0% { transform: translateX(0) rotate(0); } 15% { transform: translateX(13px) rotate(0); } 19% { transform: translateX(17px) rotate(-8deg); } 23% { transform: translateX(15px) rotate(12deg) translateY(2px); } 29% { transform: translateX(6px) rotate(-20deg) translateY(15px) scale(.65); } 35%, 100% { transform: translateX(0) rotate(-24deg) translateY(32px) scale(.25); opacity: 0; } }
@keyframes intro-spin-show { 0%, 2% { opacity: 0; } 8%, 68% { opacity: .95; } 100% { opacity: 0; } }
@keyframes intro-wheel-spin-one { from { transform: scale(.62) rotate(0deg); } to { transform: scale(.62) rotate(1440deg); } }
@keyframes intro-wheel-spin-two { from { transform: scale(.64) rotate(0deg); } to { transform: scale(.64) rotate(1440deg); } }
@keyframes intro-swirl-spin { from { transform: rotate(0deg); } to { transform: rotate(720deg); } }
@keyframes intro-line { 0%, 5% { opacity: 0; transform: translateY(5px); } 12%, 25% { opacity: 1; transform: translateY(0); } 31%, 100% { opacity: 0; transform: translateY(-4px); } }
.intro-story p:nth-child(2) { animation-name: intro-line-second; }
.intro-story p:nth-child(3) { animation-name: intro-line-third; }
@keyframes intro-line-second { 0%, 34% { opacity: 0; transform: translateY(5px); } 40%, 54% { opacity: 1; transform: translateY(0); } 62%, 100% { opacity: 0; transform: translateY(-4px); } }
@keyframes intro-line-third { 0%, 64% { opacity: 0; transform: translateY(5px); } 70%, 95% { opacity: 1; transform: translateY(0); } 100% { opacity: 0; transform: translateY(-4px); } }
@media (prefers-reduced-motion: reduce) {
  .intro-evacuees { animation: none; transform: translateX(264px); }
  .intro-human-person, .intro-run-limb { animation: none; transform: none; }
  .intro-caught-person { animation: none; }
  .intro-water-spin { animation: none; opacity: 0; }
  .intro-spinner, .intro-swirl { animation: none; }
  .intro-story p { animation: none; opacity: 1; }
  .intro-story p:nth-child(n+2) { display: none; }
}
.stars { display: inline-flex; gap: 2px; font-size: 16px; }
.stars i { font-style: normal; color: rgba(255,255,255,.25); }
.stars i.on { color: var(--sun); }
.card > .stars { font-size: 38px; margin: 2px 0 6px; }

.portrait-tip { display: none; }
@media (orientation: portrait) and (pointer: coarse) { .portrait-tip { display: block; } }

.results { list-style: none; margin: 8px 0 4px; padding: 0; text-align: left; }
.results li { display: flex; justify-content: space-between; gap: 10px; padding: 6px 10px; border-radius: 10px; color: var(--muted); font-size: 14px; }
.results li:first-child { color: #fff; font-size: 16px; background: rgba(255,255,255,.08); }
.results li.ok { color: var(--sun); }

/* short screens (phones held sideways): wider, tighter cards */
@media (max-height: 520px) {
  .card { width: min(640px, 100%); padding: 10px 16px; }
  .kicker { margin-bottom: 2px; font-size: 10px; }
  .card h2 { font-size: 28px; }
  .card h2 br { display: none; }
  .card h2 span { margin-left: .3em; }
  .card h3 { font-size: 24px; }
  .card > .stars { font-size: 26px; margin: 0; }
  .lead { margin: 2px 0 6px; font-size: 14px; }
  .btn { padding: 8px 12px; margin-top: 6px; }
  .btn.big { font-size: 20px; padding: 8px; }
  .tiles { grid-template-columns: repeat(6, 1fr); gap: 6px; margin-top: 8px; }
  .tile { padding: 4px 2px; }
  .tile-icon { font-size: 18px; }
  .tile b { font-size: 10px; }
  .tile small { font-size: 9px; }
  .small { margin-top: 6px; }
  .results { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin: 4px 0; }
  .results li { flex-direction: column; gap: 0; padding: 4px 6px; font-size: 12px; }
  .results li:first-child { font-size: 13px; }
  .slide-btn { width: 64px; height: 64px; }
}

/* ---------- ad banner: at least 150px from the play area (AdSense game-page guidance) ----------
   computer: banner stays on screen under the game, with a 150px empty gap.
   phone/tablet: game fills the screen; banner sits below it, reached by scrolling (swipe the strip under the game). */
.ad-slot { text-align: center; }
.ad-label { font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); opacity: .8; }
.game-shell { border-bottom: 3px solid var(--navy); }
.ad-banner { flex: 0 0 auto; margin-top: 150px; padding: 0 0 max(4px, env(safe-area-inset-bottom)); background: var(--navy-dark); }
.scroll-hint { display: none; }
@media (pointer: coarse) {
  .app { height: auto; }
  .game-shell { flex: none; height: calc(100vh - 34px); height: calc(100dvh - 34px); }
  .scroll-hint { display: block; height: 34px; line-height: 34px; text-align: center; font-size: 12px; color: var(--muted); }
  .ad-banner { margin-top: 116px; }
}
.ad-banner ins { display: inline-block; width: 320px; height: 50px; }
@media (min-width: 768px) and (min-height: 600px) { .ad-banner ins { width: 728px; height: 90px; } }
.ad-placeholder ins { background: repeating-linear-gradient(45deg, #1d3a6e, #1d3a6e 10px, #24467f 10px, #24467f 20px); border: 1px dashed var(--line); }

/* ---------- text below the game ---------- */
.content { max-width: 760px; margin: 0 auto; padding: 28px 20px 48px; line-height: 1.6; }
.content h2 { margin: 30px 0 10px; color: var(--sun); font-family: "Luckiest Guy", sans-serif; font-weight: 400; font-size: 26px; letter-spacing: .02em; }
.content p, .content li { color: #dbe5fb; }
.content li { margin-bottom: 6px; }
.content a { color: var(--sky); }
.content kbd { padding: 1px 6px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; background: var(--navy); font-size: 13px; color: #fff; }
.content footer { margin-top: 40px; color: var(--muted); font-size: 13px; text-align: center; }
