:root {
  --bg: #0a0c12;
  --panel: #141824;
  --border: #2a334a;
  --text: #eef2ff;
  --muted: #8f9bb8;
  --gold: #f5b942;
  --cyan: #58d5ff;
  --red: #f85149;
  --green: #3fb950;
  --purple: #a371f7;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background: radial-gradient(circle at top, #181f33 0%, var(--bg) 72%);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  user-select: none;
}
.shell { width: 100%; max-width: 940px; display: flex; flex-direction: column; gap: 10px; }
.hud {
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 8px 14px;
}
.hud-left, .hud-right { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.brand { font-weight: 900; letter-spacing: 0.16em; color: var(--gold); }
.stat { display: flex; align-items: center; gap: 6px; }
.lbl { font-size: 0.7rem; font-weight: 800; color: var(--muted); }
.val { font-family: ui-monospace, monospace; font-size: 0.96rem; font-weight: 800; }
.gold { color: var(--gold); }
.cyan { color: var(--cyan); }
.green { color: var(--green); }
.icon-btn { background: #1d2436; border: 1px solid var(--border); color: var(--text); border-radius: 6px; width: 34px; height: 30px; cursor: pointer; }

.board-stage {
  position: relative; background: #0c101a; border: 2px solid var(--border); border-radius: 12px;
  padding: 16px; display: grid; grid-template-columns: 380px 1fr; gap: 16px; min-height: 460px;
}
.board-left { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.grid {
  display: grid; grid-template-columns: repeat(5, 68px); grid-template-rows: repeat(5, 68px);
  gap: 6px; padding: 8px; background: #090c14; border: 1px solid var(--border); border-radius: 10px;
}
.tile {
  position: relative;
  background: linear-gradient(145deg, #1d263b 0%, #121826 100%);
  border: 2px solid #2b3856;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), inset 0 -2px 0 rgba(0, 0, 0, 0.45);
  border-radius: 8px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  cursor: pointer; transition: transform 0.08s, border-color 0.12s, background 0.12s;
  font-size: 1.5rem;
  overflow: hidden;
}
.tile-spr {
  width: 54px; height: 54px; object-fit: contain;
  image-rendering: pixelated;
  pointer-events: none;
  filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.7));
}
.tile-spr.pit-spr {
  width: 58px; height: 58px;
  animation: pitSpin 8s linear infinite;
}
@keyframes pitSpin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.tile.pit { background: radial-gradient(circle, #180929 0%, #090311 100%); border-color: #6e40c9; }
.tile.danger { box-shadow: inset 0 0 14px rgba(248, 81, 73, 0.65); border-color: rgba(248, 81, 73, 0.8); }
.tile.valid { border-color: var(--green); background: rgba(63, 185, 80, 0.22); }
.tile.valid:hover { transform: scale(1.05); background: rgba(63, 185, 80, 0.36); }
.tile-hp {
  position: absolute; bottom: 3px; right: 4px; font-size: 0.68rem; font-weight: 900;
  font-family: monospace; background: rgba(0,0,0,0.75); padding: 1px 4px; border-radius: 4px;
}
.tile-intent {
  position: absolute; top: 2px; left: 4px; font-size: 0.64rem; font-weight: 800; color: #ff8c86;
}
.combat-log {
  width: 100%; background: #090c14; border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; font-size: 0.78rem; color: var(--cyan); text-align: center; min-height: 36px;
}

.hand-panel { display: flex; flex-direction: column; gap: 10px; }
.hand-header { display: flex; justify-content: space-between; align-items: center; font-size: 0.78rem; font-weight: 800; color: var(--muted); letter-spacing: 0.08em; }
.end-turn-btn {
  background: var(--gold); color: #0a0c12; border: none; border-radius: 7px;
  padding: 8px 14px; font-weight: 900; font-size: 0.78rem; cursor: pointer;
}
.hand { display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px; flex: 1; align-content: start; }
.tcard {
  background: linear-gradient(180deg, #1b2338 0%, #121726 100%);
  border: 2px solid #303d5c; border-radius: 10px; padding: 11px; color: var(--text);
  text-align: left; cursor: pointer; display: flex; flex-direction: column; gap: 5px;
  transition: transform 0.1s, border-color 0.12s;
}
.tcard:hover:not(:disabled) { transform: translateY(-3px); border-color: var(--cyan); }
.tcard.selected { border-color: var(--green); box-shadow: 0 0 14px rgba(63, 185, 80, 0.35); }
.tcard:disabled { opacity: 0.42; cursor: not-allowed; }
.tcard-top { display: flex; justify-content: space-between; align-items: center; }
.tcard-cost { background: var(--gold); color: #0a0c12; font-weight: 900; font-size: 0.72rem; padding: 2px 7px; border-radius: 999px; }
.tcard-name { font-weight: 800; font-size: 0.88rem; }
.tcard-desc { font-size: 0.75rem; color: var(--muted); line-height: 1.35; }

.overlay {
  position: absolute; inset: 0; background: rgba(10, 12, 18, 0.88); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; padding: 14px; z-index: 10; border-radius: 10px;
}
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  padding: 20px 24px; max-width: 470px; width: 100%; max-height: 100%; overflow-y: auto;
  text-align: center; display: flex; flex-direction: column; gap: 10px;
}
.card h1 { color: var(--gold); letter-spacing: 0.12em; }
.card p { font-size: 0.84rem; color: var(--muted); line-height: 1.4; }
.stats-box { background: #090c14; border: 1px solid var(--border); border-radius: 8px; padding: 8px; font-family: monospace; font-size: 0.84rem; }
.lb-panel { background: #090c14; border: 1px solid var(--border); border-radius: 8px; padding: 9px 11px; text-align: left; }
.lb-head { display: flex; justify-content: space-between; font-size: 0.72rem; font-weight: 800; color: var(--gold); margin-bottom: 5px; }
.lb-list { display: flex; flex-direction: column; gap: 3px; font-family: monospace; font-size: 0.77rem; color: var(--muted); }
.lb-row { display: flex; justify-content: space-between; }
.lb-submit { display: flex; gap: 6px; margin-top: 7px; }
.lb-submit input { flex: 1; background: #141824; color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; font-size: 0.8rem; }
.ok-btn { background: var(--green); color: #05160a; border: none; border-radius: 6px; padding: 6px 12px; font-weight: 800; cursor: pointer; font-size: 0.75rem; }
.actions { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.primary-btn, .sec-btn { width: 100%; max-width: 260px; border-radius: 8px; padding: 10px 18px; font-weight: 800; cursor: pointer; }
.primary-btn { background: var(--gold); color: #0a0c12; border: none; letter-spacing: 0.08em; }
.sec-btn { background: rgba(88, 213, 255, 0.14); color: var(--cyan); border: 1px solid rgba(88, 213, 255, 0.45); }
.share-out { background: #090c14; color: var(--cyan); border: 1px solid var(--border); border-radius: 6px; padding: 6px; font-size: 0.72rem; font-family: monospace; text-align: center; }
.challenge-box { background: rgba(88, 213, 255, 0.12); border: 1px solid rgba(88, 213, 255, 0.45); color: var(--cyan); padding: 7px; border-radius: 8px; font-size: 0.82rem; font-weight: 700; }

.draft-box { width: 100%; max-width: 640px; text-align: center; }
.draft-title { font-size: 1.2rem; font-weight: 900; color: var(--green); margin-bottom: 14px; letter-spacing: 0.08em; }
.draft-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(175px, 1fr)); gap: 12px; }
.footer { display: flex; justify-content: space-between; font-size: 0.75rem; color: var(--muted); padding: 0 4px; }
.footer a { color: var(--gold); text-decoration: none; font-weight: 700; }
.hidden { display: none !important; }
@media (max-width: 780px) {
  .board-stage { grid-template-columns: 1fr; }
  .grid { grid-template-columns: repeat(5, 56px); grid-template-rows: repeat(5, 56px); }
}
