* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; background: #05080f; color: #e8e4d8;
  font-family: -apple-system, system-ui, sans-serif; overflow: hidden;
}

#title-screen {
  position: fixed; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 18px;
  background: radial-gradient(ellipse at center, #0d2436 0%, #05080f 75%);
  padding: 24px; text-align: center;
}

#title-screen img.logo {
  width: 96px; height: 96px; border-radius: 18px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}

#title-screen h1 {
  margin: 0; font-size: 26px; font-weight: 700; color: #f2d98a;
  letter-spacing: 0.5px; text-shadow: 0 2px 6px rgba(0,0,0,0.6);
}
#title-screen .subtitle {
  margin-top: -12px; font-size: 13px; color: #9fb8c4; letter-spacing: 1px;
  text-transform: uppercase;
}

.menu-buttons { display: flex; flex-direction: column; gap: 10px; width: 220px; margin-top: 8px; }
.menu-buttons button {
  font: 600 16px/1 -apple-system, system-ui, sans-serif; padding: 14px 0;
  background: rgba(255,255,255,0.06); color: #e8e4d8;
  border: 1px solid rgba(242,217,138,0.35); border-radius: 10px;
  -webkit-tap-highlight-color: transparent;
}
.menu-buttons button:active { background: rgba(242,217,138,0.18); }
.menu-buttons button:disabled { opacity: 0.4; }
.menu-buttons button.primary { background: rgba(242,217,138,0.85); color: #1a1408; border-color: transparent; }
.menu-buttons button.primary:active { background: rgba(242,217,138,1); }
.menu-buttons button.selected { border-color: #f2d98a; background: rgba(242,217,138,0.22); box-shadow: 0 0 0 1px #f2d98a inset; }

#version-badge {
  position: absolute; bottom: 10px; right: 10px; padding: 8px;
  color: rgba(255,255,255,0.5); font-size: 13px; font-weight: 600;
  background: none; border: none;
}
#refresh-button {
  position: absolute; bottom: 6px; right: 66px; width: 34px; height: 34px;
  color: rgba(255,255,255,0.55); font-size: 18px; line-height: 1;
  background: none; border: none; -webkit-tap-highlight-color: transparent;
}
#refresh-button:active { color: #f2d98a; }
#refresh-button.spinning { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

#game-screen {
  position: fixed; inset: 0; background: #000; display: none;
  align-items: center; justify-content: center;
  box-sizing: border-box;
  /* Keep the picture out from under the notch / Dynamic Island / home bar. */
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
}
/* 4:3 wrapper sized by JS (fitCanvas); the canvas fills it, so the game keeps
   its proportions in both orientations instead of stretching. */
#canvas-wrap { position: relative; line-height: 0; }
#canvas { display: block; width: 100%; height: 100%; }

/* In-game overlay: Skip / Save-Load / Keyboard / Help. Deliberately faint so
   they don't compete with the game's own UI. */
#game-overlay {
  position: absolute; top: calc(6px + env(safe-area-inset-top));
  right: calc(6px + env(safe-area-inset-right));
  display: flex; gap: 6px; z-index: 10;
}
#game-overlay button {
  width: 38px; height: 38px; border-radius: 10px; border: none;
  background: rgba(255,255,255,0.10); color: rgba(255,255,255,0.7);
  font-size: 17px; line-height: 1; -webkit-tap-highlight-color: transparent;
}
#game-overlay button:active { background: rgba(255,255,255,0.28); }
#help-button { font-weight: 700; }

/* Help modal control glyphs */
.help-list { list-style: none; margin: 0; padding: 0; }
.help-list li { margin-bottom: 10px; font-size: 14px; line-height: 1.45; color: #cbd5df; }
.help-list .ctl {
  display: inline-block; min-width: 24px; text-align: center; margin-right: 4px;
  padding: 1px 4px; border-radius: 6px; background: rgba(255,255,255,0.12);
}

/* Hidden input used to summon the iOS keyboard; kept on-screen (1px) so
   focusing it is allowed, but invisible. */
#keyboard-proxy {
  position: absolute; bottom: 0; left: 0; width: 1px; height: 1px;
  opacity: 0.01; border: none; padding: 0; background: transparent; color: transparent;
}

/* Download progress for the one-time game data fetch */
#progress {
  display: none; width: 220px; height: 6px; border-radius: 3px;
  background: rgba(255,255,255,0.12); overflow: hidden;
}
#progress-bar {
  width: 0%; height: 100%; border-radius: 3px;
  background: #f2d98a; transition: width 0.2s linear;
}

