:root {
  --bg: #0f1a24;
  --panel: #22334a;
  --panel-alt: #2e4b6b;
  --text: #f4f4f4;
  --accent: #ffd166;
  --accent2: #73f29f;
  --muted: #b8d0e8;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Courier New", monospace;
  color: var(--text);
  background: repeating-linear-gradient(45deg, #101a26 0 12px, #0d151f 12px 24px);
  image-rendering: pixelated;
}

.app-shell {
  max-width: 1120px;
  margin: 0 auto;
  padding: 1rem;
}

.game-header {
  text-align: center;
  margin-bottom: 1rem;
  text-shadow: 2px 2px 0 #000;
}

.panel {
  display: none;
  background: var(--panel);
  border: 3px solid #0f1926;
  border-radius: 0;
  padding: 1rem;
  box-shadow: 0 0 0 3px #3f628a, 8px 8px 0 #08111a;
}

.panel.active { display: block; }

.primary {
  background: var(--accent);
  color: #0f1d2f;
  border: 2px solid #1e2e46;
}

button {
  border: 2px solid #101a26;
  color: var(--text);
  background: #3a5683;
  border-radius: 0;
  padding: 0.65rem 1rem;
  cursor: pointer;
  font-weight: 700;
  font-family: inherit;
  text-transform: uppercase;
}

button:hover { transform: translate(-1px, -1px); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.hint { margin-top: 0.6rem; color: var(--muted); }

.character-grid,
.level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem;
  margin: 0.75rem 0 1rem;
}

.card {
  border: 2px solid #162334;
  background: linear-gradient(180deg, #365987, var(--panel-alt));
  padding: 0.7rem;
}

.card.selected { outline: 3px solid var(--accent2); }
.card h3 { margin: 0 0 0.2rem; }
.card p { margin: 0.2rem 0; color: #e7f0ff; font-size: 0.9rem; }

.stats-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.25rem;
}

.stat-dot {
  height: 8px;
  background: #203752;
}

.stat-dot.fill { background: var(--accent2); }

.actions { display: flex; gap: 0.5rem; }

.game-panel { position: relative; padding: 0.75rem; }

#gameCanvas {
  width: 100%;
  max-width: 960px;
  display: block;
  margin: 0 auto;
  border: 4px solid #111;
  background: #9ed9ff;
  image-rendering: pixelated;
}

.hud {
  margin-top: 0.6rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.4rem;
}

.hud-card {
  background: #102238;
  border: 2px solid #35577f;
  padding: 0.4rem 0.55rem;
  font-size: 0.86rem;
}

.mobile-controls {
  margin-top: 0.8rem;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.4rem;
  background: rgba(10, 22, 36, 0.75);
  border: 2px solid #365b85;
  padding: 0.4rem;
}

.ability-panel {
  margin-top: 0.5rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.35rem;
}

.ability-card {
  background: #101d2f;
  border: 2px solid #33577f;
  padding: 0.35rem 0.45rem;
  font-size: 0.8rem;
}

@media (max-width: 800px) {
  .mobile-controls { grid-template-columns: repeat(2, 1fr); }
}


.score-list {
  margin: 0.5rem 0 0;
  padding-left: 1.2rem;
  background: #0d1726;
  border: 2px solid #274362;
  min-height: 120px;
}

.score-list li {
  padding: 0.25rem 0;
  font-size: 0.82rem;
}

.mobile-tip {
  margin-top: 0.5rem;
  color: #ffe082;
  font-size: 0.82rem;
}

body.mobile-device .app-shell {
  padding: 0.5rem;
}

body.mobile-device .panel {
  padding: 0.75rem;
}

body.mobile-device .actions {
  flex-wrap: wrap;
}

body.mobile-device button {
  min-height: 46px;
  font-size: 0.88rem;
}

body.mobile-device .mobile-controls {
  display: grid;
  position: sticky;
  bottom: 0;
  background: rgba(10, 22, 36, 0.9);
  border: 2px solid #365b85;
  padding: 0.4rem;
}

body.mobile-device .mobile-controls button {
  min-height: 54px;
  font-size: 0.9rem;
}

body.mobile-device .hud {
  grid-template-columns: repeat(2, minmax(130px, 1fr));
}

@media (max-width: 560px) {
  body.mobile-device .character-grid,
  body.mobile-device .level-grid {
    grid-template-columns: 1fr;
  }
}
