:root {
  color-scheme: dark;
  --bg-top: #071622;
  --bg-bottom: #031018;
  --panel: rgba(8, 25, 38, 0.84);
  --panel-strong: rgba(10, 34, 51, 0.94);
  --line: rgba(143, 229, 255, 0.18);
  --text: #e8fbff;
  --muted: #9ebdcc;
  --accent: #8cf2ff;
  --accent-2: #55c4ff;
  --warn: #ff8b74;
  --success: #8affbf;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.34);
  font-family: "Avenir Next Condensed", "Trebuchet MS", "PingFang SC", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top, rgba(64, 174, 214, 0.18), transparent 28%),
    radial-gradient(circle at bottom, rgba(3, 94, 126, 0.28), transparent 34%),
    linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
  color: var(--text);
}

body {
  overflow-x: hidden;
}

button {
  border: 0;
  border-radius: 16px;
  cursor: pointer;
  font: inherit;
}

.app-shell {
  width: min(1180px, calc(100vw - 24px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 12px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.hero h1,
.panel h2 {
  margin: 0;
  font-family: "Copperplate", "STKaiti", serif;
  letter-spacing: 0.03em;
}

.subtitle {
  max-width: 640px;
  color: var(--muted);
  margin: 10px 0 0;
  line-height: 1.45;
}

.hero-actions {
  display: flex;
  gap: 10px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(320px, 460px) minmax(320px, 1fr);
  gap: 18px;
  align-items: start;
}

.game-column {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.game-frame {
  position: relative;
  background: linear-gradient(180deg, rgba(7, 24, 37, 0.75), rgba(3, 11, 18, 0.92));
  border: 1px solid var(--line);
  border-radius: 28px;
  overflow: hidden;
  box-shadow: var(--shadow);
  aspect-ratio: 1 / 2;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.panel,
.side-panel .panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 18px;
}

.wide-panel {
  width: min(94%, 760px);
}

.side-panel {
  display: grid;
  gap: 16px;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.compact-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.card {
  position: relative;
  padding: 14px;
  border-radius: 18px;
  border: 1px solid rgba(140, 242, 255, 0.16);
  background: linear-gradient(180deg, rgba(10, 31, 47, 0.9), rgba(5, 18, 28, 0.96));
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 124px;
}

.card.selected {
  outline: 2px solid var(--accent);
  transform: translateY(-2px);
}

.card.locked {
  opacity: 0.62;
}

.card button {
  margin-top: auto;
}

.tag {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(140, 242, 255, 0.12);
  color: var(--accent);
  font-size: 12px;
}

.card h3 {
  margin: 0;
  font-size: 18px;
}

.card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.35;
  font-size: 14px;
}

.primary-btn,
.ghost-btn {
  padding: 12px 18px;
  transition: transform 160ms ease, opacity 160ms ease, background 160ms ease;
}

.primary-btn:hover,
.ghost-btn:hover {
  transform: translateY(-1px);
}

.primary-btn {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #04202f;
  font-weight: 700;
}

.ghost-btn {
  background: rgba(140, 242, 255, 0.08);
  color: var(--text);
  border: 1px solid rgba(140, 242, 255, 0.18);
}

.small-btn {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
}

.touch-hint {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  padding: 0 4px;
}

.hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 14px;
}

.hud .ghost-btn,
.hud .primary-btn {
  pointer-events: auto;
}

.hud-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

.bottom-row {
  align-items: end;
}

.pill {
  min-width: 0;
  padding: 10px 12px;
  border-radius: 18px;
  background: rgba(5, 21, 31, 0.68);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(140, 242, 255, 0.18);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.pill span {
  color: var(--muted);
  font-size: 11px;
}

.pill strong {
  font-size: 14px;
}

.bar-group {
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 18px;
  background: rgba(5, 21, 31, 0.68);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(140, 242, 255, 0.18);
  display: grid;
  gap: 6px;
}

.bar-group label,
.bar-group span {
  font-size: 12px;
}

.bar-group label {
  color: var(--muted);
}

.bar {
  width: 100%;
  height: 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.fill {
  height: 100%;
  border-radius: inherit;
}

.hp-fill {
  background: linear-gradient(90deg, #ff9078, #ffc18d);
}

.growth-fill {
  background: linear-gradient(90deg, #66dcff, #b9fff2);
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(2, 8, 14, 0.62);
  backdrop-filter: blur(8px);
  padding: 16px;
}

.mutation-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.mutation-card {
  padding: 16px;
  border-radius: 20px;
  border: 1px solid rgba(140, 242, 255, 0.16);
  background: linear-gradient(180deg, rgba(13, 39, 58, 0.92), rgba(5, 18, 28, 0.98));
  text-align: left;
}

.mutation-card.common .tag {
  color: var(--accent);
}

.mutation-card.rare .tag {
  color: #ffd990;
  background: rgba(255, 217, 144, 0.12);
}

.mutation-card.legendary .tag {
  color: #ff9f8f;
  background: rgba(255, 159, 143, 0.12);
}

.meta-list,
.codex-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.meta-item,
.codex-item {
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(4, 15, 23, 0.74);
  border: 1px solid rgba(140, 242, 255, 0.1);
}

.meta-item strong,
.codex-item strong {
  display: block;
  margin-bottom: 4px;
}

.hidden {
  display: none !important;
}

@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .hero {
    flex-direction: column;
    align-items: stretch;
  }

  .game-frame {
    max-width: min(100%, 480px);
    margin: 0 auto;
  }
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100vw - 12px, 100%);
    padding-top: 12px;
  }

  .hero-actions {
    flex-wrap: wrap;
  }

  .card-grid,
  .compact-grid,
  .mutation-grid {
    grid-template-columns: 1fr;
  }
}
