* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #080b10;
  --panel: #111722;
  --border: #233044;
  --text: #e2e8f0;
  --muted: #8b9bb4;
  --accent: #f59e0b;
  --accent-hover: #fbbf24;
  --ok: #22c55e;
  --ok-hover: #4ade80;
  --err: #ef4444;
  --mono: "JetBrains Mono", "Cascadia Code", Consolas, monospace;
}
html, body { height: 100%; background: var(--bg); color: var(--text); font-family: "Segoe UI", system-ui, sans-serif; overflow: hidden; }
.app-shell { display: flex; flex-direction: column; height: 100vh; width: 100vw; }
.stage-column { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.stage-wrap {
  position: relative; flex: 1; min-height: 0;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at center, #111827 0%, #05070b 100%);
  padding: 8px;
}
#game-canvas {
  width: 100%; height: 100%; object-fit: contain;
  image-rendering: pixelated; image-rendering: crisp-edges;
  background: #000; border: 1px solid #1e293b; border-radius: 6px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.7);
}

/* Two-Column Boot Launcher Overlay */
.boot-overlay {
  position: absolute; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  background: rgba(5, 8, 13, 0.95); padding: 16px;
}
.boot-overlay.hidden { display: none; }
.launcher-grid {
  width: min(1080px, 98%);
  height: min(630px, 88vh);
  display: grid; grid-template-columns: 1.35fr 1fr; gap: 14px;
  align-items: stretch;
}
@media (max-width: 820px) {
  .launcher-grid { grid-template-columns: 1fr; height: auto; max-height: 92vh; overflow-y: auto; }
}

