:root {
  --bg-deep: #5c94fc;
  --bg-ground: #c84c0c;
  --accent: #e45b10;
  --gold: #fcbc00;
  --text: #ffffff;
  --text-shadow: #000000;
  --card: rgba(0, 0, 0, 0.82);
  --border: #fcfcfc;
  --sky-top: #5c94fc;
  --sky-bot: #3878d8;
}

@font-face {
  font-family: "PixelFallback";
  src: local("Press Start 2P"), local("Courier New");
}

* {
  box-sizing: border-box;
  image-rendering: pixelated;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg-deep);
  font-family: "Press Start 2P", "Courier New", monospace;
  color: var(--text);
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  overscroll-behavior: none;
  position: fixed;
  inset: 0;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  margin: 0 auto;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--sky-top);
  touch-action: none;
}

#ui-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

#ui-overlay .screen,
#ui-overlay .hud,
#ui-overlay .overlay-message {
  pointer-events: auto;
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  text-align: center;
  background: rgba(0, 0, 0, 0.78);
}

.screen.active {
  display: flex;
}

.title-flare {
  display: none;
}

.game-title {
  font-family: "Press Start 2P", monospace;
  font-size: clamp(1rem, 3.5vw, 1.6rem);
  margin: 0 0 0.75rem;
  color: #fcbc00;
  text-shadow:
    3px 3px 0 #000,
    -1px -1px 0 #000,
    1px -1px 0 #000,
    -1px 1px 0 #000;
  position: relative;
  z-index: 1;
  line-height: 1.6;
}

.subtitle {
  margin: 0 0 1.25rem;
  color: #fcfcfc;
  font-size: clamp(0.45rem, 1.6vw, 0.65rem);
  text-shadow: 2px 2px 0 #000;
  line-height: 1.8;
}

.title-stats {
  font-size: clamp(0.45rem, 1.5vw, 0.6rem);
  margin-bottom: 1.5rem;
  padding: 0.75rem 1rem;
  background: #000;
  border: 4px solid #fcbc00;
  line-height: 2;
  text-shadow: 1px 1px 0 #000;
}

.btn {
  font-family: "Press Start 2P", monospace;
  font-size: clamp(0.5rem, 1.6vw, 0.7rem);
  padding: 0.85rem 1.5rem;
  margin: 0.35rem;
  border: 4px solid #fcfcfc;
  cursor: pointer;
  text-shadow: 2px 2px 0 #000;
  transition: transform 0.08s ease;
  line-height: 1.5;
}

.btn:active {
  transform: scale(0.95);
}

.btn:hover {
  border-color: #fcbc00;
}

.btn-primary {
  background: #e45b10;
  color: #fcfcfc;
  border-color: #fcbc00;
}

.btn-secondary {
  background: #006800;
  color: #fcfcfc;
  border-color: #00a800;
}

.btn-ghost {
  background: transparent;
  color: #b0b0b0;
  border-color: #585858;
}

.screen h2 {
  font-family: "Press Start 2P", monospace;
  font-size: clamp(0.7rem, 2.5vw, 1rem);
  margin-top: 0;
  margin-bottom: 0.75rem;
  color: #fcbc00;
  text-shadow: 2px 2px 0 #000;
  line-height: 1.6;
}

.hint {
  max-width: 26rem;
  color: #b0b0b0;
  margin-bottom: 1rem;
  font-size: clamp(0.4rem, 1.3vw, 0.55rem);
  line-height: 2;
}

.hero-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 0.5rem;
  width: 100%;
  max-width: 560px;
  max-height: min(55vh, 400px);
  overflow-y: auto;
  padding: 0.25rem;
  margin-bottom: 1rem;
}

.hero-card {
  background: #1a1a2e;
  border: 3px solid #585858;
  padding: 0.6rem;
  cursor: pointer;
  transition: border-color 0.1s;
}

.hero-card:hover {
  border-color: #fcfcfc;
}

.hero-card.selected {
  border-color: #fcbc00;
  background: #2a2a1e;
  box-shadow: inset 0 0 0 2px #fcbc0044;
}

