* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif; }
body { background: #0e1116; color: #e6e6e6; }

#app { display: grid; grid-template-columns: 320px 1fr; height: 100vh; }

#sidebar {
  background: #161a22;
  border-right: 1px solid #232938;
  overflow-y: auto;
  padding: 16px;
}
#sidebar h1 { font-size: 20px; margin: 0 0 12px; letter-spacing: 0.5px; }
#sidebar h2 { font-size: 12px; text-transform: uppercase; color: #8a93a6; margin: 0 0 8px; letter-spacing: 0.8px; }
.panel { background: #1c2030; border: 1px solid #232938; border-radius: 10px; padding: 12px; margin-bottom: 12px; }
.row { display: grid; grid-template-columns: 80px 1fr 36px; align-items: center; gap: 8px; margin: 6px 0; font-size: 13px; }
.row .val { text-align: right; color: #c8cfdb; font-variant-numeric: tabular-nums; }
.row input[type=number], .row select { width: 100%; background: #0e1116; color: #e6e6e6; border: 1px solid #2a3044; border-radius: 6px; padding: 4px 6px; }
.row input[type=range] { width: 100%; }

.hint { font-size: 11px; color: #8a93a6; text-align: right; margin-top: 4px; font-variant-numeric: tabular-nums; }

.features { display: flex; flex-direction: column; gap: 6px; }

.hidden { display: none !important; }
.mp-players { margin-top: 6px; display: flex; flex-direction: column; gap: 4px; }
.mp-player {
  display: flex; justify-content: space-between; align-items: center;
  background: #0e1116; border: 1px solid #2a3044; border-radius: 6px;
  padding: 4px 8px; font-size: 12px;
}
.mp-player .you { color: #5b8def; font-weight: 600; }
.mp-player .pending { color: #f5a623; }
.mp-player .done { color: #2ea862; }
.link-btn {
  background: none; border: none; color: #5b8def; cursor: pointer;
  font-size: 11px; padding: 0 4px; text-decoration: underline;
}
.mp-players .host-tag { color: #8a93a6; font-size: 10px; margin-left: 4px; }
#mpRoom button, #mpControls button:not(.primary) {
  background: #2a3044; color: #fff; border: 1px solid #3a4258;
  border-radius: 6px; padding: 6px 10px; cursor: pointer; font-size: 12px;
}
#mpRoom button:hover, #mpControls button:not(.primary):hover { background: #3a4258; }

.region-tools { margin-bottom: 8px; }
.region-tools input {
  width: 100%; background: #0e1116; color: #e6e6e6;
  border: 1px solid #2a3044; border-radius: 6px; padding: 5px 8px;
  font-size: 12px;
}
.region-tree { font-size: 13px; max-height: 360px; overflow-y: auto; padding-right: 4px; }
.region-tree .node { user-select: none; }
.region-tree .node-row {
  display: flex; align-items: center; gap: 4px;
  padding: 2px 4px; border-radius: 4px; cursor: pointer;
}
.region-tree .node-row:hover { background: #232938; }
.region-tree .caret {
  width: 14px; text-align: center; color: #8a93a6; font-size: 10px;
  display: inline-block; transition: transform 0.15s;
}
.region-tree .node.collapsed > .node-row > .caret { transform: rotate(-90deg); }
.region-tree .node.leaf > .node-row > .caret { visibility: hidden; }
.region-tree .label { flex: 1; }
.region-tree .count { color: #6c7689; font-size: 11px; font-variant-numeric: tabular-nums; }
.region-tree .children { padding-left: 16px; border-left: 1px solid #232938; margin-left: 7px; }
.region-tree .node.collapsed > .children { display: none; }
.region-tree input[type=checkbox] { accent-color: #5b8def; cursor: pointer; }
.region-tree .node-row.hidden { display: none; }
.region-tree .node.lvl-0 > .node-row { font-weight: 600; }
.region-tree .node.lvl-1 > .node-row { font-weight: 500; }
.region-tree .node.lvl-3 > .node-row { color: #c8cfdb; }
.toggle { display: flex; align-items: center; justify-content: space-between; font-size: 13px; padding: 4px 6px; border-radius: 6px; cursor: pointer; user-select: none; }
.toggle:hover { background: #232938; }
.toggle input { accent-color: #5b8def; }

button.primary {
  width: 100%;
  background: linear-gradient(180deg, #5b8def, #3a6cd6);
  color: white; border: none; border-radius: 8px; padding: 10px 12px; font-weight: 600; cursor: pointer;
  font-size: 14px;
}
button.primary:hover { filter: brightness(1.08); }
button.primary:disabled { opacity: 0.5; cursor: not-allowed; }

.score { margin-top: 10px; text-align: center; color: #c8cfdb; font-size: 13px; font-variant-numeric: tabular-nums; }

#main { position: relative; display: flex; flex-direction: column; }
#hud {
  position: absolute; top: 12px; left: 12px; right: 12px; z-index: 5;
  display: flex; gap: 12px; align-items: flex-start; flex-wrap: wrap;
  pointer-events: none;
}
#hud > * { pointer-events: auto; }
.timer {
  background: rgba(14, 17, 22, 0.85);
  color: #fff; padding: 8px 12px; border-radius: 8px; font-size: 22px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  border: 1px solid #232938;
  min-width: 64px; text-align: center;
}
.timer.warn { color: #f5a623; }
.timer.crit { color: #ff5252; }
#prompt {
  background: rgba(14, 17, 22, 0.85); padding: 10px 12px; border-radius: 8px; font-size: 13px; max-width: 360px;
  border: 1px solid #232938; color: #c8cfdb;
}
.choices { display: flex; gap: 8px; flex-wrap: wrap; flex: 1; justify-content: flex-end; }
.choices button {
  background: rgba(14, 17, 22, 0.9);
  color: #fff;
  border: 1px solid #2a3044;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
}
.choices button:hover:not(:disabled) { background: #2a3044; border-color: #5b8def; }
.choices button.correct { background: #1f6f43; border-color: #2ea862; }
.choices button.wrong { background: #6f1f1f; border-color: #c44; }
.choices button:disabled { cursor: default; }

#map { flex: 1; }

.overlay {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.5); z-index: 10;
}
.overlay.hidden { display: none; }
.overlay-card {
  background: #161a22; border: 1px solid #232938; border-radius: 12px; padding: 20px 24px;
  min-width: 280px; max-width: 420px; text-align: center;
}
#overlayTitle { font-size: 22px; font-weight: 700; margin-bottom: 8px; }
#overlayBody { color: #c8cfdb; font-size: 14px; margin-bottom: 16px; line-height: 1.5; }
