:root {
  --bg: #0f1b2d;
  --panel: #1d3557;
  --accent: #f4c430;
  --accent-2: #e63946;
  --green: #52b788;
  --cream: #fdf6e3;
  --muted: #b7c3d0;
  --btn: #2a4a7f;
  --btn-hover: #3b66a8;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
}

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

html, body { width: 100%; height: 100%; overflow: hidden; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--cream);
  -webkit-tap-highlight-color: transparent;
}

#app { width: 100%; height: 100%; display: flex; flex-direction: column; }

/* ---------- Top bar ---------- */
#topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  background: linear-gradient(180deg, #1d3557, #162a47);
  box-shadow: var(--shadow);
  position: relative;
  z-index: 2;
  flex-wrap: wrap;
}
.brand { display: flex; flex-direction: column; line-height: 1.1; min-width: 120px; }
.brand__title { font-size: 18px; font-weight: 800; color: var(--accent); }
.brand__sub { font-size: 11px; color: var(--muted); letter-spacing: 1px; text-transform: uppercase; }

.stat { display: flex; align-items: center; gap: 8px; background: rgba(0,0,0,0.25); padding: 6px 12px; border-radius: 10px; border: 2px solid rgba(255,255,255,0.08); }
.stat__label { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.stat__val { font-weight: 800; color: var(--cream); }
.vault-bar { width: 90px; height: 12px; background: rgba(0,0,0,0.4); border-radius: 8px; overflow: hidden; border: 2px solid #000; }
.vault-bar__fill { height: 100%; background: linear-gradient(90deg, #e63946, #f4c430); width: 100%; transition: width 0.2s; }

.controls { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.howto-bar { padding: 4px 12px; background: rgba(0,0,0,0.3); border-bottom: 1px solid rgba(255,255,255,0.08); display: flex; justify-content: center; }
.howto { font-size: 12px; color: var(--cream); background: rgba(0,0,0,0.3); border: 2px solid rgba(255,255,255,0.12); border-radius: 8px; padding: 6px 10px; max-width: 360px; line-height: 1.3; }
button { cursor: pointer; border: none; background: var(--btn); color: var(--cream); padding: 8px 12px; border-radius: 10px; font-weight: 700; border: 2px solid rgba(0,0,0,0.3); transition: background 0.15s, transform 0.1s; }
button:hover { background: var(--btn-hover); }
button:active { transform: translateY(1px); }
button.cta { width: 100%; background: linear-gradient(180deg, #f4c430, #e0a800); color: #1d2330; padding: 12px; border: 2px solid #000; }
button.cta:hover { background: linear-gradient(180deg, #ffd84d, #f4c430); }

/* ---------- Main ---------- */
#main { flex: 1; display: flex; overflow: hidden; min-height: 0; }
#canvasWrap { flex: 1; position: relative; background: #0a1423; display: flex; align-items: center; justify-content: center; padding: 8px; }
#canvasWrap canvas { max-width: 100%; max-height: 100%; box-shadow: var(--shadow); border-radius: 6px; }

#sidebar { width: 300px; background: linear-gradient(180deg, #162a47, #0f1b2d); padding: 14px; display: flex; flex-direction: column; gap: 12px; box-shadow: -4px 0 0 #0002; overflow-y: auto; }
.sidebar__head h2 { font-size: 16px; color: var(--accent); margin-bottom: 4px; }
.hint { font-size: 12px; color: var(--muted); line-height: 1.4; }
.tower-list { display: flex; flex-direction: column; gap: 8px; }
.tower-card {
  display: flex; align-items: center; gap: 10px;
  background: rgba(0,0,0,0.35); border: 3px solid rgba(255,255,255,0.08);
  border-radius: 12px; padding: 8px 10px; cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}
.tower-card:hover { border-color: var(--accent); }
.tower-card.active { border-color: var(--accent); background: rgba(244,196,48,0.12); transform: scale(1.02); }
.tower-card .t-icon { width: 44px; height: 44px; flex-shrink: 0; }
.tower-card .t-info { flex: 1; }
.tower-card .t-name { font-weight: 800; font-size: 13px; color: var(--cream); }
.tower-card .t-desc { font-size: 11px; color: var(--muted); line-height: 1.3; }
.tower-card .t-cost { font-weight: 800; color: var(--accent); font-size: 14px; }
.sidebar__foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.status { font-size: 13px; color: var(--muted); text-align: center; line-height: 1.4; }

/* ---------- Overlay ---------- */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.65); display: flex; align-items: center; justify-content: center; z-index: 10; }
.overlay.hidden { display: none; }
.card { background: var(--panel); border: 4px solid #000; border-radius: 16px; padding: 28px 32px; text-align: center; box-shadow: var(--shadow); max-width: 90vw; }
.card h1 { color: var(--accent); margin-bottom: 8px; font-size: 28px; }
.card p { color: var(--cream); margin-bottom: 16px; }

@media (max-width: 760px) {
  #main { flex-direction: column; }
  #sidebar { width: 100%; max-height: 260px; }
  #topbar { gap: 8px; }
  .brand { min-width: auto; }
}
