/* Game shell — Summer Sunset Pixel (see docs/superpowers/specs/2026-07-01-visual-directions.md §1) */

:root {
  --night: #241539;
  --grape: #6D2E8B;
  --flare: #FF5D73;
  --sun: #FFD35C;
  --sand: #F2C078;
  --foam: #FFF4E2;
  --arcade: #2FE6D6;
  --ink: #2A1533;
}

* { box-sizing: border-box; }

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

body {
  font-family: "Pixelify Sans", sans-serif;
  color: var(--foam);
}

h1 {
  font-family: "Handjet", sans-serif;
  font-weight: 700;
  color: var(--sun);
  text-shadow: 0 0 12px rgba(255, 211, 92, 0.55);
  letter-spacing: 0.04em;
  margin: 0 0 clamp(8px, 2vh, 16px);
  font-size: clamp(28px, 8vw, 56px);
  text-align: center;
}

p {
  margin: 0 0 clamp(12px, 3vh, 20px);
  font-size: clamp(14px, 2.4vw, 18px);
  text-align: center;
  max-width: 32ch;
}

#stage {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  overflow: hidden;
  background: var(--night);
}

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: auto; /* smooth final scale — the game.js buffer upscale is bilinear */
  touch-action: manipulation;
  background: var(--night);
}

/* HUD */
.hud {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 10px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  padding: 6px 18px;
  border-radius: 999px;
  background: radial-gradient(circle at 50% 40%, var(--sun) 0%, var(--flare) 100%);
  color: var(--ink);
  font-family: "VT323", monospace;
  font-size: clamp(20px, 4vw, 30px);
  line-height: 1;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.25);
}

/* #score is a plain <span>; CSS transforms don't apply to non-replaced inline
   boxes, so it needs a box-generating display for the pulse scale to work. */
#score {
  display: inline-block;
}

/* Score pulse (Task 23): brief scale-up beat when a lyric line is revealed.
   boot.js adds this class on reveal and removes it on `animationend` so the
   same beat can retrigger on the next reveal. */
#score.pulse {
  animation: score-pulse 450ms ease-in-out;
}

@keyframes score-pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.4); }
  100% { transform: scale(1); }
}

/* Lives (hearts): a small row just under the score pill. boot.js fills it with
   one .heart per life; spent lives get .lost. */
.lives {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 62px); /* clears the score pill below it */
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  display: flex;
  gap: 8px;
  font-size: clamp(15px, 3.4vw, 20px);
  line-height: 1;
}
.heart {
  color: var(--flare);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
}
.heart.lost { color: rgba(255, 244, 226, 0.28); text-shadow: none; }

/* Life-lost popup: «ОЙ!» keeps the h1 Handjet title font (the earlier "weird"
   look was a stale cache, not the font). The lives line uses plain monospace —
   same look as «Очки»/«Рекорд» but digits match the text size (VT323's digits
   render smaller than the monospace-fallback Cyrillic). */
.lives-left {
  font-family: monospace;
  color: var(--sun);
  font-size: clamp(18px, 4.2vw, 26px);
  margin: 0 0 clamp(6px, 1.5vh, 12px);
}

.hidden { display: none !important; }

.mute {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 8px);
  right: calc(env(safe-area-inset-right) + 8px);
  z-index: 6;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border: none;
  border-radius: 50%;
  background: var(--grape);
  color: var(--foam);
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.home {
  position: absolute;
  bottom: calc(env(safe-area-inset-bottom) + 10px);
  left: calc(env(safe-area-inset-left) + 10px);
  z-index: 6;
  font-family: "Pixelify Sans", sans-serif;
  font-size: clamp(12px, 2vw, 14px);
  color: var(--foam);
  opacity: 0.8;
  text-decoration: none;
  padding: 8px 10px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}
.home:hover { opacity: 1; }

/* Overlays */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: clamp(16px, 4vh, 32px) clamp(16px, 6vw, 32px);
  background: rgba(36, 21, 57, 0.72); /* --night scrim */
  text-align: center;
}

.btn {
  font-family: "Pixelify Sans", sans-serif;
  font-weight: 600;
  min-height: 44px;
  min-width: 44px;
  padding: 10px 22px;
  border: none;
  border-radius: 10px;
  background: var(--arcade);
  color: var(--ink);
  font-size: clamp(15px, 2.6vw, 18px);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.3);
}
.btn:active { transform: translateY(2px); box-shadow: none; }

.btn.big {
  font-size: clamp(18px, 3.6vw, 24px);
  padding: 14px 34px;
  margin-top: 4px;
}

