/* ---------- Reset & Base ---------- */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: #0d1117;
  color: #e6edf3;
  font: 16px/1.4 system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial,
        "Apple Color Emoji","Segoe UI Emoji";
}

/* ---------- Utilities ---------- */
.hidden { display: none !important; }
.spacer { flex: 1; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky;
  top: 0; z-index: 5;
  display: flex; align-items: center;
  padding: 12px 16px;
  background: #0b0f14;
  border-bottom: 1px solid #1f2630;
}
.logo { font-size: 20px; letter-spacing: 2px; margin: 0; }
.top-actions { display: flex; gap: 8px; }
.btn { text-decoration: none; }

/* ---------- Buttons ---------- */
.btn {
  appearance: none; border: 1px solid #2b3240; color: #e6edf3;
  background: #151b23; padding: 8px 12px; border-radius: 8px;
  cursor: pointer; transition: transform .05s ease, background .15s ease, border .15s ease;
}
.btn:hover { background: #1a2130; border-color: #374256; }
.btn:active { transform: translateY(1px); }
.btn-ghost { background: transparent; border-color: #2b3240; }
.btn-primary { background: #2d6cdf; border-color: #2d6cdf; color: #fff; }
.btn-primary:hover { background: #2a5fc2; border-color: #2a5fc2; }
.btn.key.capturing { outline: 2px solid #2d6cdf; }

/* ---------- Menu ---------- */
.menu { max-width: 900px; margin: 40px auto 10px; padding: 0 16px; text-align: center; }
.headline { font-size: 28px; margin: 8px 0 16px; opacity: .9; }
.menu-buttons { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* ---------- Game Layout ---------- */
.game {
  max-width: 1200px; margin: 24px auto; padding: 0 16px;
  display: grid; grid-template-columns: 1fr 360px 1fr; gap: 28px;
  align-items: start;
}

/* Players */
.player { display: flex; justify-content: center; }
.playfield {
  background: #000;
  display: block;
  width: 240px; height: 480px; /* match canvas attributes */
  image-rendering: pixelated;
  box-shadow: 0 6px 20px rgba(0,0,0,.4);
}

/* Center UI column */
.center-ui { display: flex; flex-direction: column; align-items: stretch; gap: 16px; }
.top-ui { display: flex; gap: 8px; justify-content: center; }
.player-ui {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
}

/* UI blocks inside the center column */
.ui-block {
  background: #0e141b;
  border: 1px solid #1f2630;
  border-radius: 10px;
  padding: 12px;
  min-height: 160px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.02);
}
.ui-block .pstats { display: grid; gap: 4px; margin-bottom: 12px; }
.ui-block .mini-wrap { display: grid; gap: 6px; margin-bottom: 8px; }
.mini { background:#000; border:1px solid #313a48; width:96px; height:96px; justify-self:center; }

/* ---------- Overlay (Pause / Game Over) ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 10;
  background: rgba(0,0,0,.55);
  display: grid; place-items: center;
}
.overlay-content {
  background: #0e141b; border: 1px solid #2a3342; border-radius: 14px;
  padding: 24px 28px; width: min(92vw, 520px); text-align: center;
  box-shadow: 0 10px 30px rgba(0,0,0,.6);
}
.overlay-title { font-size: 28px; font-weight: 800; margin-bottom: 6px; }
.overlay-sub { opacity: .85; margin-bottom: 14px; }

/* ---------- Options Modal ---------- */
.options {
  position: fixed; inset: 0; z-index: 12; background: rgba(0,0,0,.5);
  display: grid; place-items: center;
}
.options-panel {
  width: min(96vw, 720px);
  background: #0e141b; border: 1px solid #2a3342; border-radius: 14px;
  padding: 18px 18px 20px;
  box-shadow: 0 10px 30px rgba(0,0,0,.6);
}
.options-header {
  display: flex; align-items: center; gap: 8px; margin-bottom: 8px;
}
.options-header h2 { margin: 0; }
.options-header .close { margin-left: auto; }

.opt-section { margin-top: 14px; }
.opt-section h3 { font-size: 16px; opacity: .9; margin: 8px 0; }
.opt-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 6px 0;
}
label { opacity: .9; }

.palette-chips { display: flex; gap: 10px; flex-wrap: wrap; }
.chip {
  width: 28px; height: 28px; border-radius: 6px; cursor: pointer;
  border: 2px solid #2b3240; box-shadow: inset 0 0 0 1px rgba(0,0,0,.25);
}
.chip.active { border-color: #2d6cdf; box-shadow: 0 0 0 2px rgba(45,108,223,.3); }

.controls-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.keys-list {
  background: #0b1016; border: 1px solid #273243; border-radius: 10px;
  padding: 10px; display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center;
}
.keys-list .key { justify-self: end; }

/* Range inputs */
input[type="range"] { width: 240px; }

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
  .game { grid-template-columns: 1fr; }
  .center-ui { order: -1; }
  .player-ui { grid-template-columns: 1fr; }
}
/* XP widget */
#xpWidget {
  display:flex; align-items:center; gap:10px;
  background: rgba(255,255,255,0.06);
  border:1px solid rgba(255,255,255,0.1);
  padding:6px 10px; border-radius:10px; font-size:12px;
}
#xpWidget .lvl { font-weight:700; }
#xpWidget .streak { opacity:.8 }
#xpBar { width:120px; height:6px; background:rgba(255,255,255,0.12); border-radius:999px; overflow:hidden }
#xpBar > div { height:100%; width:0%; background:linear-gradient(90deg,#7dd3fc,#a78bfa,#f472b6); }
.badge-continue {
  position:absolute; top:-8px; right:-8px; background:#22c55e; color:#0b2213;
  padding:3px 8px; font-size:11px; font-weight:700; border-radius:999px; box-shadow:0 2px 10px rgba(0,0,0,.25);
}
