:root {
  --bg-dark: #0f172a;
  --panel-bg: rgba(15, 23, 42, 0.85);
  --panel-border: rgba(148, 163, 184, 0.24);
  --accent-blue: #38bdf8;
  --accent-green: #22c55e;
  --accent-amber: #f59e0b;
  --accent-red: #ef4444;
  --accent-purple: #a855f7;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
}

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

body, html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-dark);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  color: var(--text-main);
}

#canvas-container {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1;
}

.hidden {
  display: none !important;
}

#danger-vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  box-shadow: inset 0 0 110px rgba(239, 68, 68, 0.78);
  animation: pulseDanger 0.65s infinite alternate;
}

@keyframes pulseDanger {
  from { opacity: 0.45; }
  to { opacity: 1; }
}

/* Top HUD Bar */
#hud-top {
  position: fixed;
  top: 14px;
  left: 16px;
  right: 16px;
  z-index: 10;
  display: flex;
  align-items: stretch;
  gap: 12px;
  pointer-events: none;
}

.hud-card {
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 10px 15px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.35);
  pointer-events: auto;
}

.timer-card {
  min-width: 170px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.score-card {
  flex: 1;
  max-width: 390px;
}

.suspicion-card {
  flex: 1;
  max-width: 360px;
}

.hud-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.trend-badge {
  font-size: 10px;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 999px;
}

.trend-badge.gaining {
  background: rgba(34, 197, 94, 0.2);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.4);
}

.trend-badge.draining {
  background: rgba(239, 68, 68, 0.22);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.45);
}

.hud-value {
  font-size: 25px;
  font-weight: 800;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.hud-sub {
  font-size: 11px;
  color: #cbd5e1;
  margin-top: 2px;
}

.score-row, .suspicion-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.combo-badge {
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  color: #fff;
  font-weight: 800;
  font-size: 13px;
  padding: 2px 9px;
  border-radius: 999px;
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.4);
}

.hud-value-sm {
  font-size: 14.5px;
  font-weight: 700;
}

.state-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  text-transform: uppercase;
}

.state-badge.safe {
  background: rgba(34, 197, 94, 0.2);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.4);
}

.state-badge.patrol {
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.4);
}

.state-badge.danger {
  background: rgba(239, 68, 68, 0.25);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.5);
  animation: blinkBadge 0.5s infinite alternate;
}

@keyframes blinkBadge {
  from { transform: scale(1); }
  to { transform: scale(1.06); }
}

.progress-track {
  width: 100%;
  height: 9px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.12s linear;
}

.score-fill {
  background: linear-gradient(90deg, #38bdf8, #22c55e);
}

.suspicion-fill {
  background: linear-gradient(90deg, #22c55e, #f59e0b, #ef4444);
}

.hud-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
  align-items: flex-start;
  pointer-events: auto;
}

.gadget-btn {
  height: 44px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid rgba(245, 158, 11, 0.5);
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.25), rgba(234, 88, 12, 0.25));
  color: #fef08a;
  font-weight: 800;
  font-size: 12.5px;
  cursor: pointer;
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
}

.gadget-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  border-color: #facc15;
  background: rgba(245, 158, 11, 0.38);
}

.gadget-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  border-color: rgba(148, 163, 184, 0.2);
}

.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--panel-border);
  background: var(--panel-bg);
  color: #fff;
  font-size: 19px;
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: transform 0.15s, border-color 0.15s;
}

.icon-btn:hover {
  transform: translateY(-2px);
  border-color: var(--accent-blue);
}

/* Warning Banner */
.warning-banner {
  position: fixed;
  top: 96px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 12;
  background: rgba(220, 38, 38, 0.92);
  border: 2px solid #fca5a5;
  color: #fff;
  padding: 8px 20px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 8px 25px rgba(220, 38, 38, 0.5);
  animation: bannerBounce 0.45s infinite alternate;
  pointer-events: none;
}

@keyframes bannerBounce {
  from { transform: translateX(-50%) translateY(0px); }
  to { transform: translateX(-50%) translateY(-4px); }
}

/* Boss Sudden Question QTE Card */
.qte-card {
  position: fixed;
  left: 20px;
  bottom: 24px;
  width: 340px;
  z-index: 15;
  background: rgba(15, 23, 42, 0.95);
  border: 2px solid #f59e0b;
  border-radius: 16px;
  padding: 14px 16px;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.65);
  animation: qtePop 0.25s ease-out;
}

@keyframes qtePop {
  from { transform: translateY(20px) scale(0.95); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

.qte-header {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 800;
  color: #fbbf24;
  margin-bottom: 6px;
}

.qte-question {
  font-size: 14px;
  font-weight: 700;
  color: #f8fafc;
  margin-bottom: 10px;
}

.qte-options {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 10px;
}

.qte-btn {
  text-align: left;
  padding: 8px 11px;
  border-radius: 9px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(30, 41, 59, 0.9);
  color: #e2e8f0;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.12s;
}

.qte-btn:hover {
  border-color: #38bdf8;
  background: rgba(56, 189, 248, 0.2);
}

.qte-bar-track {
  width: 100%;
  height: 6px;
  background: rgba(255,255,255,0.12);
  border-radius: 999px;
  overflow: hidden;
}

.qte-bar-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #ef4444, #f59e0b);
}

/* Floating 3D labels */
#floating-labels {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 6;
}