/* CTA (cover + presave button), mounted into #start-cta or #over-cta by boot.js */
.cta {
  margin-top: clamp(16px, 3vh, 24px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: clamp(12px, 2vh, 16px);
  background: var(--sand);
  border-radius: 14px;
  color: var(--ink);
}

.cta .cover {
  width: clamp(140px, 42vw, 200px);
  height: auto;
  display: block;
  border-radius: 10px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
}

.cta .presave {
  background: var(--flare);
  color: var(--foam);
}

/* Character picker (start overlay): 4 selectable tiles, >=44px touch targets. */
.char-picker {
  display: flex;
  gap: clamp(8px, 2vw, 14px);
  margin: 0 0 clamp(10px, 2vh, 16px);
}

.char-tile {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 3px;
  border: 3px solid var(--grape);
  border-radius: 10px;
  background: var(--night);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s ease, transform 0.1s ease;
}

.char-tile canvas {
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
}

.char-tile:hover { border-color: var(--sand); }

.char-tile.selected {
  border-color: var(--arcade);
  box-shadow: 0 0 10px rgba(47, 230, 214, 0.6);
}

.char-tile:active { transform: translateY(1px); }

/* Best-score line on start + game-over overlays (plain monospace so the score
   digits match the Cyrillic — VT323's digits render smaller than the fallback). */
.best {
  font-family: monospace;
  font-size: clamp(17px, 3.4vw, 22px);
  color: var(--sun);
  margin: 0 0 clamp(10px, 2vh, 16px);
}

/* Pre-game controls manual (Task 24): static, always shown on #start. */
.manual {
  list-style: none;
  margin: 0 0 clamp(12px, 2.5vh, 18px);
  padding: clamp(10px, 2vh, 14px) clamp(14px, 4vw, 20px);
  display: flex;
  flex-direction: column;
  gap: clamp(6px, 1.4vh, 10px);
  background: rgba(109, 46, 139, 0.35); /* --grape scrim */
  border: 2px solid var(--grape);
  border-radius: 14px;
  max-width: 34ch;
}

.manual li {
  display: flex;
  align-items: center;
  gap: clamp(8px, 2vw, 12px);
  font-size: clamp(13px, 2.2vw, 16px);
  line-height: 1.3;
  color: var(--foam);
  text-align: left;
}

.manual-icon {
  flex: 0 0 auto;
  min-width: 1.6em;
  font-size: clamp(16px, 3vw, 20px);
  text-align: center;
}

/* Lyric-reveal popup (Task 23): sunset-styled overlay shown every N points,
   gameplay is paused (frozen scene) behind it until "Дальше" is tapped. */
.reveal-overlay {
  z-index: 20; /* above the HUD/mute button while it's up */
  background: rgba(36, 21, 57, 0.86);
}

.reveal-label {
  /* Clean monospace, same as the "Очки"/"Рекорд" line (the pixel body font was
     hard to read for a full sentence); the stylised look stays on the lyric line. */
  font-family: monospace;
  color: var(--sun);
  font-size: clamp(16px, 3.4vw, 22px);
  line-height: 1.4;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

.reveal-line {
  font-family: "Handjet", sans-serif;
  font-weight: 700;
  color: var(--foam);
  text-shadow: 0 0 14px rgba(255, 93, 115, 0.5);
  font-size: clamp(22px, 5.5vw, 36px);
  line-height: 1.25;
  max-width: 30ch;
  margin: 0 0 clamp(18px, 3.5vh, 28px);
}

/* Presave modal (Task 26): opened by the CTA button on both variants.
   Deliberately NOT sunset-styled — a plain white "bandlink" look. */
.presave-overlay {
  z-index: 25; /* above the HUD/mute button and the reveal popup */
  background: rgba(0, 0, 0, 0.6);
}

.presave-card {
  position: relative;
  width: 100%;
  max-width: 360px;
  max-height: 90vh;
  overflow-y: auto;
  background: #fff;
  color: #222;
  border-radius: 14px;
  padding: clamp(16px, 3vh, 22px) clamp(14px, 4vw, 20px) clamp(18px, 3vh, 24px);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}

.presave-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border: none;
  background: transparent;
  color: #888;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.presave-close:hover { color: #333; }

.presave-cover {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 10px;
  margin: 0 0 12px;
}

.presave-title {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #222;
  text-shadow: none;
  letter-spacing: normal;
  font-size: clamp(18px, 4vw, 22px);
  font-weight: 700;
  margin: 0 0 2px;
  text-align: left;
}

/* Release name under the «Пресейв» heading (Дела поважнее — 19). */
.presave-release {
  margin: 0 0 14px;
  font-size: clamp(13px, 3.2vw, 15px);
  color: #666;
  text-align: left;
}

.presave-services {
  list-style: none;
  margin: 0;
  padding: 0;
}

.bl-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 44px;
  padding: 12px 14px;
  margin: 8px 0;
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.bl-row:hover { border-color: #d0d0d0; background: #fafafa; }
.bl-row:active { transform: translateY(1px); }

.bl-name {
  font-size: clamp(14px, 3.6vw, 16px);
  color: #222;
  text-align: left;
}

.el-link__action {
  font-size: clamp(13px, 3.4vw, 15px);
  font-weight: 600;
  color: #4a7dff;
}

.el-link__action_disabled {
  color: #9aa0a6;
  cursor: default;
}

/* Landscape: keep overlays from feeling cramped in short viewports */
@media (orientation: landscape) and (max-height: 480px) {
  .overlay { justify-content: center; gap: 4px; }
  h1 { font-size: clamp(20px, 5vw, 32px); margin-bottom: 4px; }
  p { margin-bottom: 8px; }
  .cta { margin-top: 8px; padding: 8px; flex-direction: row; gap: 12px; }
  .char-picker { margin-bottom: 6px; }
  .best { margin-bottom: 6px; }
  .reveal-line { font-size: clamp(18px, 4vw, 26px); margin-bottom: 10px; }
  .manual { padding: 6px 10px; gap: 3px; margin-bottom: 6px; }
  .manual li { font-size: clamp(11px, 2vw, 13px); }
}