.terminal-window, .mods-window {
  display: flex; flex-direction: column; min-height: 0; height: 100%; max-height: 100%;
  background: #0b1018; border: 1px solid #263549; border-radius: 10px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.85); overflow: hidden;
}
.mods-window.dragover { border-color: #4ade80; box-shadow: 0 0 0 2px rgba(74, 222, 128, 0.35); }

.terminal-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; background: #121a26; border-bottom: 1px solid #233044; flex-shrink: 0;
}
.term-dots { display: flex; gap: 6px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot.red { background: #ef4444; }
.dot.yellow { background: #f59e0b; }
.dot.green { background: #22c55e; }
.term-title { font-family: var(--mono); font-size: 11.5px; color: #94a3b8; letter-spacing: 0.04em; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.term-badge {
  font-family: var(--mono); font-size: 11px; font-weight: 700;
  padding: 2px 8px; border-radius: 4px; background: rgba(245, 158, 11, 0.16); color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.4); flex-shrink: 0;
}
.term-badge.ok { background: rgba(34, 197, 94, 0.16); color: #4ade80; border-color: rgba(34, 197, 94, 0.4); }
.term-badge.fail { background: rgba(239, 68, 68, 0.18); color: #f87171; border-color: rgba(239, 68, 68, 0.45); }

.terminal-log {
  font-family: var(--mono); font-size: 12px; line-height: 1.5;
  padding: 12px 14px; flex: 1 1 0; min-height: 120px; overflow-y: auto;
  background: #070b11; color: #cbd5e1;
}
.t-line { display: flex; gap: 8px; white-space: pre-wrap; word-break: break-word; }
.t-tag { font-weight: 700; flex-shrink: 0; }
.t-ok { color: #4ade80; }
.t-fail { color: #f87171; }
.t-warn { color: #fbbf24; }
.t-info { color: #38bdf8; }
.t-dim { color: #64748b; }

.jar-gate { padding: 12px 14px 14px; border-top: 1px solid #1e293b; background: #0d1420; flex-shrink: 0; }
.drop-zone {
  border: 2px dashed rgba(245, 158, 11, 0.5); border-radius: 8px;
  padding: 12px 14px; text-align: center; transition: border-color .15s, background .15s;
}
.drop-zone.dragover { border-color: #4ade80; background: rgba(34, 197, 94, 0.08); }
.drop-zone.key-ready { border-style: solid; border-color: rgba(34, 197, 94, 0.55); background: rgba(34, 197, 94, 0.06); }
.gate-head { font-weight: 700; font-size: 13.5px; color: #fbbf24; margin-bottom: 6px; letter-spacing: 0.02em; }
.drop-zone.key-ready .gate-head { color: #4ade80; }
.gate-desc { font-size: 12.5px; color: #94a3b8; line-height: 1.45; margin-bottom: 10px; }
.gate-desc code { font-family: var(--mono); color: #cbd5e1; background: #172132; padding: 1px 4px; border-radius: 4px; }
.picker-row { display: flex; align-items: center; justify-content: center; gap: 8px; margin-bottom: 8px; }
.remember-row { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: #94a3b8; cursor: pointer; }
.error-box {
  margin-top: 10px; padding: 8px 10px; border-radius: 6px;
  background: rgba(239, 68, 68, 0.14); border: 1px solid rgba(239, 68, 68, 0.45);
  color: #fca5a5; font-family: var(--mono); font-size: 11.5px; text-align: left;
}

/* Play Button */
.play-row { margin-top: 12px; }
.play-btn {
  width: 100%; padding: 12px 16px; font-size: 15px; font-weight: 800; letter-spacing: 0.05em;
  border-radius: 8px; border: 1px solid #334155; background: #182234; color: #64748b;
  cursor: not-allowed; transition: all 0.18s ease;
}
.play-btn:not(:disabled) {
  background: linear-gradient(135deg, #16a34a 0%, #22c55e 100%);
  border-color: #4ade80; color: #052e16; cursor: pointer;
  box-shadow: 0 0 22px rgba(34, 197, 94, 0.35);
}
.play-btn:not(:disabled):hover {
  background: linear-gradient(135deg, #22c55e 0%, #4ade80 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 26px rgba(34, 197, 94, 0.5);
}

/* Mods Panel */
.mods-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 12px; background: #0e1522; border-bottom: 1px solid #1e293b; flex-shrink: 0;
}
.mods-hint { font-size: 11.5px; color: #7c8ea8; }
.mods-actions { display: flex; gap: 6px; }
.mods-list {
  flex: 1 1 0; min-height: 0; overflow-y: auto; padding: 10px 12px;
  display: flex; flex-direction: column; gap: 8px; background: #080c13;
}
.mods-empty { font-size: 12.5px; color: #64748b; text-align: center; padding: 28px 10px; }
.mod-card {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 9px 10px; border-radius: 7px;
  background: #101724; border: 1px solid #223044; transition: border-color 0.15s, background 0.15s;
}
.mod-card.enabled { border-color: rgba(34, 197, 94, 0.5); background: rgba(34, 197, 94, 0.06); }
.mod-check { margin-top: 3px; width: 15px; height: 15px; accent-color: #22c55e; cursor: pointer; flex-shrink: 0; }
.mod-info { flex: 1; min-width: 0; }
.mod-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 3px; }
.mod-name { font-size: 13px; font-weight: 700; color: #f1f5f9; }
.mod-ver { font-family: var(--mono); font-size: 10.5px; color: #94a3b8; }
.mod-tag {
  font-family: var(--mono); font-size: 10px; font-weight: 700;
  padding: 1px 5px; border-radius: 3px; background: #1a273b; color: #7dd3fc; border: 1px solid #2c4161;
}
.mod-desc { font-size: 11.5px; color: #94a3b8; line-height: 1.4; }
.mod-meta { font-family: var(--mono); font-size: 10.5px; color: #64748b; margin-top: 4px; }
.mod-order { display: flex; flex-direction: column; gap: 3px; flex-shrink: 0; }
.mod-order button {
  width: 22px; height: 20px; border-radius: 4px; border: 1px solid #2c3d55;
  background: #162030; color: #cbd5e1; font-size: 10px; cursor: pointer;
}
.mod-order button:hover { background: #23334b; color: #fff; }
.mods-footer {
  padding: 8px 12px; font-size: 11.5px; color: #7c8ea8;
  background: #0d1420; border-top: 1px solid #1e293b; flex-shrink: 0;
}
.mods-footer code { font-family: var(--mono); color: #cbd5e1; background: #172132; padding: 1px 4px; border-radius: 3px; }

/* Status Bar */
.status-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 6px 12px; background: #0e141f; border-top: 1px solid var(--border); font-size: 12.5px;
}
.status-text { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.badge-key, .badge-res {
  font-family: var(--mono); font-size: 11.5px; padding: 3px 8px; border-radius: 5px;
  background: #161f2e; border: 1px solid #263549; color: #94a3b8;
}
.badge-key { color: #86efac; border-color: rgba(34, 197, 94, 0.35); background: rgba(34, 197, 94, 0.08); }
.bottom-controls { display: flex; gap: 6px; }
.bar-btn {
  background: #182234; color: var(--text); border: 1px solid #2c3d55;
  border-radius: 5px; padding: 4px 10px; font-size: 12px; cursor: pointer;
}
.bar-btn:hover { background: #223047; }
.bar-btn.accent { background: rgba(245, 158, 11, 0.16); border-color: rgba(245, 158, 11, 0.5); color: #fcd34d; }

/* Buttons & Drawer */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: 6px; border: 1px solid #334155;
  background: #1e293b; color: var(--text); font-size: 13px; font-weight: 600; cursor: pointer;
}
.btn:hover { background: #283548; }
.btn.primary { background: var(--accent); color: #0b0f17; border-color: var(--accent); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.small { padding: 6px 10px; font-size: 12px; }
.btn.tiny { padding: 3px 8px; font-size: 11px; }
.btn.danger { background: rgba(239, 68, 68, 0.16); border-color: rgba(239, 68, 68, 0.45); color: #fca5a5; }
.btn.secondary { background: #182234; }

.drawer-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.55); z-index: 30; }
.sidebar {
  position: fixed; top: 0; right: 0; bottom: 0; width: 320px; max-width: 92vw;
  background: var(--panel); border-left: 1px solid var(--border);
  z-index: 40; display: flex; flex-direction: column; gap: 10px; padding: 12px;
  overflow-y: auto; transition: transform 0.2s ease;
}
.sidebar.drawer-closed { transform: translateX(100%); }
.drawer-header { display: flex; justify-content: space-between; align-items: center; font-weight: 700; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.panel { background: #0c121c; border: 1px solid #1e2a3b; border-radius: 8px; padding: 10px; }
.panel-title { font-size: 12px; font-weight: 700; color: #fbbf24; text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 8px; }
.row-between { display: flex; justify-content: space-between; align-items: center; }
.control-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.control-row:last-child { margin-bottom: 0; }
.field-label { display: flex; flex-direction: column; gap: 4px; font-size: 11.5px; color: var(--muted); flex: 1; }
select, input[type="range"] { background: #151f2e; color: var(--text); border: 1px solid #2b3b52; border-radius: 5px; padding: 4px 6px; font-size: 12px; }
.keys-list { list-style: none; display: flex; flex-direction: column; gap: 5px; font-size: 12px; }
.keys-list li { display: flex; justify-content: space-between; gap: 8px; border-bottom: 1px dashed #1e293b; padding-bottom: 4px; }
.keys-list span { font-family: var(--mono); color: #fcd34d; }
.keys-list b { font-weight: 500; color: #cbd5e1; text-align: right; }
.telemetry-box { font-family: var(--mono); font-size: 11.5px; color: #94a3b8; background: #080c13; padding: 6px 8px; border-radius: 5px; margin-bottom: 8px; }
.actions-panel { display: flex; flex-direction: column; gap: 6px; }
.keypad-wrap { display: flex; flex-direction: column; gap: 6px; }
.keypad-wrap.collapsed { display: none; }
.soft-row, .dpad, .numpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.kbtn { padding: 8px 4px; background: #192334; color: var(--text); border: 1px solid #2d3e57; border-radius: 5px; cursor: pointer; font-weight: 600; font-size: 12px; }
.kbtn.active, .kbtn:active { background: var(--accent); color: #000; }
.kbtn.fire { background: rgba(245, 158, 11, 0.2); border-color: rgba(245, 158, 11, 0.5); }
/* Custom Sleek Terminal & Launcher Scrollbars */
.terminal-log,
.mods-list,
.sidebar,
.launcher-grid {
  scrollbar-width: thin;
  scrollbar-color: #334a66 #080d14;
}

.terminal-log::-webkit-scrollbar,
.mods-list::-webkit-scrollbar,
.sidebar::-webkit-scrollbar,
.launcher-grid::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}

.terminal-log::-webkit-scrollbar-track,
.mods-list::-webkit-scrollbar-track,
.sidebar::-webkit-scrollbar-track,
.launcher-grid::-webkit-scrollbar-track {
  background: #060a10;
  border-left: 1px solid #162131;
  border-radius: 6px;
}

.terminal-log::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(56, 189, 248, 0.55) 0%, rgba(34, 197, 94, 0.55) 100%);
  border: 2px solid #060a10;
  border-radius: 999px;
  box-shadow: inset 0 0 6px rgba(56, 189, 248, 0.35);
}

.terminal-log::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, rgba(56, 189, 248, 0.9) 0%, rgba(74, 222, 128, 0.9) 100%);
}

.mods-list::-webkit-scrollbar-thumb,
.sidebar::-webkit-scrollbar-thumb,
.launcher-grid::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(245, 158, 11, 0.45) 0%, rgba(59, 130, 246, 0.45) 100%);
  border: 2px solid #060a10;
  border-radius: 999px;
}

.mods-list::-webkit-scrollbar-thumb:hover,
.sidebar::-webkit-scrollbar-thumb:hover,
.launcher-grid::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, rgba(251, 191, 36, 0.85) 0%, rgba(96, 165, 250, 0.85) 100%);
}

.terminal-log::-webkit-scrollbar-corner,
.mods-list::-webkit-scrollbar-corner,
.sidebar::-webkit-scrollbar-corner {
  background: #060a10;
}
/* FPS Selector Row & Live Badge */
.fps-launch-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  margin-top: 10px; padding: 7px 10px; border-radius: 7px;
  background: #0a101a; border: 1px solid #1e2d42;
}
.fps-inline-label {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 600; color: #cbd5e1;
}
.badge-fps {
  font-family: var(--mono); font-size: 11.5px; font-weight: 700; padding: 3px 8px; border-radius: 5px;
  color: #38bdf8; border: 1px solid rgba(56, 189, 248, 0.4); background: rgba(56, 189, 248, 0.1);
}
.fps-launch-row.fps-locked {
  border-color: #1e293b;
  opacity: 0.85;
}
.fps-launch-row select:disabled,
.sidebar select:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.fps-lock-note {
  font-family: var(--mono);
  font-size: 10.5px;
  color: #f59e0b;
}
.stage-fps-pill {
  position: absolute;
  top: 14px;
  right: 16px;
  z-index: 15;
  pointer-events: none;
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: 6px;
  color: #4ade80;
  background: rgba(6, 10, 16, 0.82);
  border: 1px solid rgba(56, 189, 248, 0.45);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.55);
}
.bar-btn.debug-btn {
  background: rgba(56, 189, 248, 0.14);
  border-color: rgba(56, 189, 248, 0.45);
  color: #7dd3fc;
}
.bar-btn.debug-btn:hover {
  background: rgba(56, 189, 248, 0.25);
}
.bar-btn.debug-btn.has-warn {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.6);
  color: #fca5a5;
}
/* Clean Fullscreen / In-Game Mode (hide bottom bar & borders; F2 still opens drawer) */
.app-shell.in-game .status-bar {
  display: none;
}
.app-shell.in-game .stage-wrap {
  padding: 0;
  background: #000;
}
.app-shell.in-game #game-canvas {
  border: none;
  border-radius: 0;
  box-shadow: none;
}

/* F11 Fullscreen Hint above Play button */
.fullscreen-hint {
  margin-top: 8px;
  padding: 6px 10px;
  border-radius: 6px;
  text-align: center;
  font-size: 11.5px;
  font-weight: 600;
  color: #7dd3fc;
  background: rgba(56, 189, 248, 0.08);
  border: 1px solid rgba(56, 189, 248, 0.28);
}
.fullscreen-hint kbd {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  background: #172336;
  border: 1px solid #334e6f;
  color: #f8fafc;
}
