:root {
  --bg: #020617;
  --bg-soft: #020617;
  --card: #020617;
  --card-elevated: #020617;
  --accent: #38bdf8;
  --accent-soft: #0ea5e9;
  --accent-muted: #7dd3fc;
  --danger: #ef4444;
  --success: #22c55e;
  --border-subtle: #1f2937;
  --text: #e5e7eb;
  --text-muted: #9ca3af;
  --shadow-soft: 0 18px 45px rgba(15, 23, 42, 0.7);
  --radius-card: 18px;
  --radius-pill: 999px;
  --radius-soft: 10px;
  --transition-fast: 0.18s ease-out;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top, #020617 0, #020617 40%, #020617 100%);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.app {
  width: 100%;
  max-width: 640px;
}

#game.game-card {
  background: linear-gradient(145deg, #020617 0%, #020617 50%, #020617 100%);
  border-radius: var(--radius-card);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-soft);
  padding: 20px 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: relative;
  overflow: hidden;
}

#game::before {
  content: "";
  position: absolute;
  inset: -40%;
  background: radial-gradient(circle at top right, rgba(56, 189, 248, 0.16), transparent 55%);
  opacity: 0.8;
  pointer-events: none;
}

.game-header {
  position: relative;
  z-index: 1;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 10px;
  margin-bottom: 4px;
}

.game-header h1 {
  margin: 0 0 4px;
  font-size: 1.4rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 8px;
}

.game-header h1::before {
  content: "⚔️";
  font-size: 1.1rem;
}

.tagline {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

#stats.stats {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  padding: 8px 10px;
  border-radius: var(--radius-soft);
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.88), rgba(15, 23, 42, 0.96));
  border: 1px solid var(--border-subtle);
}

.stat {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.stat strong {
  color: var(--accent-muted);
}

#controls.controls {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

button {
  cursor: pointer;
  border-radius: var(--radius-soft);
  border: 1px solid rgba(56, 189, 248, 0.5);
  background: radial-gradient(circle at top, var(--accent) 0, var(--accent-soft) 45%, #0369a1 100%);
  color: #0b1120;
  font-weight: 600;
  font-size: 0.85rem;
  padding: 10px 8px;
  transition:
    transform var(--transition-fast),
    box-shadow var(--transition-fast),
    background 0.2s ease-out,
    border-color 0.2s ease-out;
  box-shadow: 0 10px 24px rgba(56, 189, 248, 0.3);
  white-space: normal;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 32px rgba(56, 189, 248, 0.45);
  border-color: #e0f2fe;
}

button:active {
  transform: translateY(0);
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.7);
}

button:focus-visible {
  outline: 2px solid #e0f2fe;
  outline-offset: 2px;
}

#monsterStats.monster-stats {
  position: relative;
  z-index: 1;
  display: none;
  padding: 8px 10px;
  border-radius: var(--radius-soft);
  background: radial-gradient(circle at left, rgba(239, 68, 68, 0.22), rgba(15, 23, 42, 0.98));
  border: 1px solid rgba(239, 68, 68, 0.7);
  font-size: 0.86rem;
}

#monsterStats .stat strong {
  color: #fecaca;
}

#text.log {
  position: relative;
  z-index: 1;
  background: radial-gradient(circle at top left, rgba(15, 23, 42, 0.9), rgba(15, 23, 42, 0.98));
  color: var(--text);
  padding: 10px 11px;
  border-radius: var(--radius-soft);
  border: 1px solid var(--border-subtle);
  font-size: 0.9rem;
  line-height: 1.4;
  max-height: 180px;
  overflow-y: auto;
  white-space: pre-line;
}

#text strong {
  color: var(--accent-muted);
}

#text::-webkit-scrollbar {
  width: 6px;
}

#text::-webkit-scrollbar-track {
  background: transparent;
}

#text::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.6);
  border-radius: 999px;
}

.game-footer {
  position: relative;
  z-index: 1;
  margin-top: 2px;
  padding-top: 6px;
  border-top: 1px solid var(--border-subtle);
  text-align: right;
}

.game-footer small {
  font-size: 0.75rem;
  color: var(--text-muted);
}

@media (max-width: 520px) {
  #game.game-card {
    padding: 16px 14px 12px;
  }

  .game-header h1 {
    font-size: 1.25rem;
  }

  #controls.controls {
    grid-template-columns: 1fr;
  }

  #text.log {
    max-height: 200px;
  }
}
