:root {
  --bg: #071018;
  --ink: #e8f6ff;
  --muted: #7ea3b8;
  --accent: #3ee0c5;
  --hot: #ff5d6c;
  --gold: #ffd166;
  --card: rgba(6, 18, 28, 0.86);
}

* { 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: pointer;
}

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

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

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

#you-tag {
  margin-top: 6px;
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

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

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

#keeps { margin-top: 8px; width: 320px; max-width: 46vw; }

.keep-row {
  display: grid;
  grid-template-columns: 64px 1fr 40px;
  gap: 8px;
  align-items: center;
  font-size: 11px;
  letter-spacing: 0.08em;
  font-weight: 700;
}

.keep-row.them { margin-top: 4px; color: var(--hot); }
.keep-row span:first-child { text-align: right; overflow: hidden; text-overflow: ellipsis; }

.hp-track {
  height: 8px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

#you-hp {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #1d8f78, var(--accent));
}

#them-hp {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #9b2434, var(--hot));
}

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

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

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

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

#pulse-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

#pulse-pips {
  display: flex;
  gap: 4px;
}

#pulse-pips i {
  width: 14px;
  height: 18px;
  border: 1px solid rgba(62, 224, 197, 0.35);
  background: rgba(62, 224, 197, 0.08);
  transform: skewX(-12deg);
}

#pulse-pips i.on {
  background: linear-gradient(180deg, #9ff7e6, var(--accent));
  box-shadow: 0 0 10px rgba(62, 224, 197, 0.55);
}

#pulse-pips i.half {
  background: linear-gradient(180deg, rgba(159, 247, 230, 0.35), rgba(62, 224, 197, 0.25));
}

#pulse-n {
  font-weight: 800;
  font-size: 20px;
  min-width: 28px;
  color: var(--accent);
  text-shadow: 0 0 12px rgba(62, 224, 197, 0.5);
}

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

.card {
  width: 92px;
  padding: 8px 6px 7px;
  background: var(--card);
  border: 1px solid rgba(62, 224, 197, 0.22);
  color: var(--ink);
  cursor: pointer;
  position: relative;
  text-align: center;
}

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

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

.card.poor { opacity: 0.42; }

.glyph {
  width: 28px;
  height: 28px;
  margin: 4px auto 6px;
}

.glyph.spark {
  background: #ffd166;
  clip-path: polygon(50% 0, 100% 70%, 70% 70%, 70% 100%, 30% 100%, 30% 70%, 0 70%);
}

.glyph.quill {
  width: 8px;
  height: 28px;
  background: linear-gradient(#c9f0ff, #3ea8e0);
  border-radius: 4px;
  box-shadow: 8px 6px 0 -2px #7ad0ff;
}

.glyph.bulwark {
  background: #8aa4b8;
  border-radius: 4px 4px 10px 10px;
  box-shadow: inset 0 -8px 0 #5c7386;
}

.card-name { font-size: 11px; font-weight: 800; letter-spacing: 0.14em; }
.card-meta { font-size: 10px; color: var(--muted); margin-top: 2px; }

#hint {
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--muted);
  text-shadow: 0 2px 8px #000;
}

#splash, #over {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  background: radial-gradient(ellipse at 50% 30%, rgba(62, 224, 197, 0.12), transparent 55%),
              rgba(5, 10, 16, 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(62, 224, 197, 0.28);
  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: #061018;
  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: #042018;
  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: 76px; }
  #keeps { width: 240px; }
  .splash-card h1 { font-size: 40px; }
}