.float-popup {
  position: absolute;
  transform: translate(-50%, -50%);
  font-weight: 800;
  font-size: 15px;
  padding: 3px 8px;
  border-radius: 8px;
  white-space: nowrap;
  pointer-events: none;
  text-shadow: 0 2px 4px rgba(0,0,0,0.65);
  transition: opacity 0.15s;
}

.boss-bubble, .npc-bubble {
  position: absolute;
  transform: translate(-50%, -100%);
  background: rgba(15, 23, 42, 0.92);
  border: 2px solid #fbbf24;
  color: #fff;
  font-weight: 800;
  font-size: 13px;
  padding: 5px 11px;
  border-radius: 12px;
  box-shadow: 0 6px 16px rgba(0,0,0,0.45);
  white-space: nowrap;
}

.boss-bubble.alert {
  background: #dc2626;
  border-color: #fef08a;
  font-size: 14.5px;
}

.npc-bubble.ally {
  background: rgba(6, 78, 59, 0.95);
  border-color: #34d399;
  color: #ecfdf5;
}

.npc-bubble.snitch {
  background: rgba(124, 45, 18, 0.95);
  border-color: #fb923c;
  color: #fff7ed;
}

/* Interactive PC Monitor Panel (Bottom-Right) */
#pc-monitor-panel {
  position: fixed;
  right: 18px;
  bottom: 14px;
  z-index: 10;
  width: 465px;
  max-width: calc(100vw - 32px);
}

.monitor-bezel {
  background: #1e293b;
  border: 3px solid #475569;
  border-radius: 16px;
  padding: 9px;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255,255,255,0.08);
}

.monitor-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #0f172a;
  padding: 6px 10px;
  border-radius: 9px 9px 0 0;
  border-bottom: 1px solid #334155;
}

.window-dots {
  display: flex;
  gap: 5px;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}
.dot.red { background: #ef4444; }
.dot.yellow { background: #f59e0b; }
.dot.green { background: #22c55e; }

.window-title {
  font-size: 12px;
  font-weight: 700;
  color: #e2e8f0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mode-pill {
  font-size: 10px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 6px;
}

.mode-pill.gaming {
  background: rgba(168, 85, 247, 0.25);
  color: #e9d5ff;
  border: 1px solid #a855f7;
}

.mode-pill.working {
  background: rgba(34, 197, 94, 0.22);
  color: #bbf7d0;
  border: 1px solid #22c55e;
}

.mode-pill.desktop {
  background: rgba(245, 158, 11, 0.25);
  color: #fef08a;
  border: 1px solid #f59e0b;
}

/* OS Taskbar Tabs: Desktop + 5 Games */
.minigame-tabs {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  background: #0f172a;
  border-bottom: 1px solid #334155;
  gap: 3px;
  padding: 4px 5px;
}

.mg-tab {
  background: rgba(255,255,255,0.05);
  border: 1px solid transparent;
  color: #94a3b8;
  font-size: 10.5px;
  font-weight: 700;
  padding: 4px 3px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.12s;
}

.mg-tab.active {
  background: rgba(56, 189, 248, 0.2);
  border-color: rgba(56, 189, 248, 0.5);
  color: #fff;
}

.monitor-screen-wrapper {
  position: relative;
  width: 100%;
  height: 245px;
  background: #090d16;
  border-radius: 0 0 8px 8px;
  overflow: hidden;
  border: 1px solid #334155;
}

#pc-screen-canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}

/* Alt+Tab Overlay */
#alttab-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.alttab-box {
  background: rgba(30, 41, 59, 0.96);
  border: 1px solid #64748b;
  border-radius: 12px;
  padding: 14px 20px;
  text-align: center;
  width: 265px;
}

.alttab-box.lagging {
  border: 2px solid #ef4444;
  background: rgba(69, 10, 10, 0.95);
  animation: shakeBox 0.15s infinite alternate;
}

@keyframes shakeBox {
  from { transform: translateX(-3px); }
  to { transform: translateX(3px); }
}

.alttab-icons {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-bottom: 10px;
}

.alttab-app {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 24px;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(255,255,255,0.06);
}

.alttab-app span {
  font-size: 11px;
  font-weight: 700;
  margin-top: 2px;
}

.alttab-arrow {
  font-size: 18px;
  color: var(--accent-blue);
  font-weight: 800;
}

.alttab-bar-track {
  width: 100%;
  height: 6px;
  background: rgba(255,255,255,0.12);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 6px;
}

.alttab-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--accent-blue);
}

