#scanlines::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: radial-gradient(
    ellipse at center,
    transparent 65%,
    rgba(0, 0, 0, 0.15) 100%
  );
}

/* ── Top bar ─────────────────────────────────────────────── */
#top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2px 4px 6px;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(0, 255, 65, 0.08);
  margin-bottom: 4px;
}

#top-bar .title {
  font-size: 1.1rem;
  font-weight: bold;
  color: var(--accent);
  letter-spacing: 3px;
  text-shadow: 0 0 15px rgba(0, 255, 65, 0.6), 0 0 40px rgba(0, 255, 65, 0.2);
}
.dim { color: var(--text-dim); }

#connection-status {
  font-size: 0.6rem;
  padding: 3px 10px;
  border-radius: 10px;
  letter-spacing: 0.5px;
  border: 1px solid transparent;
}
#connection-status.connected    { background: rgba(0,200,0,0.15); color: #4f4; border-color: rgba(0,200,0,0.2); }
#connection-status.disconnected { background: rgba(120,120,0,0.1); color: #997; border-color: rgba(120,120,0,0.15); }

/* ── Difficulty badge ────────────────────────────────────── */
#diff-badge {
  font-size: 0.48rem;
  font-weight: bold;
  letter-spacing: 1.5px;
  padding: 2px 8px;
  border: 1px solid;
  border-radius: var(--radius-sm);
  opacity: 0.7;
}
#diff-badge.hidden { display: none; }

/* ── Status bar ──────────────────────────────────────────── */
#status-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 14px;
  background:
    linear-gradient(180deg, rgba(0,255,65,0.08) 0%, rgba(0,255,65,0.03) 100%);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  margin-bottom: 4px;
  box-shadow:
    var(--depth-shadow),
    inset 0 1px 0 rgba(0,255,65,0.08);
}

#integrity-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

#integrity-wrap .label {
  font-size: 0.55rem;
  color: var(--text-dim);
  letter-spacing: 1px;
  white-space: nowrap;
}

#integrity-text {
  font-size: 0.8rem;
  font-weight: bold;
  color: var(--accent);
  min-width: 32px;
  text-align: right;
  text-shadow: 0 0 8px rgba(0, 255, 65, 0.3);
}

#stats-wrap {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 0.72rem;
  flex-shrink: 0;
}

#score-text {
  color: var(--yellow);
  font-weight: bold;
  min-width: 50px;
  text-align: right;
  font-size: 0.9rem;
  text-shadow: 0 0 10px rgba(255, 204, 0, 0.4), 0 0 25px rgba(255, 204, 0, 0.15);
}

#level-text {
  color: var(--text);
  opacity: 0.7;
  font-size: 0.65rem;
}

#tier-text {
  font-size: 0.55rem;
  font-weight: bold;
  letter-spacing: 1px;
  opacity: 0.9;
}

#combo-text {
  color: var(--orange);
  font-weight: bold;
  min-width: 20px;
  font-size: 0.75rem;
  text-shadow: 0 0 8px rgba(255, 136, 0, 0.4), 0 0 20px rgba(255, 136, 0, 0.15);
}

#multi-text {
  color: var(--orange);
  font-weight: bold;
  font-size: 0.68rem;
}

#timer-text {
  color: var(--text-dim);
  font-size: 0.62rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.5px;
  min-width: 28px;
  text-align: center;
  text-shadow: 0 0 4px rgba(0,255,65,0.1);
}

/* ── Level progress bar ──────────────────────────────────── */
#level-progress-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  margin-bottom: 1px;
}

#level-progress-track {
  flex: 1;
  height: 5px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

#level-progress-fill {
  background: var(--accent);
  box-shadow: 0 0 10px rgba(0, 255, 65, 0.35), 0 0 20px rgba(0, 255, 65, 0.15);
  height: 100%;
  width: 100%;
  border-radius: 2px;
  will-change: transform;
  transform-origin: left center;
}

#level-progress-label {
  font-size: 0.42rem;
  color: var(--text-dim);
  letter-spacing: 0.5px;
  white-space: nowrap;
  min-width: 38px;
  text-align: right;
}

/* ── Score popups (floating, no layout impact) ──────────── */
#score-popups {
  position: absolute;
  top: 15%;
  left: 0;
  right: 0;
  pointer-events: none;
  z-index: 15;
  overflow: visible;
}

.score-popup {
  position: absolute;
  font-size: 0.75rem;
  font-weight: bold;
  letter-spacing: 1px;
  text-shadow: 0 0 10px currentColor, 0 0 25px currentColor;
  pointer-events: none;
  animation: scoreFloat 0.9s ease-out forwards;
  white-space: nowrap;
}