/* Boot overlay over the game canvas (download / startup progress) */
#boot-overlay {
  position: absolute; inset: 0; display: none; z-index: 15;
  flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  background: radial-gradient(ellipse at center, #0d2436 0%, #05080f 80%);
  padding: 24px; text-align: center;
  opacity: 1; transition: opacity 0.4s ease;
}
#boot-overlay .boot-logo {
  width: 84px; height: 84px; border-radius: 16px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
#boot-progress {
  width: 240px; max-width: 70vw; height: 8px; border-radius: 4px;
  background: rgba(255,255,255,0.12); overflow: hidden; visibility: hidden;
}
#boot-progress-bar {
  width: 0%; height: 100%; border-radius: 4px;
  background: #f2d98a; transition: width 0.25s linear;
}
#boot-note { font-size: 14px; font-weight: 600; color: #e8e4d8; }
#boot-overlay .boot-hint {
  font-size: 12px; line-height: 1.5; color: #7d8b95; max-width: 300px;
}

/* Resume overlay (game froze while backgrounded) */
#resume-overlay {
  position: fixed; inset: 0; display: none; z-index: 18;
  flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  background: radial-gradient(ellipse at center, #0d2436 0%, #05080f 80%);
  padding: 24px; text-align: center;
}
#resume-overlay .resume-title { font-size: 20px; font-weight: 700; color: #f2d98a; }
#resume-overlay .resume-text { font-size: 14px; line-height: 1.5; color: #cbd5df; max-width: 300px; }
#resume-overlay #resume-button {
  font: 600 16px/1 -apple-system, system-ui, sans-serif; padding: 14px 28px;
  background: rgba(242,217,138,0.85); color: #1a1408; border: none; border-radius: 10px;
  -webkit-tap-highlight-color: transparent;
}
#resume-overlay #resume-button:active { background: rgba(242,217,138,1); }

/* Resume pill (dismissible "stuck?" hint after a long break) */
#resume-pill {
  position: absolute; z-index: 12; left: 50%; transform: translateX(-50%);
  top: calc(8px + env(safe-area-inset-top)); max-width: 90%;
  display: none; padding: 9px 14px; border-radius: 20px; border: none;
  font: 600 13px/1.2 -apple-system, system-ui, sans-serif;
  background: rgba(242,217,138,0.92); color: #1a1408;
  box-shadow: 0 4px 14px rgba(0,0,0,0.5); -webkit-tap-highlight-color: transparent;
}
#resume-pill.show { display: block; }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7); display: none;
  align-items: center; justify-content: center; z-index: 20; padding: 24px;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: #101826; border: 1px solid rgba(242,217,138,0.3); border-radius: 12px;
  padding: 20px; max-width: 360px; width: 100%; max-height: 70vh; overflow-y: auto;
}
.modal-box h2 { margin-top: 0; color: #f2d98a; font-size: 18px; }
.modal-box p, .modal-box li { font-size: 14px; line-height: 1.5; color: #cbd5df; }
.modal-close {
  margin-top: 14px; width: 100%; padding: 10px; background: rgba(255,255,255,0.08);
  color: #e8e4d8; border: 1px solid rgba(255,255,255,0.2); border-radius: 8px;
}
.changelog-entry { margin-bottom: 12px; }
.changelog-entry .v { color: #f2d98a; font-weight: 700; }
.changelog-entry .d { color: #7d8b95; font-size: 12px; margin-left: 6px; }

.status-note { font-size: 13px; color: #7d8b95; margin-top: 4px; max-width: 260px; }

/* Save list in the Load Game modal */
#loadgame-list { list-style: none; margin: 0; padding: 0; }
#loadgame-list li { margin-bottom: 8px; }
.save-entry {
  width: 100%; display: flex; justify-content: space-between; align-items: center;
  gap: 10px; padding: 12px; border-radius: 8px; text-align: left;
  background: rgba(255,255,255,0.06); color: #e8e4d8;
  border: 1px solid rgba(242,217,138,0.25); -webkit-tap-highlight-color: transparent;
}
.save-entry:active { background: rgba(242,217,138,0.18); }
.save-entry .save-name { font-weight: 600; font-size: 14px; }
.save-entry .save-when { font-size: 11px; color: #7d8b95; white-space: nowrap; }