.alttab-caption {
  font-size: 11px;
  color: #cbd5e1;
  font-weight: 700;
}

.monitor-controls {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.control-row {
  display: flex;
  gap: 6px;
}

.switch-btn {
  flex: 1;
  padding: 9px 10px;
  border-radius: 10px;
  border: none;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: #fff;
  font-weight: 800;
  font-size: 12.5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
  transition: transform 0.1s, filter 0.15s;
}

.switch-btn:hover {
  filter: brightness(1.1);
}

.switch-btn.work-active {
  background: linear-gradient(135deg, #a855f7, #7e22ce);
  box-shadow: 0 4px 12px rgba(147, 51, 234, 0.4);
}

.sub-work-btn {
  padding: 9px 10px;
  border-radius: 10px;
  border: 1px solid rgba(34, 197, 94, 0.45);
  background: rgba(21, 128, 61, 0.28);
  color: #bbf7d0;
  font-weight: 800;
  font-size: 11.5px;
  cursor: pointer;
  white-space: nowrap;
}

.sub-work-btn:hover {
  background: rgba(21, 128, 61, 0.45);
}

.key-hint {
  background: rgba(0, 0, 0, 0.35);
  padding: 2px 6px;
  border-radius: 5px;
  font-size: 10.5px;
  letter-spacing: 0.04em;
  border: 1px solid rgba(255,255,255,0.25);
}

.mini-help {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-card {
  background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
  border: 1px solid rgba(148, 163, 184, 0.3);
  border-radius: 22px;
  max-width: 760px;
  width: 100%;
  padding: 26px 30px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.65);
  text-align: center;
}

.game-logo-badge {
  display: inline-block;
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent-blue);
  border: 1px solid rgba(56, 189, 248, 0.35);
  font-size: 12px;
  font-weight: 800;
  padding: 4px 12px;
  border-radius: 999px;
  margin-bottom: 6px;
}

.game-title {
  font-size: 38px;
  font-weight: 900;
  letter-spacing: -0.02em;
  background: linear-gradient(90deg, #38bdf8, #f59e0b, #ef4444);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 4px;
}

.game-subtitle {
  color: #cbd5e1;
  font-size: 14px;
  margin-bottom: 18px;
}

.rules-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  text-align: left;
  margin-bottom: 18px;
}

.rule-box {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 11px 13px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.rule-icon {
  font-size: 22px;
  line-height: 1;
  margin-top: 2px;
}

.rule-content h3 {
  font-size: 13.5px;
  font-weight: 800;
  color: #f8fafc;
  margin-bottom: 3px;
}

.rule-content p {
  font-size: 12px;
  color: #94a3b8;
  line-height: 1.42;
}

.difficulty-selector {
  margin-bottom: 20px;
}

.diff-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: #94a3b8;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.day-buttons {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.day-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 2px solid rgba(148, 163, 184, 0.2);
  border-radius: 12px;
  padding: 9px 6px;
  color: #e2e8f0;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 3px;
  transition: all 0.15s;
}

.day-btn strong {
  font-size: 12.5px;
}

.day-btn span {
  font-size: 10.5px;
  color: #94a3b8;
}

.day-btn.active {
  background: rgba(56, 189, 248, 0.18);
  border-color: var(--accent-blue);
  color: #fff;
}

.day-btn.completed {
  border-color: rgba(34, 197, 94, 0.5);
}

.primary-cta-btn {
  width: 100%;
  padding: 14px 22px;
  border-radius: 14px;
  border: none;
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 10px 25px rgba(34, 197, 94, 0.35);
  transition: transform 0.15s, filter 0.15s;
}

.primary-cta-btn:hover {
  transform: translateY(-2px);
  filter: brightness(1.08);
}

.next-day-btn {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  box-shadow: 0 10px 25px rgba(37, 99, 235, 0.4);
  margin-bottom: 8px;
}

.secondary-cta-btn {
  width: 100%;
  margin-top: 8px;
  padding: 11px 18px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.3);
  background: rgba(255, 255, 255, 0.06);
  color: #cbd5e1;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.end-card {
  max-width: 520px;
}

.end-icon {
  font-size: 52px;
  margin-bottom: 6px;
}

.end-title {
  font-size: 28px;
  font-weight: 900;
  margin-bottom: 6px;
}

.end-reason {
  color: #cbd5e1;
  font-size: 14px;
  margin-bottom: 18px;
}

.stats-summary {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}

.stat-item {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.stat-name {
  font-size: 11px;
  color: #94a3b8;
}

.stat-val {
  font-size: 18px;
  color: #f8fafc;
}

@media (max-width: 900px) {
  #hud-top {
    flex-wrap: wrap;
  }
  #pc-monitor-panel {
    width: 340px;
  }
  .rules-grid, .day-buttons {
    grid-template-columns: 1fr 1fr;
  }
}
