:root {
  --bg: #10240f;
  --ink: #fff6e0;
  --muted: #c9b48a;
  --accent: #ffd24a;
  --hot: #ff5a3c;
  --elixir: #c56bff;
  --card: rgba(18, 12, 8, 0.9);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", "Avenir Next", Futura, system-ui, sans-serif;
  user-select: none;
  touch-action: none;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}

#hud-left { position: absolute; top: 14px; left: 16px; }

#brand {
  font-weight: 800;
  letter-spacing: 0.32em;
  font-size: 13px;
  color: var(--accent);
}

#you-tag {
  margin-top: 4px;
  font-size: 18px;
  font-weight: 700;
}

#hud-center {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
}

#clock {
  font-weight: 800;
  letter-spacing: 0.14em;
  font-size: 22px;
  text-shadow: 0 2px 12px #000;
}

#toast {
  min-height: 1.2em;
  margin-top: 6px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--accent);
  text-shadow: 0 2px 12px #000;
}

#hud-right {
  position: absolute;
  top: 14px;
  right: 16px;
  text-align: right;
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--muted);
}

#bot-style { margin-top: 4px; color: var(--hot); font-weight: 700; }

#legend {
  position: fixed;
  top: 64px;
  left: 12px;
  z-index: 3;
  width: 196px;
  pointer-events: none;
  padding: 8px 8px 6px;
  background: rgba(10, 14, 8, 0.62);
  border: 1px solid rgba(255, 210, 74, 0.16);
  text-shadow: 0 1px 6px #000;
}

.legend-title {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.18em;
  color: var(--accent);
  margin: 2px 0 5px;
}

.legend-title.aoe {
  margin-top: 8px;
  color: #ff9a4a;
  border-top: 1px solid rgba(255, 154, 74, 0.28);
  padding-top: 7px;
}

.leg-row {
  display: grid;
  grid-template-columns: 8px 1fr auto;
  gap: 5px;
  align-items: center;
  font-size: 10px;
  line-height: 1.35;
  margin-bottom: 2px;
}

.leg-row i {
  width: 8px;
  height: 8px;
  display: block;
}

.leg-row.aoe i {
  transform: rotate(45deg);
  background: conic-gradient(#ffd24a, #ff5a3c) !important;
}

.leg-row b { font-weight: 800; letter-spacing: 0.06em; }

.leg-cost {
  font-weight: 800;
  color: var(--elixir);
}

.leg-row em {
  grid-column: 2 / -1;
  font-style: normal;
  font-size: 16px;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-top: -1px;
  margin-bottom: 4px;
  line-height: 1.2;
}

#tray {
  position: fixed;
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
  z-index: 3;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  pointer-events: none;
}

#elixir-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 28px;
}

#elixir-bar {
  width: 16px;
  height: 92px;
  border: 1px solid rgba(197, 107, 255, 0.45);
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: flex-end;
  overflow: hidden;
}

#elixir-fill {
  display: block;
  width: 100%;
  height: 50%;
  background: linear-gradient(#efc2ff, var(--elixir));
  box-shadow: 0 0 12px rgba(197, 107, 255, 0.55);
}

#elixir-n {
  font-weight: 800;
  font-size: 18px;
  color: var(--elixir);
}

#cards {
  display: flex;
  gap: 7px;
  pointer-events: auto;
}

.card {
  width: 78px;
  min-height: 108px;
  padding: 8px 6px 8px;
  background: var(--card);
  border: 1px solid rgba(255, 210, 74, 0.22);
  color: var(--ink);
  cursor: pointer;
  position: relative;
  text-align: center;
}

.card kbd {
  position: absolute;
  top: 6px;
  left: 7px;
  font-size: 10px;
  color: var(--muted);
}

.card .cost {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 26px;
  height: 26px;
  padding: 0 4px;
  display: grid;
  place-items: center;
  font-size: 16px;
  font-weight: 800;
  color: #f4d8ff;
  background: radial-gradient(circle at 40% 30%, #d38cff, #7a2bb8 70%);
  border: 1px solid rgba(255, 220, 255, 0.45);
  box-shadow: 0 0 10px rgba(197, 107, 255, 0.45);
  line-height: 1;
}

.card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 8px 22px rgba(0, 0, 0, 0.4);
  transform: translateY(-6px);
}

.card.poor { opacity: 0.42; }

.card.aoe {
  border-color: rgba(255, 154, 74, 0.55);
  background: linear-gradient(180deg, rgba(50, 18, 8, 0.95), rgba(18, 12, 8, 0.92));
}

.card.aoe.selected {
  border-color: #ff9a4a;
  box-shadow: 0 0 0 1px #ff9a4a, 0 8px 22px rgba(0, 0, 0, 0.4);
}

.glyph {
  width: 30px;
  height: 30px;
  margin: 18px auto 6px;
  background: var(--accent);
}

.glyph-aoe {
  width: 26px;
  height: 26px;
  margin: 20px auto 6px;
  transform: rotate(45deg);
  box-shadow: 0 0 12px rgba(255, 154, 74, 0.55);
  border: 1px solid rgba(255, 240, 180, 0.5);
}

.card-name {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.1em;
}

.aoe-tag {
  margin-top: 3px;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.16em;
  color: #ff9a4a;
}

#next-wrap {
  width: 54px;
  text-align: center;
  opacity: 0.85;
}

#next-label {
  font-size: 9px;
  letter-spacing: 0.16em;
  color: var(--muted);
  margin-bottom: 4px;
}

#next-card {
  height: 64px;
  background: var(--card);
  border: 1px dashed rgba(255, 255, 255, 0.18);
  display: grid;
  place-items: center;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.08em;
  padding: 4px;
}

#hint {
  position: fixed;
  left: 50%;
  bottom: 122px;
  transform: translateX(-50%);
  z-index: 3;
  font-size: 11px;
  color: var(--muted);
  text-shadow: 0 2px 8px #000;
  pointer-events: none;
  white-space: nowrap;
}

#splash, #over {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  background: radial-gradient(ellipse at 50% 28%, rgba(255, 210, 74, 0.14), transparent 55%),
              rgba(8, 14, 8, 0.78);
}

#over.hidden, #splash.hidden { display: none; }

.splash-card {
  width: min(420px, 90vw);
  padding: 28px 28px 24px;
  background: var(--card);
  border: 1px solid rgba(255, 210, 74, 0.3);
  text-align: center;
}

.kicker {
  letter-spacing: 0.28em;
  font-size: 11px;
  font-weight: 800;
  color: var(--accent);
}

.splash-card h1 {
  font-size: 52px;
  letter-spacing: 0.12em;
  margin: 8px 0 6px;
}

.tag { color: var(--muted); margin-bottom: 18px; }

label {
  display: block;
  text-align: left;
  font-size: 11px;
  letter-spacing: 0.16em;
  color: var(--muted);
  margin-bottom: 14px;
}

input {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  background: #120e08;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--ink);
  font: inherit;
  outline: none;
}

button { font: inherit; cursor: pointer; }

#play, #again {
  width: 100%;
  padding: 12px;
  background: var(--accent);
  color: #2a1a00;
  border: 0;
  font-weight: 800;
  letter-spacing: 0.18em;
}

#play:hover, #again:hover { filter: brightness(1.08); }

.fine {
  margin-top: 12px;
  font-size: 11px;
  color: var(--muted);
}

@media (max-width: 720px) {
  .card { width: 60px; min-height: 96px; }
  .card .cost { min-width: 22px; height: 22px; font-size: 14px; }
  .splash-card h1 { font-size: 40px; }
  #hint { display: none; }
  #legend { display: none; }
}
