@font-face {
  font-family: 'Press Start 2P';
  src: url('fonts/press-start-2p.ttf') format('truetype');
  font-display: swap;
}

:root {
  --bg: #050e18;
  --bg2: #0a1c2e;
  --ice: #7ed6ff;
  --ice-deep: #3d8fc9;
  --glow: rgba(126, 214, 255, 0.45);
  --text: #eaf6ff;
  --danger: #ff5a5a;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: radial-gradient(ellipse at 50% -10%, #0c2438 0%, var(--bg) 55%);
  color: var(--text);
  font-family: 'Press Start 2P', 'Courier New', monospace;
  text-align: center;
  image-rendering: pixelated;
  -webkit-font-smoothing: none;
}

.hero { padding: 0 0 16px; }

.banner {
  position: relative;
  width: 100%;
  max-height: 46vh;
  overflow: hidden;
  box-shadow: 0 0 30px var(--glow);
}
.banner img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: cover;
  -webkit-mask-image: linear-gradient(180deg, #000 78%, transparent 100%);
  mask-image: linear-gradient(180deg, #000 78%, transparent 100%);
}

.hero-turtle {
  width: 80px;
  height: 80px;
  margin: -34px auto 4px;
  position: relative;
  background: url('assets/sprites/turtle_idle_strip6.png') 0 0 / 480px 80px no-repeat;
  animation: idle 0.9s steps(6) infinite;
  filter: drop-shadow(0 0 10px var(--glow));
}
@keyframes idle { to { background-position-x: -480px; } }

.title-img {
  display: block;
  margin: 0 auto;
  width: min(480px, 88vw);
  height: auto;
  filter: drop-shadow(0 0 18px var(--glow));
}

.tagline {
  margin-top: 6px;
  font-size: 13px;
  color: var(--ice);
  text-shadow: 0 0 10px var(--glow), 2px 2px 0 #000;
  letter-spacing: 3px;
}

.ca-pill {
  margin-top: 20px;
  display: inline-flex;
  gap: 10px;
  align-items: center;
  max-width: 92vw;
  padding: 10px 14px;
  background: var(--bg2);
  border: 3px solid var(--ice-deep);
  box-shadow: 0 0 12px var(--glow), inset 0 0 8px rgba(126, 214, 255, 0.15);
  color: var(--text);
  font: inherit;
  font-size: 10px;
  cursor: pointer;
}
.ca-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ca-copy { color: var(--ice); flex-shrink: 0; text-shadow: 0 0 8px var(--glow); }

.pump-link {
  display: inline-block;
  margin-top: 14px;
  padding: 12px 18px;
  background: linear-gradient(180deg, #9fe3ff 0%, #4aa8e0 100%);
  color: #04121f;
  text-decoration: none;
  font-size: 12px;
  border: 3px solid var(--ice);
  box-shadow: 0 0 16px var(--glow), 0 4px 0 #04121f;
}
.pump-link:active { transform: translateY(3px); box-shadow: 0 0 16px var(--glow); }

.game-wrap { position: relative; margin: 24px auto 0; max-width: 900px; padding: 0 8px; }
#game {
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 3px solid var(--ice-deep);
  box-shadow: 0 0 20px var(--glow);
}
#game canvas { image-rendering: pixelated; width: 100% !important; height: 100% !important; }

.touch-controls {
  display: flex;
  gap: 8px;
  max-width: 900px;
  margin: 8px auto 0;
  padding: 0 8px;
}
.tc-btn {
  flex: 1;
  padding: 22px 0;
  font: inherit;
  font-size: 14px;
  background: var(--bg2);
  color: var(--ice);
  border: 3px solid var(--ice-deep);
  box-shadow: 0 0 10px var(--glow);
  text-shadow: 0 0 8px var(--glow);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.tc-btn:active { background: var(--ice); color: #04121f; text-shadow: none; }
.touch-controls[hidden] { display: none; }

/* ---- lore chapters ---- */
.lore { margin-top: 56px; }
.lore-title {
  font-size: 18px;
  color: var(--ice);
  text-shadow: 0 0 14px var(--glow), 2px 2px 0 #000;
  margin-bottom: 28px;
}
.chapter {
  position: relative;
  height: 72vh;
  min-height: 420px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  border-top: 3px solid rgba(126, 214, 255, 0.25);
  border-bottom: 3px solid rgba(126, 214, 255, 0.25);
  margin-bottom: 48px;
}
.chapter-bg {
  position: absolute;
  inset: -18% 0;
  background-size: cover;
  background-position: center;
  image-rendering: pixelated;
  will-change: transform;
}
.chapter::after {
  /* scanlines */
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.22) 0 2px, transparent 2px 4px);
  pointer-events: none;
}
.chapter-plate {
  position: relative;
  z-index: 1;
  background: rgba(4, 14, 24, 0.82);
  border: 3px solid var(--ice-deep);
  box-shadow: 0 0 20px var(--glow);
  padding: 24px 28px;
  max-width: min(520px, 88vw);
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}
.chapter-plate.visible { opacity: 1; transform: none; }
.chapter-tag {
  display: inline-block;
  font-size: 9px;
  color: #04121f;
  background: var(--ice);
  padding: 5px 8px;
  margin-bottom: 12px;
  box-shadow: 0 0 10px var(--glow);
}
.chapter-plate h3 {
  font-size: 16px;
  color: var(--ice);
  text-shadow: 0 0 10px var(--glow);
  margin-bottom: 14px;
}
.chapter-plate p { font-size: 10px; line-height: 2; color: var(--text); }

@media (prefers-reduced-motion: reduce) {
  .chapter-bg { transform: none !important; }
  .chapter-plate { opacity: 1; transform: none; transition: none; }
}
@media (max-width: 600px) {
  .lore-title { font-size: 13px; }
  .chapter { height: 60vh; min-height: 340px; }
  .chapter-plate h3 { font-size: 13px; }
  .chapter-plate p { font-size: 9px; }
}

.board { margin: 40px auto; max-width: 480px; padding: 0 16px; }
.board h2 {
  font-size: 16px;
  color: var(--ice);
  text-shadow: 0 0 12px var(--glow), 2px 2px 0 #000;
  margin-bottom: 16px;
}
#leaderboard { list-style: none; counter-reset: rank; text-align: left; font-size: 11px; }
#leaderboard li {
  counter-increment: rank;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 2px solid rgba(126, 214, 255, 0.25);
  margin-bottom: 6px;
  background: var(--bg2);
}
#leaderboard li::before { content: counter(rank) '.'; color: var(--ice-deep); }
#leaderboard li:first-child {
  border-color: var(--ice);
  box-shadow: 0 0 12px var(--glow);
}
#leaderboard li:first-child::before { color: var(--ice); text-shadow: 0 0 8px var(--glow); }
.lb-name { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.lb-score { color: var(--ice); }
#leaderboard .empty { justify-content: center; color: var(--ice-deep); }
#leaderboard .empty::before { content: none; }

dialog#submit-dialog {
  margin: auto;
  background: var(--bg2);
  color: var(--text);
  border: 4px solid var(--ice);
  box-shadow: 0 0 24px var(--glow);
  padding: 24px;
  font-family: inherit;
  text-align: center;
  max-width: 90vw;
}
dialog#submit-dialog::backdrop { background: rgba(2, 8, 14, 0.8); }
dialog h2 { font-size: 14px; color: var(--danger); margin-bottom: 12px; }
.final-score { font-size: 12px; color: var(--ice); text-shadow: 0 0 8px var(--glow); margin-bottom: 16px; }
#submit-form { display: flex; flex-direction: column; gap: 10px; }
#submit-form input {
  font: inherit;
  font-size: 12px;
  padding: 10px;
  background: var(--bg);
  border: 2px solid var(--ice-deep);
  color: var(--text);
  text-align: center;
}
#submit-form button {
  font: inherit;
  font-size: 11px;
  padding: 10px;
  cursor: pointer;
  background: linear-gradient(180deg, #9fe3ff 0%, #4aa8e0 100%);
  border: 2px solid var(--ice);
  color: #04121f;
}
#submit-form #skip-btn { background: var(--bg); border-color: var(--ice-deep); color: var(--ice-deep); }
.submit-result { margin-top: 10px; font-size: 11px; color: var(--ice); min-height: 14px; }

footer { padding: 32px 16px; font-size: 9px; color: var(--ice-deep); }

@media (max-width: 600px) {
  .tagline { font-size: 10px; }
  .ca-pill { font-size: 8px; }
  .board h2 { font-size: 13px; }
}
