:root {
  --bg: #050507;
  --panel-bg: rgba(14, 16, 22, 0.84);
  --panel-border: rgba(255, 255, 255, 0.14);
  --text: #f3f5f8;
  --muted: #9aa3b2;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --chip-bg: rgba(255, 255, 255, 0.08);
  --chip-active: #3b82f6;
}

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

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Helvetica, Arial, sans-serif;
  user-select: none;
  -webkit-font-smoothing: antialiased;
}

#glCanvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
}

/* Central Fixation Target */
.fixation-target {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 5;
}

.fixation-target.red-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #ef4444;
  border: 3px solid #ffffff;
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.75);
}

.fixation-target.green-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #22c55e;
  border: 3px solid #ffffff;
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.75);
}

.fixation-target.crosshair {
  width: 34px;
  height: 34px;
}

.fixation-target.crosshair::before,
.fixation-target.crosshair::after {
  content: "";
  position: absolute;
  background: #ef4444;
  box-shadow: 0 0 0 1.5px #ffffff, 0 0 8px rgba(0, 0, 0, 0.8);
}

.fixation-target.crosshair::before {
  top: 50%;
  left: 0;
  right: 0;
  height: 4px;
  transform: translateY(-50%);
}

.fixation-target.crosshair::after {
  left: 50%;
  top: 0;
  bottom: 0;
  width: 4px;
  transform: translateX(-50%);
}

.fixation-target.off {
  display: none;
}

/* Top-Left Count-Up Stopwatch */
.stopwatch-bar {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px 6px 14px;
  border-radius: 999px;
  background: rgba(10, 12, 18, 0.78);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(10px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.stopwatch-readout {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 14px;
  font-weight: 700;
  color: #f8fafc;
  min-width: 48px;
  text-align: center;
}

.sw-btn {
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.sw-btn:active {
  transform: scale(0.97);
}

.sw-btn-start {
  background: #22c55e;
  color: #052e16;
}

.sw-btn-start:hover,
.sw-btn-start:focus-visible {
  background: #16a34a;
  color: #ffffff;
  outline: 2px solid #86efac;
}

.sw-btn-stop {
  background: #ef4444;
  color: #ffffff;
}

.sw-btn-stop:hover,
.sw-btn-stop:focus-visible {
  background: #dc2626;
  outline: 2px solid #fca5a5;
}

.sw-btn-reset {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--panel-border);
  color: var(--text);
}

.sw-btn-reset:hover,
.sw-btn-reset:focus-visible {
  background: rgba(255, 255, 255, 0.2);
  outline: 2px solid var(--accent);
}

/* Status Badge */
.status-badge {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 15;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(10, 12, 18, 0.72);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(8px);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  font-weight: 600;
  color: #4ade80;
  pointer-events: none;
}

.timer-readout {
  color: #f8fafc;
  padding-left: 10px;
  border-left: 1px solid rgba(255, 255, 255, 0.2);
}

/* Pause Banner */
.pause-banner {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 12;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 18px 30px;
  border-radius: 14px;
  background: rgba(10, 12, 18, 0.86);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(10px);
  pointer-events: none;
}

.pause-banner span {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.14em;
}

.pause-banner small {
  font-size: 13px;
  color: var(--muted);
}

/* Floating Re-open Button */
.show-hud-btn {
  position: fixed;
  bottom: 18px;
  right: 18px;
  z-index: 20;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
  background: rgba(14, 16, 22, 0.75);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  backdrop-filter: blur(8px);
  opacity: 0.55;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.show-hud-btn:hover,
.show-hud-btn:focus-visible {
  opacity: 1;
  transform: translateY(-1px);
  outline: 2px solid var(--accent);
}

/* Main Control Panel */
.control-panel {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  width: min(960px, calc(100vw - 32px));
  z-index: 20;
  padding: 16px 20px 14px;
  border-radius: 16px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(14px);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55);
  transition: opacity 0.28s ease, transform 0.28s ease;
}

.control-panel.hud-hidden {
  opacity: 0;
  transform: translate(-50%, 24px);
  pointer-events: none;
}

.panel-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.brand h1 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand .subtitle {
  font-size: 12px;
  color: var(--muted);
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.btn {
  padding: 8px 14px;
  border-radius: 9px;
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.btn:hover,
.btn:focus-visible {
  background: rgba(255, 255, 255, 0.16);
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.btn-primary {
  background: var(--accent);
  border-color: transparent;
}

.btn-primary:hover,
.btn-primary:focus-visible {
  background: var(--accent-hover);
}

.btn-ghost {
  background: transparent;
}

/* Presets */
.presets-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.chip {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
  background: var(--chip-bg);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.chip:hover,
.chip:focus-visible {
  background: rgba(255, 255, 255, 0.16);
  outline: 2px solid var(--accent);
}

.chip.active {
  background: var(--chip-active);
  border-color: transparent;
}

/* Controls Grid */
.controls-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px 14px;
  margin-bottom: 12px;
}

.control {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.control strong {
  color: var(--text);
  float: right;
  font-weight: 600;
}

.control select {
  width: 100%;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid var(--panel-border);
  background: #141821;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}

.control select:focus-visible,
.control input[type="range"]:focus-visible {
  outline: 2px solid var(--accent);
}

.control input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
  margin-top: 4px;
}

/* Footer */
.panel-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 12px;
  color: var(--muted);
}

.shortcuts {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

kbd {
  display: inline-block;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
}

.toggles {
  display: flex;
  gap: 14px;
}

.inline-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  color: var(--text);
}

.safety-note {
  margin-top: 8px;
  font-size: 11px;
  color: var(--muted);
  opacity: 0.85;
}

.hidden {
  display: none !important;
}

body.cursor-hidden {
  cursor: none;
}

@media (max-width: 780px) {
  .controls-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .shortcuts {
    display: none;
  }
}
