:root {
  --bg: #0e1420;
  --bg-elevated: #161e2e;
  --text: #eef2f8;
  --text-dim: #8b96a8;
  --accent: #3ea6ff;
  --success: #34c759;
  --danger: #ff453a;
  --warning: #ffb020;
  --border: #263248;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Tahoma, sans-serif;
  overscroll-behavior: none;
  user-select: none;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 16px;
  display: flex;
  flex-direction: column;
}

.screen { display: flex; flex-direction: column; align-items: center; flex: 1; }
.screen.hidden { display: none; }

h1 { font-size: 22px; margin: 8px 0; text-align: center; }
h2 { font-size: 24px; margin: 12px 0; text-align: center; }

.balance { font-size: 16px; color: var(--text-dim); margin: 4px 0 16px; }
.balance span { color: var(--warning); font-weight: 700; }

.hint { font-size: 13px; color: var(--text-dim); text-align: center; margin-bottom: 20px; line-height: 1.7; }

.stake-list { width: 100%; display: flex; flex-direction: column; gap: 10px; }

.stake-btn {
  width: 100%;
  padding: 16px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.stake-btn:active { background: var(--accent); border-color: var(--accent); }
.stake-btn .sub { font-size: 12px; font-weight: 400; color: var(--text-dim); }

.error-text { color: var(--danger); font-size: 14px; margin-top: 16px; text-align: center; min-height: 20px; }

.spinner {
  width: 44px; height: 44px;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
  margin: 60px 0 20px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.btn {
  padding: 12px 28px;
  border-radius: 12px;
  border: none;
  font-size: 15px;
  font-weight: 700;
  margin-top: 16px;
}
.btn-danger { background: var(--danger); color: #fff; }
.btn-primary { background: var(--accent); color: #fff; }

.hud {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.tower-hp { flex: 1; display: flex; align-items: center; gap: 6px; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.dot.mine { background: var(--accent); }
.dot.enemy { background: var(--danger); }

.bar {
  flex: 1;
  height: 10px;
  background: var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.bar-fill { height: 100%; transition: width 0.15s linear; }
.bar-fill.mine { background: var(--accent); }
.bar-fill.enemy { background: var(--danger); }
.bar-fill.energy { background: var(--warning); }

.timer { font-size: 14px; font-weight: 700; color: var(--text-dim); min-width: 42px; text-align: center; }

#battlefield {
  width: 100%;
  max-width: 360px;
  aspect-ratio: 360 / 520;
  border-radius: 14px;
  background: #10321f;
  border: 1px solid var(--border);
}

.energy-row { width: 100%; display: flex; align-items: center; gap: 8px; margin: 10px 0; }
.energy-bar { max-width: 360px; }
#energy-text { font-size: 12px; color: var(--text-dim); min-width: 40px; }

.hand {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.card-btn {
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  padding: 10px 4px;
  text-align: center;
  font-size: 11px;
  line-height: 1.5;
}
.card-btn .icon { font-size: 22px; display: block; }
.card-btn .cost { color: var(--warning); font-weight: 700; }
.card-btn.selected { border-color: var(--accent); background: #12294a; }
.card-btn.disabled { opacity: 0.4; }

#result-title { font-size: 26px; }
#result-title.win { color: var(--success); }
#result-title.lose { color: var(--danger); }
#result-title.draw { color: var(--text-dim); }
#result-detail { color: var(--text-dim); font-size: 15px; }
