:root {
  --bg: #0f1115;
  --panel: #1b1e26;
  --panel2: #262a35;
  --border: #3a3f4d;
  --accent: #f5b53f;
  --text: #e8e8ea;
  --muted: #9aa0ad;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  touch-action: none;            /* phones: no pinch zoom or scroll; the game pans itself (see touch.js) */
  overscroll-behavior: none;
  background: radial-gradient(circle at 50% 30%, #1d2230, var(--bg) 70%);
  font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
}

/* The board is designed at 960px wide and scaled to fill the window (see ui.js). */
#wrap {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 960px;
  transform-origin: center center;
  transform: translate(-50%, -50%) scale(1);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
}

/* ---------- HUD ---------- */
#hud {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 56px;
  padding: 0 16px;
  background: linear-gradient(var(--panel2), var(--panel));
  border-bottom: 2px solid var(--accent);
  font-size: 18px;
}
.stat {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 6px;
  font-weight: 600;
}
.stat .icon { font-size: 16px; }
.stat .label { font-size: 11px; color: var(--muted); letter-spacing: 1.5px; }
.stat .dim { color: var(--muted); font-weight: 400; }
.spacer { flex: 1; }

button {
  font: inherit;
  font-weight: 700;
  font-size: 15px;
  padding: 9px 18px;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: #1b1400;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  transition: filter 0.15s, transform 0.1s;
}
button:hover { filter: brightness(1.1); }
button:active { transform: translateY(1px); }
button:disabled { background: #3a3f4d; color: #8a8f9c; cursor: default; filter: none; transform: none; }

#hud .icon-btn {
  padding: 6px 10px;
  font-size: 18px;
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
}
#hud .icon-btn:hover { background: rgba(255, 255, 255, 0.1); filter: none; }

canvas { display: block; }

/* ---------- Build / upgrade menu ---------- */
#menu {
  position: absolute;
  display: none;
  width: 236px;
  padding: 10px 10px 8px;
  background: rgba(22, 25, 33, 0.82);
  backdrop-filter: blur(10px) saturate(1.3);
  -webkit-backdrop-filter: blur(10px) saturate(1.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  font-size: 13px;
  z-index: 2;
}
#menu .head { display: flex; align-items: center; justify-content: space-between; padding: 0 22px 6px 2px; }
#menu .title { font-weight: 700; font-size: 14px; }
#menu .lv { color: var(--accent); font-size: 12px; font-weight: 600; }
#menu .stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 0 0 8px; }
#menu .stat { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 4px 0; background: rgba(255, 255, 255, 0.05); border-radius: 8px; }
#menu .stat small { color: var(--muted); font-size: 10px; letter-spacing: 0.4px; text-transform: uppercase; }
#menu .stat b { font-size: 13px; font-variant-numeric: tabular-nums; }
#menu .x {
  position: absolute; top: 6px; right: 6px;
  width: 22px; height: 22px; padding: 0;
  border-radius: 50%; background: rgba(255, 255, 255, 0.08); color: var(--muted);
  font-size: 11px; text-transform: none; letter-spacing: 0;
}
#menu .x:hover { background: rgba(255, 255, 255, 0.16); color: var(--text); filter: none; }

#menu .grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
#menu .grid.two { grid-template-columns: repeat(2, 1fr); margin-bottom: 6px; }
#menu .grid.two .tile .nm { font-size: 11px; }
#menu .tile {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 7px 4px 6px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  color: var(--text);
  text-transform: none; letter-spacing: 0; font-weight: 600; font-size: 11px;
  transition: background 0.12s, transform 0.1s, border-color 0.12s;
}
#menu .tile:hover { background: rgba(255, 255, 255, 0.12); border-color: var(--accent); transform: translateY(-1px); filter: none; }
#menu .tile:disabled { opacity: 0.35; transform: none; }
#menu .tile .ico { font-size: 20px; line-height: 1; }
#menu .tile .cost { color: var(--accent); font-size: 11px; font-weight: 700; }
#menu .tile .cost::before { content: "◆ "; font-size: 8px; vertical-align: 1px; }
#menu .hint { min-height: 15px; margin-top: 7px; padding: 0 2px; color: var(--muted); font-size: 11px; text-align: center; }

#menu .row { display: flex; gap: 6px; }
#menu .pill {
  flex: 1; padding: 7px 8px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px; color: var(--text);
  text-transform: none; letter-spacing: 0; font-weight: 600; font-size: 12px; white-space: nowrap;
}
#menu .pill b { color: var(--accent); font-weight: 700; }
#menu .pill:hover { background: rgba(255, 255, 255, 0.16); filter: none; }
#menu .pill.primary { background: var(--accent); color: #1b1400; border-color: transparent; }
#menu .pill.primary b { color: #1b1400; }
#menu .pill.primary:hover { filter: brightness(1.1); }
#menu .pill.sell { flex: 0 0 auto; }
#menu .pill:disabled { opacity: 0.4; }

/* ---------- Hero pick (start of each round) ---------- */
#heroPick {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(10, 12, 18, 0.72);
  text-align: center;
  z-index: 3;
}
#heroPick h1 { font-size: 40px; margin: 0 0 6px; letter-spacing: 2px; }
#heroPick p { color: var(--muted); margin: 0 0 22px; font-size: 16px; }
#heroPick .cards { display: flex; gap: 12px; }
#heroPick .card {
  width: 172px;
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-transform: none;
  letter-spacing: 0;
  background: var(--panel);
  color: var(--text);
  border: 2px solid var(--border);
  border-top: 4px solid var(--accent);
  border-radius: 10px;
  transition: transform 0.12s, border-color 0.12s;
}
#heroPick .card:hover { transform: translateY(-4px); border-color: var(--accent); filter: none; }
#heroPick .card .portrait { font-size: 44px; }
#heroPick .card strong { font-size: 18px; }
#heroPick .card small { color: var(--muted); font-size: 12px; font-weight: 400; line-height: 1.4; }
#heroPick .card[data-hero="avril"] { border-top-color: #f06292; }
#heroPick .card[data-hero="ember"] { border-top-color: #ff7043; }
#heroPick .card[data-hero="willow"] { border-top-color: #8bc34a; }
#heroPick .card[data-hero="meilin"] { border-top-color: #80deea; }

/* ---------- Game over / victory ---------- */
#overlay {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(10, 12, 18, 0.82);
  text-align: center;
  z-index: 3;
}
#overlay h1 { font-size: 56px; margin: 0 0 8px; letter-spacing: 2px; }
#overlay p { color: var(--muted); margin: 0 0 22px; font-size: 18px; }
#overlay button { font-size: 20px; padding: 12px 28px; }