@keyframes scoreFloat {
  0%   { opacity: 1; transform: translateY(0); }
  70%  { opacity: 0.8; }
  100% { opacity: 0; transform: translateY(-40px); }
}

/* ── Shield indicator (floating) ──────────────────────────── */
#shield-indicator {
  position: absolute;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 15;
  pointer-events: none;
  text-align: center;
  font-size: 0.65rem;
  font-weight: bold;
  color: #66ccff;
  letter-spacing: 2px;
  padding: 5px 16px;
  background: rgba(0, 20, 40, 0.8);
  border: 1px solid rgba(102, 204, 255, 0.4);
  border-radius: 20px;
  text-shadow: 0 0 12px rgba(102, 204, 255, 0.6), 0 0 25px rgba(102, 204, 255, 0.3);
  box-shadow: 0 2px 12px rgba(0,0,0,0.4), 0 0 15px rgba(102,204,255,0.15);
  animation: shieldPulse 0.8s ease-in-out infinite;
  white-space: nowrap;
}
#shield-indicator.hidden { display: none; }

@keyframes shieldPulse {
  0%, 100% { opacity: 1; text-shadow: 0 0 10px rgba(102, 204, 255, 0.5); }
  50%      { opacity: 0.6; text-shadow: 0 0 20px rgba(102, 204, 255, 0.8); }
}

/* ── Bar tracks (reusable) ───────────────────────────────── */
.bar-track {
  height: 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
  box-shadow: inset 0 1px 4px rgba(0,0,0,0.3);
}

.bar-fill {
  height: 100%;
  width: 100%;
  border-radius: 3px;
  will-change: transform;
  transform-origin: left center;
}

.integrity-track {
  flex: 1;
  min-width: 60px;
  height: 10px;
}

.integrity-track .bar-fill {
  background: var(--accent);
  box-shadow: 0 0 12px rgba(0, 255, 65, 0.4), 0 0 25px rgba(0, 255, 65, 0.15);
  transition: background 0.3s;
}

/* ── Game layout (CSS Grid) ───────────────────────────────── */
#game-layout {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1.3fr 1fr;
  grid-template-rows: minmax(0, 1fr) minmax(0, 2.5fr);
  grid-template-areas:
    "firewall firewall firewall"
    "decrypt  center   reactor";
  gap: 8px;
  min-height: 0;
}

#sector-g  { grid-area: firewall; }
#sector-b  { grid-area: decrypt; }
#sector-r  { grid-area: reactor; }
#center-column {
  grid-area: center;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

.sector {
  display: flex;
  flex-direction: column;
  background:
    linear-gradient(180deg, rgba(0,255,65,0.07) 0%, rgba(0,255,65,0.02) 40%, rgba(0,0,0,0.15) 100%);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
  min-height: 0;
  contain: layout style;
  box-shadow:
    var(--depth-shadow),
    inset 0 1px 0 rgba(0,255,65,0.1),
    inset 0 -2px 8px rgba(0,0,0,0.4),
    inset 0 0 40px rgba(0, 0, 0, 0.2);
  /* Monitor bezel effect */
  outline: 1px solid rgba(255, 255, 255, 0.05);
  outline-offset: -4px;
  position: relative;
}

/* Inner screen glow — CRT phosphor edge light */
.sector::after {
  content: '';
  position: absolute;
  inset: 3px;
  border-radius: calc(var(--radius-lg) - 3px);
  pointer-events: none;
  box-shadow: inset 0 0 25px rgba(0, 255, 65, 0.04), inset 0 0 60px rgba(0, 255, 65, 0.015);
  z-index: 0;
}

.sector.flash-r { border-color: var(--red);  box-shadow: var(--depth-shadow), inset 0 0 35px rgba(255,56,56,0.2), 0 0 20px rgba(255,56,56,0.15); }
.sector.flash-g { border-color: var(--green); box-shadow: var(--depth-shadow), inset 0 0 35px rgba(56,255,92,0.2), 0 0 20px rgba(56,255,92,0.15); }
.sector.flash-b { border-color: var(--blue); box-shadow: var(--depth-shadow), inset 0 0 35px rgba(56,136,255,0.2), 0 0 20px rgba(56,136,255,0.15); }
.sector.flash-warn { border-color: var(--orange); box-shadow: var(--depth-shadow), inset 0 0 30px rgba(255,136,0,0.18), 0 0 15px rgba(255,136,0,0.12); }

/* Sector urgency pulsing — draws attention to sectors needing input */
.sector.sector-urgent-r {
  border-color: rgba(255, 56, 56, 0.6);
  animation: sectorPulseR 0.6s ease-in-out infinite;
}
.sector.sector-urgent-g {
  border-color: rgba(56, 255, 92, 0.6);
  animation: sectorPulseG 0.5s ease-in-out infinite;
}
.sector.sector-urgent-b {
  border-color: rgba(56, 136, 255, 0.6);
  animation: sectorPulseB 0.6s ease-in-out infinite;
}

