:root {
  --green-primary: #1B4332;
  --green-mid: #2D6A4F;
  --cream: #FFFEF5;
  --bg: #0a1210;
  --card: #1a2e26;
  --card-2: #234A3E;
  --ink: #FFFEF5;
  --muted: #a8b5ad;
  --primary: #2D6A4F;
  --emerald: #2D6A4F;
  --danger: #ef4444;
  --border: rgba(45,106,79,.35);
}
*,
*::before,
*::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Kalam', cursive, system-ui, sans-serif;
  background: radial-gradient(circle at 20% 0%, #1B4332 0%, var(--bg) 45%, #040a08 100%);
  color: var(--ink);
  min-height: 100vh;
}
body[data-mode="puzzle"] {
  background:
    radial-gradient(circle at 12% 0%, rgba(180,83,9,.32), transparent 45%),
    radial-gradient(circle at 85% 8%, rgba(120,53,15,.36), transparent 48%),
    linear-gradient(180deg, #1a120a, #0f0a06 70%);
}
body[data-mode="puzzle"] .arena-card,
body[data-mode="puzzle"] .status-card,
body[data-mode="puzzle"] .hud span {
  background: linear-gradient(180deg, #2a1b10, #1b120b);
  border-color: rgba(251,191,36,.28);
}
body[data-mode="puzzle"] .memory-cell {
  background: linear-gradient(180deg, #5b3a21, #3e2817);
  border-color: rgba(251,191,36,.28);
  color: #fde68a;
  box-shadow: inset 0 -3px 0 rgba(0,0,0,.2);
}
body[data-mode="puzzle"] .memory-cell.chain {
  background: linear-gradient(135deg, #d97706, #f59e0b);
  border-color: rgba(255,251,235,.8);
  color: #1f1307;
}
body[data-mode="puzzle"] .memory-cell.boom {
  background: linear-gradient(135deg, #fde68a, #fbbf24);
  border-color: rgba(255,255,255,.95);
}
.player-nav {
  position: sticky;
  top: 0;
  z-index: 30;
  height: 72px;
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(13,24,20,.92);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
}
.back-link { font-family: 'Kalam', cursive, sans-serif; color: var(--muted); font-size: 0.84rem; font-weight: 500; }
.player-title-wrap { text-align: center; }
.player-title-wrap h1 {
  font-family: 'Lora', serif;
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 2px;
}
.player-title-wrap p { color: var(--muted); font-size: 0.72rem; }
.btn-mini {
  font-family: 'DM Sans', sans-serif;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--primary), #3D8060);
  color: #fff;
  min-height: 36px;
  padding: 0 14px;
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
}
.player-main {
  max-width: 1120px;
  margin: 0 auto;
  padding: 16px;
  display: grid;
  gap: 12px;
}
.hud {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.hud span {
  font-family: 'DM Sans', sans-serif;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card);
  color: #E8F0EC;
  padding: 8px 10px;
  font-size: 0.76rem;
  font-weight: 600;
}
.arena-card {
  border-radius: 16px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, var(--card), #0d1330);
  box-shadow: 0 14px 30px rgba(3,7,20,.45);
  padding: 12px;
}
#arena-canvas {
  width: 100%;
  max-width: 100%;
  border-radius: 12px;
  border: 1px solid rgba(45,106,79,.2);
  background: linear-gradient(180deg, #0c1230, #091028);
}
.status-card {
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card);
  padding: 10px 12px;
  color: #cfd8ff;
  font-size: 0.84rem;
}

.forge {
  display: grid;
  gap: 10px;
  padding: 12px;
}
.forge-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--card-2);
}
.forge-row span { color: var(--muted); font-size: 0.8rem; }
.forge-row strong { font-family: 'DM Sans', sans-serif; font-size: 1.05rem; font-weight: 600; }
.forge-actions {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}
.forge-btn {
  min-height: 42px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.04);
  color: #E8F0EC;
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
}

.memory {
  padding: 12px;
}
.memory-guide {
  color: var(--muted);
  font-size: 0.84rem;
  margin-bottom: 10px;
}
.worm-hud {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}
.worm-hud span {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255,255,255,.03);
  color: #E8F0EC;
  font-size: 0.74rem;
  font-weight: 700;
  padding: 8px 9px;
}
.worm-hud strong { color: #fef08a; }
.memory-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}
.memory-cell {
  min-height: 62px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, #1c2350, #141a3c);
  color: #c7d2fe;
  font-size: 1.02rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform .12s ease, border-color .12s ease, box-shadow .12s ease;
}
.memory-cell:hover {
  transform: translateY(-1px);
  border-color: rgba(45,106,79,.58);
  box-shadow: 0 8px 16px rgba(4,8,22,.4);
}
.memory-cell.flash {
  background: linear-gradient(135deg, rgba(109,93,252,.75), rgba(236,72,153,.65));
  border-color: rgba(255,255,255,.6);
  color: #fff;
}
.memory-cell.chain {
  background: linear-gradient(135deg, rgba(16,185,129,.62), rgba(52,211,153,.52));
  border-color: rgba(110,231,183,.86);
  color: #fff;
}
.memory-cell.boom {
  background: linear-gradient(135deg, rgba(250,204,21,.7), rgba(249,115,22,.62));
  border-color: rgba(255,255,255,.9);
  color: #1A1A1A;
}

@media (max-width: 760px) {
  .player-nav { padding: 0 10px; }
  .player-title-wrap h1 { font-size: 0.88rem; }
  .hud { grid-template-columns: 1fr 1fr; }
  .forge-actions { grid-template-columns: repeat(2, 1fr); }
  .worm-hud { grid-template-columns: 1fr; }
  .memory-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .memory-cell { min-height: 58px; }
}