.hero-card.locked {
  opacity: 0.5;
}

.hero-thumb {
  display: block;
  margin: 0 auto 0.25rem;
  width: 52px;
  height: 52px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.hero-name {
  font-family: "Press Start 2P", monospace;
  font-size: 0.5rem;
  margin-top: 0.4rem;
  line-height: 1.5;
  color: #fcfcfc;
  text-shadow: 1px 1px 0 #000;
}

.hero-meta {
  font-size: 0.45rem;
  color: #fcbc00;
  margin-top: 0.3rem;
  line-height: 1.4;
}

.how-list {
  text-align: left;
  max-width: 24rem;
  line-height: 2.2;
  font-size: clamp(0.4rem, 1.3vw, 0.55rem);
}

.how-list li {
  margin-bottom: 0.4rem;
}

.row-actions {
  margin-top: auto;
}

.hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 0.5rem 0.75rem;
  font-size: 0.55rem;
  text-shadow: 2px 2px 0 #000;
}

.hud.hidden {
  display: none;
}

.hud-shell {
  display: block;
  margin-top: 0.3rem;
  color: #40b828;
  font-size: 0.45rem;
  animation: shellPulse 0.6s ease infinite alternate;
}

@keyframes shellPulse {
  from { opacity: 0.7; }
  to { opacity: 1; }
}

.hud-left, .hud-right {
  background: rgba(0, 0, 0, 0.7);
  padding: 0.35rem 0.65rem;
  border: 3px solid #fcbc00;
}

.hud-label {
  display: block;
  font-size: 0.4rem;
  color: #b0b0b0;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  line-height: 1.5;
}

#hud-level {
  font-family: "Press Start 2P", monospace;
  font-size: 0.9rem;
  color: #fcbc00;
}

.hud-center {
  flex: 1;
  text-align: center;
  padding: 0.4rem 0.5rem;
  font-size: 0.5rem;
  color: #fcfcfc;
  line-height: 1.6;
}

.overlay-message {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.8);
  padding: 1rem;
}

.overlay-message.hidden {
  display: none;
}

.message-card {
  background: #000;
  border: 4px solid #fcbc00;
  padding: 1.25rem 1.5rem;
  max-width: 22rem;
  width: 100%;
}

.message-card h2 {
  margin: 0 0 0.6rem;
  font-family: "Press Start 2P", monospace;
  font-size: 0.8rem;
  color: #fcbc00;
  text-shadow: 2px 2px 0 #333;
  line-height: 1.6;
}

.message-card p {
  margin: 0 0 1rem;
  line-height: 2;
  font-size: 0.5rem;
  color: #fcfcfc;
}

.message-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
}

.message-actions .btn {
  margin: 0;
}

/* Touch controls for iPad / mobile */
.touch-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  padding: env(safe-area-inset-bottom, 12px) 16px 16px;
  pointer-events: none;
  z-index: 50;
}

.touch-controls.hidden {
  display: none;
}

.touch-btn {
  pointer-events: auto;
  font-family: "Press Start 2P", monospace;
  font-size: 0.7rem;
  border: 4px solid rgba(255,255,255,0.5);
  background: rgba(0,0,0,0.45);
  color: rgba(255,255,255,0.85);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.touch-btn:active {
  background: rgba(255,255,255,0.25);
  border-color: rgba(255,255,255,0.8);
}

.touch-jump {
  width: clamp(80px, 22vw, 130px);
  height: clamp(80px, 22vw, 130px);
  border-radius: 50%;
}

.touch-throw {
  width: clamp(65px, 18vw, 100px);
  height: clamp(65px, 18vw, 100px);
  border-radius: 50%;
  border-color: rgba(64, 184, 40, 0.6);
  color: rgba(64, 184, 40, 0.85);
}

.touch-throw.has-shell {
  border-color: rgba(64, 184, 40, 0.9);
  background: rgba(64, 184, 40, 0.25);
  color: #fcfcfc;
}