@keyframes sectorPulseR {
  0%, 100% { border-color: rgba(255,56,56,0.3); }
  50%      { border-color: rgba(255,56,56,0.7); }
}
@keyframes sectorPulseG {
  0%, 100% { border-color: rgba(56,255,92,0.3); }
  50%      { border-color: rgba(56,255,92,0.7); }
}
@keyframes sectorPulseB {
  0%, 100% { border-color: rgba(56,136,255,0.3); }
  50%      { border-color: rgba(56,136,255,0.7); }
}

/* Button glow when urgent */
.btn.btn-urgent {
  animation: btnUrgentGlow 0.5s ease-in-out infinite;
}
@keyframes btnUrgentGlow {
  0%, 100% { opacity: 0.75; }
  50%      { opacity: 1; }
}

/* Side sectors need min-width: 0 for grid overflow protection */
#sector-b, #sector-r { min-width: 0; }

/* Colored left accent borders for instant sector identification + monitor bezel glow */
#sector-r { border-left: 5px solid var(--red-dim); }
#sector-g { border-top: 5px solid var(--green-dim); border-left-width: 2px; }
#sector-b { border-left: 5px solid var(--blue-dim); }
#sector-r.flash-r { border-left-color: var(--red); }
#sector-g.flash-g { border-top-color: var(--green); }
#sector-b.flash-b { border-left-color: var(--blue); }

/* Per-sector inner glow colors */
#sector-r::after { box-shadow: inset 0 0 30px rgba(255, 56, 56, 0.05), inset 0 0 60px rgba(255, 56, 56, 0.02); }
#sector-g::after { box-shadow: inset 0 0 30px rgba(56, 255, 92, 0.05), inset 0 0 60px rgba(56, 255, 92, 0.02); }
#sector-b::after { box-shadow: inset 0 0 30px rgba(56, 136, 255, 0.05), inset 0 0 60px rgba(56, 136, 255, 0.02); }

.sector-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  flex-shrink: 0;
  min-height: 30px;
  /* Monitor label strip — more visible gradient */
  background: linear-gradient(180deg, rgba(255,255,255,0.05) 0%, rgba(255,255,255,0.01) 100%);
  position: relative;
  z-index: 1;
}

.sector-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot-r { background: var(--red);   box-shadow: 0 0 10px rgba(255,56,56,0.6), 0 0 20px rgba(255,56,56,0.25); }
.dot-g { background: var(--green); box-shadow: 0 0 10px rgba(56,255,92,0.6), 0 0 20px rgba(56,255,92,0.25); }
.dot-b { background: var(--blue);  box-shadow: 0 0 10px rgba(56,136,255,0.6), 0 0 20px rgba(56,136,255,0.25); }

.sector-name {
  font-size: 0.72rem;
  font-weight: bold;
  letter-spacing: 2px;
  flex: 1;
  text-transform: uppercase;
}
.name-r { color: var(--red); text-shadow: 0 0 8px rgba(255,56,56,0.3); }
.name-g { color: var(--green); text-shadow: 0 0 8px rgba(56,255,92,0.3); }
.name-b { color: var(--blue); text-shadow: 0 0 8px rgba(56,136,255,0.3); }

.sector-val {
  font-size: 0.72rem;
  font-weight: bold;
  min-width: 60px;
  text-align: right;
  min-height: 1em;
}

/* Float fw-result so it doesn't displace the sector-g header layout */
#fw-result {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  min-width: auto;
  min-height: auto;
  pointer-events: none;
  z-index: 2;
  text-shadow: 0 0 8px currentColor, 0 0 16px currentColor;
  animation: none;
}
#fw-result:not(:empty) {
  animation: fwResultFloat 0.6s ease-out forwards;
}
@keyframes fwResultFloat {
  0%   { opacity: 1; transform: translateY(-50%); }
  70%  { opacity: 0.9; }
  100% { opacity: 0; transform: translateY(-50%) translateY(-12px); }
}

.sector-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(2px, 0.5vh, 4px) 8px clamp(2px, 0.5vh, 5px);
  gap: clamp(1px, 0.3vh, 4px);
  min-height: 0;
}

.sector-status {
  font-size: 0.62rem;
  letter-spacing: 2px;
  text-align: center;
  color: var(--text-dim);
  transition: color 0.15s;
  min-height: 1.2em;
  flex-shrink: 0;
  text-shadow: 0 0 6px rgba(0,255,65,0.15);
}

/* ── Sector R: Reactor (vertical bar) ────────────────────── */
