/* ==========================================================================
   Julstöket i Huset — "Nordisk Julafton" Festive Christmas Eve UI
   Midnight Spruce · Tomteröd Velvet · Candlelight Gold · December Frost
   Crisp 640x360 HD 2:1 Isometric Pixelart + Cozy Swedish Holiday Atmosphere
   ========================================================================== */

:root {
  /* Deep Nordic Winter Pine & Twilight Spruce */
  --bg: #081512;
  --bg-deep: #06100e;
  --panel: #0c1f1a;
  --panel2: #122b24;
  --panel3: #193930;
  --inset-bg: #091714;
  --border: #2a5748;
  --border-soft: #1b3d32;

  /* Swedish Julröd (Tomteröd / Lingonberry Crimson) */
  --falu: #a81e2a;
  --falu-hi: #dc3845;
  --falu-deep: #54121b;
  --falu-glow: rgba(220, 56, 69, 0.36);

  /* Warm Candlelight Brass & Starlight Gold */
  --brass: #d4a346;
  --brass-hi: #fae094;
  --brass-dim: #7c6028;
  --amber: #f7ad45;

  /* Crisp December Snow & Frosted Spruce Text */
  --parchment: #eef4f1;
  --parchment-hi: #ffffff;
  --frost: #cbe5f3;
  --muted: #8fb4a7;

  /* Semantic & Holiday Palette */
  --good: #5ed68c;
  --bad: #f26c60;
  --spruce: #276846;
  --spruce-hi: #429a6a;
  --asl: #5ee6b5;
  --agent: #7ec4f5;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--parchment);
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", sans-serif;
  overflow: hidden;
  user-select: none;
}

/* Main 2-column application frame (fits 1280x800 and 1440x900 with zero overflow) */
.app {
  display: grid;
  grid-template-rows: 50px 1fr;
  grid-template-columns: minmax(0, 1fr) 364px;
  width: 100vw;
  height: 100vh;
  background: var(--bg);
}

/* ==========================================================================
   TOP BAR — VELVET JULRÖD HEADER + DRAPED TWINKLING LJUSSLINGA
   ========================================================================== */
header.topbar {
  position: relative;
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 3px 14px 0;
  background:
    radial-gradient(ellipse 360px 52px at 14% 50%, rgba(242, 198, 109, 0.14), transparent 72%),
    radial-gradient(ellipse 300px 52px at 86% 50%, rgba(94, 214, 140, 0.10), transparent 72%),
    linear-gradient(180deg, #621722 0%, #441019 56%, #2b0b12 100%);
  border-bottom: 1px solid rgba(244, 206, 122, 0.55);
  box-shadow:
    inset 0 1px 0 rgba(255, 226, 168, 0.22),
    0 4px 16px rgba(0, 0, 0, 0.52);
  z-index: 25;
}

/* Woven Nordic Christmas ribbon trim along the very top 3px edge */
header.topbar::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: repeating-linear-gradient(
    90deg,
    #d93845 0px,
    #d93845 18px,
    #f6d47d 18px,
    #f6d47d 24px,
    #2d7a4f 24px,
    #2d7a4f 42px,
    #f3f8fb 42px,
    #f3f8fb 46px
  );
  opacity: 0.92;
  pointer-events: none;
}

/* Draped pine & twinkling fairy-light SVG hanging beneath header */
.fairy-garland {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% - 1px);
  width: 100%;
  height: 22px;
  pointer-events: none;
  z-index: 26;
  overflow: visible;
  display: block;
}

.garland-pine {
  fill: none;
  stroke: #1b5c3a;
  stroke-width: 4.5;
  stroke-linecap: round;
  stroke-dasharray: 2 3.5;
  opacity: 0.92;
}

.garland-wire {
  fill: none;
  stroke: #0e2e1f;
  stroke-width: 1.5;
  opacity: 0.95;
}

@keyframes bulbTwinkle {
  0%, 100% { opacity: 1; }
  45% { opacity: 0.58; }
  65% { opacity: 0.96; }
}

.bulb {
  animation: bulbTwinkle 3.2s ease-in-out infinite;
}

.b-gold {
  fill: #ffe28a;
  animation-delay: 0s;
}

.b-red {
  fill: #ff5b66;
  animation-delay: 0.8s;
}

.b-green {
  fill: #64e89a;
  animation-delay: 1.6s;
}

.b-ice {
  fill: #a8e4ff;
  animation-delay: 2.3s;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  white-space: nowrap;
  min-width: 0;
}

.brand-badge {
  background: linear-gradient(180deg, #d83642 0%, #991a25 100%);
  border: 1px solid var(--brass-hi);
  color: #fff9e8;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  padding: 3px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  box-shadow: 0 0 10px rgba(246, 212, 125, 0.28);
}

.brand h1 {
  font-size: 15px;
  margin: 0;
  font-weight: 800;
  letter-spacing: 0.015em;
  color: var(--parchment-hi);
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.5);
}

.brand .seed-pill {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--brass-hi);
  background: rgba(14, 38, 30, 0.72);
  border: 1px solid rgba(242, 206, 122, 0.42);
  padding: 2px 8px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}

.top-metrics {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: nowrap;
}

.metric-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(9, 24, 20, 0.76);
  border: 1px solid rgba(244, 206, 122, 0.28);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11.5px;
  color: #d6e6df;
  white-space: nowrap;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07);
}

.metric-chip b {
  color: var(--brass-hi);
  font-variant-numeric: tabular-nums;
}

.metric-chip.mood {
  border-color: rgba(94, 214, 140, 0.42);
}

.metric-chip.mood b {
  color: var(--good);
}

.metric-chip.held b {
  color: var(--parchment-hi);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-dot {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10.5px;
  color: #cfe4dc;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(9, 24, 20, 0.72);
  white-space: nowrap;
}

.status-dot::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--good);
  box-shadow: 0 0 7px var(--good);
}

.status-dot.local::before {
  background: var(--amber);
  box-shadow: 0 0 7px var(--amber);
}

/* ==========================================================================
   BUTTONS & CONTROLS (FROSTED PINE, JULRÖD & CANDLELIGHT GOLD)
   ========================================================================== */
button.btn,
select.select,
input.input {
  font-family: inherit;
  background: linear-gradient(180deg, #17352c 0%, #112821 100%);
  color: var(--parchment);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 9px;
  font-size: 11.5px;
  font-weight: 600;
  transition: border-color 0.14s, background 0.14s, box-shadow 0.14s, transform 0.06s;
}

button.btn {
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

button.btn:hover:not(:disabled) {
  border-color: var(--brass);
  background: linear-gradient(180deg, #1f473b 0%, #16342b 100%);
  box-shadow: 0 0 10px rgba(242, 206, 122, 0.14);
}

button.btn:active:not(:disabled) {
  transform: translateY(1px);
}

button.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

button.btn.active {
  background: linear-gradient(180deg, rgba(186, 36, 48, 0.42) 0%, rgba(124, 22, 32, 0.36) 100%);
  border-color: var(--brass-hi);
  color: var(--brass-hi);
  box-shadow: 0 0 10px rgba(220, 56, 69, 0.22);
}

button.btn.primary {
  background: linear-gradient(180deg, #d8313d 0%, #9e1c27 100%);
  border-color: #f48c90;
  color: #fffaf0;
  font-weight: 700;
  box-shadow:
    inset 0 1px 0 rgba(255, 240, 210, 0.26),
    0 2px 10px rgba(190, 32, 46, 0.36);
}

button.btn.primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #e83c48 0%, #b3222e 100%);
  border-color: var(--brass-hi);
  box-shadow:
    inset 0 1px 0 rgba(255, 244, 220, 0.35),
    0 0 14px rgba(244, 206, 122, 0.35);
}

button.btn.accent {
  background: linear-gradient(180deg, rgba(212, 163, 70, 0.24) 0%, rgba(140, 102, 36, 0.18) 100%);
  border-color: var(--brass);
  color: var(--brass-hi);
}

button.btn.accent:hover:not(:disabled) {
  background: linear-gradient(180deg, rgba(228, 178, 82, 0.34) 0%, rgba(158, 114, 40, 0.26) 100%);
  border-color: var(--brass-hi);
}

button.btn.spruce {
  background: linear-gradient(180deg, rgba(46, 125, 80, 0.42) 0%, rgba(28, 82, 52, 0.38) 100%);
  border-color: var(--spruce-hi);
  color: #e2faec;
}

button.btn.spruce:hover:not(:disabled) {
  background: linear-gradient(180deg, rgba(58, 148, 96, 0.52) 0%, rgba(36, 102, 66, 0.46) 100%);
  border-color: var(--good);
}

button.btn.small {
  padding: 3px 8px;
  font-size: 10.5px;
}

input.input,
select.select {
  width: 100%;
  background: var(--inset-bg);
  font-weight: 500;
  outline: none;
  color: var(--parchment);
}

select.select option {
  background: #0d211b;
  color: var(--parchment);
}

input.input:focus,
select.select:focus {
  border-color: var(--brass-hi);
  box-shadow: 0 0 0 2px rgba(250, 224, 148, 0.16);
}

/* ==========================================================================
   LEFT COLUMN: STAGE VIEWPORT + SENSORY TICKER + TACTILE CONTROLS
   ========================================================================== */
main.main-col {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--bg-deep);
  overflow: hidden;
}

.stage-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 48%, #152b38 0%, #0a1820 68%, #071216 100%);
  overflow: hidden;
}

.canvas-frame {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

canvas#glCanvas,
canvas#swCanvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  cursor: pointer;
}

canvas#swCanvas {
  object-fit: contain;
}

canvas#overlayCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* Floating stage HUD pills (placed gracefully below draped fairy garland) */
.stage-hud-tl {
  position: absolute;
  top: 20px;
  left: 12px;
  display: flex;
  align-items: center;
  gap: 7px;
  background: rgba(9, 25, 21, 0.84);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(212, 163, 70, 0.46);
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 11px;
  color: var(--parchment);
  pointer-events: none;
  box-shadow: 0 3px 14px rgba(0, 0, 0, 0.45);
}

.stage-hud-tl b {
  color: var(--brass-hi);
}

.stage-hud-tr {
  position: absolute;
  top: 20px;
  right: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.mode-pill {
  background: rgba(9, 25, 21, 0.86);
  backdrop-filter: blur(6px);
  border: 1px solid var(--brass);
  color: var(--brass-hi);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.42);
}

.mode-pill.replay {
  border-color: var(--asl);
  color: var(--asl);
}

.mode-pill.director {
  border-color: var(--brass-hi);
  color: #fff3c9;
  background: linear-gradient(180deg, rgba(132, 26, 36, 0.90) 0%, rgba(68, 16, 22, 0.92) 100%);
  box-shadow: 0 0 12px rgba(242, 198, 109, 0.26);
}

/* Sensory & Event Ticker Strip */
.sensory-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background:
    linear-gradient(90deg, rgba(168, 30, 42, 0.22) 0%, rgba(16, 40, 33, 0.96) 28%, rgba(11, 29, 24, 0.98) 100%);
  border-top: 1px solid rgba(212, 163, 70, 0.44);
  border-bottom: 1px solid var(--border-soft);
  min-height: 45px;
}

.sensory-icon {
  font-size: 16px;
  flex: 0 0 auto;
  filter: drop-shadow(0 0 6px rgba(250, 214, 120, 0.45));
}

.sensory-content {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sensory-event {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--parchment-hi);
  line-height: 1.32;
  white-space: normal;
}

.sensory-event.note-highlight {
  color: #ffe8a3;
}

.sensory-event.warn {
  color: #ffa096;
}

.sensory-cues {
  font-size: 11px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.cue-tag {
  background: rgba(247, 173, 69, 0.15);
  border: 1px solid rgba(247, 173, 69, 0.42);
  color: #ffe1a4;
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 10.5px;
}

/* Tactile Control Deck below canvas */
.control-deck {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 14px;
  background: linear-gradient(180deg, #0c1f1a 0%, #081512 100%);
}

.dpad-cluster {
  display: flex;
  align-items: center;
  gap: 4px;
}

.dpad-cluster .btn {
  min-width: 34px;
  height: 30px;
  padding: 0 8px;
  font-size: 12px;
}

.action-cluster {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.action-cluster .btn {
  height: 30px;
  padding: 0 10px;
  font-size: 11.5px;
}

.key-badge {
  font-size: 9.5px;
  font-weight: 700;
  color: var(--frost);
  background: rgba(7, 20, 17, 0.9);
  border: 1px solid #2b5a4b;
  border-radius: 3px;
  padding: 1px 4px;
  margin-left: 2px;
}

.hotkey-hint {
  font-size: 10.5px;
  color: var(--muted);
  white-space: nowrap;
}

.hotkey-hint b {
  color: var(--parchment);
}

/* Replay Controls Bar (replaces deck when in Replay / Live mode) */
.replay-deck {
  display: none;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: linear-gradient(180deg, #0d221c 0%, #081612 100%);
  border-top: 1px solid rgba(94, 230, 181, 0.34);
}

.replay-deck.active {
  display: flex;
}

.replay-deck input[type="range"] {
  flex: 1 1 auto;
  accent-color: var(--falu-hi);
  cursor: pointer;
}

.replay-step-lbl {
  font-size: 11px;
  color: var(--brass-hi);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  min-width: 72px;
  text-align: center;
}

/* ==========================================================================
   RIGHT COLUMN: NORDIC WINTER PINE & FESTIVE HOLIDAY SIDEPANEL
   ========================================================================== */
aside.sidebar {
  background:
    radial-gradient(circle at 86% 6%, rgba(220, 56, 69, 0.14), transparent 40%),
    radial-gradient(circle at 12% 32%, rgba(70, 178, 120, 0.10), transparent 44%),
    linear-gradient(180deg, #0d221c 0%, #091814 100%);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

nav.tab-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 20px 9px 7px;
  background: rgba(7, 19, 16, 0.85);
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}

.tab-btn {
  background: linear-gradient(180deg, #132c25 0%, #0e221c 100%);
  color: var(--muted);
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  padding: 6px 4px;
  font-size: 10.5px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  transition: all 0.14s;
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--parchment-hi);
  border-color: var(--brass);
  background: linear-gradient(180deg, #1a3c32 0%, #122b24 100%);
}

.tab-btn.active {
  background: linear-gradient(180deg, rgba(196, 36, 48, 0.56) 0%, rgba(126, 20, 30, 0.48) 100%);
  border-color: var(--brass-hi);
  color: #fff6dc;
  box-shadow:
    inset 0 1px 0 rgba(255, 232, 180, 0.28),
    0 2px 10px rgba(196, 36, 48, 0.30);
}

.tab-btn .t-ico {
  font-size: 13.5px;
  line-height: 1;
}

.tab-panels {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 8px 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.tab-panel {
  display: none;
  flex-direction: column;
  gap: 7px;
}

.tab-panel.active {
  display: flex;
}

/* Frosted Nordic Pine cards inside sidepanel */
.card {
  background: linear-gradient(180deg, #132d26 0%, #0e231d 100%);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  box-shadow:
    inset 0 1px 0 rgba(226, 246, 255, 0.08),
    0 4px 12px rgba(0, 0, 0, 0.24);
}

.card.progression-card {
  background: linear-gradient(180deg, rgba(16, 46, 38, 0.92) 0%, rgba(9, 25, 21, 0.96) 100%);
  border-color: rgba(94, 230, 181, 0.45);
}

.card-title {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--brass-hi);
  margin: 0 0 6px 0;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(212, 163, 70, 0.18);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.card-title span.sub {
  color: var(--muted);
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
}

.premise-box {
  position: relative;
  font-size: 11.5px;
  line-height: 1.48;
  color: #fff6e8;
  background:
    radial-gradient(circle at 96% 14%, rgba(250, 224, 148, 0.16), transparent 44%),
    linear-gradient(135deg, rgba(168, 30, 42, 0.40) 0%, rgba(18, 48, 38, 0.88) 100%);
  border: 1px solid rgba(242, 200, 116, 0.42);
  border-left: 3px solid var(--falu-hi);
  border-radius: 7px;
  padding: 8px 26px 8px 10px;
  overflow: hidden;
}

.premise-box::after {
  content: "❄";
  position: absolute;
  right: 8px;
  top: 6px;
  font-size: 14px;
  color: rgba(226, 245, 255, 0.42);
  pointer-events: none;
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-bottom: 6px;
}

.form-row:last-child {
  margin-bottom: 0;
}

.form-row label {
  font-size: 10.5px;
  color: #a9cbc0;
  font-weight: 600;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

/* Avatar picker */
.avatar-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 5px;
}

.avatar-opt {
  background: var(--inset-bg);
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  padding: 5px 2px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  transition: all 0.14s;
}

.avatar-opt:hover {
  border-color: var(--brass);
  color: var(--parchment-hi);
  background: #132d25;
}

.avatar-opt.active {
  background: linear-gradient(180deg, rgba(186, 36, 48, 0.36) 0%, rgba(20, 56, 44, 0.72) 100%);
  border-color: var(--brass-hi);
  color: var(--brass-hi);
  box-shadow: 0 0 10px rgba(242, 200, 116, 0.22);
}

.avatar-opt canvas {
  width: 28px;
  height: 36px;
  image-rendering: pixelated;
  display: block;
}

/* Live HUD inside Spela tab */
.hud-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.hud-stat {
  background: var(--inset-bg);
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  padding: 5px 8px;
}

.hud-stat .lbl {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.hud-stat .val {
  font-size: 14px;
  font-weight: 800;
  color: var(--brass-hi);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

.hud-stat .val.small-txt {
  font-size: 12px;
  color: var(--parchment-hi);
}

@keyframes candySlide {
  from { background-position: 0 0, 0 0; }
  to { background-position: 24px 0, 0 0; }
}

.progress-track {
  height: 9px;
  background: #071411;
  border: 1px solid #285546;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 7px;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.55);
}

.progress-fill {
  height: 100%;
  background-image:
    repeating-linear-gradient(
      -45deg,
      rgba(255, 255, 255, 0.16) 0px,
      rgba(255, 255, 255, 0.16) 6px,
      transparent 6px,
      transparent 12px
    ),
    linear-gradient(90deg, #dc3845 0%, #f5be58 52%, #5ed68c 100%);
  background-size: 24px 100%, 100% 100%;
  width: 0%;
  border-radius: 999px;
  transition: width 0.25s ease;
  animation: candySlide 2.6s linear infinite;
}

.episode-pills {
  display: flex;
  gap: 4px;
  margin-top: 4px;
}

.episode-pills .btn {
  flex: 1;
  font-size: 10.5px;
  padding: 4px 6px;
}

/* Finish summary banner */
.finish-banner {
  display: none;
  background:
    radial-gradient(circle at 90% 15%, rgba(250, 224, 148, 0.18), transparent 50%),
    linear-gradient(180deg, rgba(42, 122, 78, 0.42) 0%, rgba(13, 33, 27, 0.94) 100%);
  border: 1px solid var(--good);
  border-radius: 8px;
  padding: 10px 11px;
  box-shadow: 0 0 16px rgba(94, 214, 140, 0.18);
}

.finish-banner.open {
  display: block;
}

.finish-banner h3 {
  margin: 0 0 4px 0;
  font-size: 13px;
  color: var(--brass-hi);
}

.finish-banner p {
  margin: 0 0 8px 0;
  font-size: 11.5px;
  color: var(--parchment);
  line-height: 1.4;
}

/* ==========================================================================
   LEADERBOARD TAB
   ========================================================================== */
.filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.filter-pills .btn {
  font-size: 10px;
  padding: 4px 7px;
}

.lb-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.lb-entry {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  align-items: center;
  gap: 7px;
  background: var(--inset-bg);
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  padding: 6px 8px;
  transition: border-color 0.12s;
}

.lb-entry:hover {
  border-color: var(--border);
}

.lb-entry.top1 {
  border-color: rgba(250, 224, 148, 0.65);
  background: linear-gradient(90deg, rgba(212, 163, 70, 0.22) 0%, rgba(158, 28, 39, 0.14) 38%, var(--inset-bg) 85%);
  box-shadow: 0 0 12px rgba(242, 200, 116, 0.12);
}

.lb-entry.top2 {
  border-color: rgba(196, 224, 240, 0.42);
  background: linear-gradient(90deg, rgba(196, 224, 240, 0.12) 0%, var(--inset-bg) 75%);
}

.lb-entry.top3 {
  border-color: rgba(224, 146, 94, 0.40);
  background: linear-gradient(90deg, rgba(224, 146, 94, 0.11) 0%, var(--inset-bg) 75%);
}

.lb-rank {
  font-size: 12.5px;
  font-weight: 800;
  color: var(--brass-hi);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.lb-info {
  min-width: 0;
}

.lb-name-row {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.lb-name {
  font-size: 12px;
  font-weight: 700;
  color: var(--parchment-hi);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cat-badge {
  font-size: 9px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  border: 1px solid var(--border);
  white-space: nowrap;
}

.cat-badge.human {
  background: rgba(250, 224, 148, 0.16);
  border-color: var(--brass);
  color: var(--brass-hi);
}

.cat-badge.agent {
  background: rgba(126, 196, 245, 0.16);
  border-color: var(--agent);
  color: var(--agent);
}

.cat-badge.agent_asl {
  background: rgba(94, 230, 181, 0.16);
  border-color: var(--asl);
  color: var(--asl);
}

.lb-meta {
  font-size: 10.5px;
  color: var(--muted);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

.lb-meta b {
  color: var(--parchment-hi);
}

.lb-empty {
  text-align: center;
  padding: 18px 10px;
  font-size: 11.5px;
  color: var(--muted);
}

/* ==========================================================================
   REPLAY CINEMA TAB
   ========================================================================== */
.replay-meta-box {
  background: var(--inset-bg);
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  padding: 8px 9px;
  font-size: 11.5px;
  line-height: 1.45;
}

.replay-meta-box b {
  color: var(--brass-hi);
}

.view-toggle-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
}

.replay-log {
  max-height: 220px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 10.5px;
}

.replay-log-item {
  display: flex;
  gap: 6px;
  padding: 4px 7px;
  border-radius: 4px;
  background: var(--inset-bg);
  border: 1px solid transparent;
  color: var(--muted);
  cursor: pointer;
}

.replay-log-item:hover {
  border-color: var(--border-soft);
  color: var(--parchment);
}

.replay-log-item.active {
  border-color: var(--brass-hi);
  background: linear-gradient(90deg, rgba(196, 36, 48, 0.28) 0%, rgba(212, 163, 70, 0.14) 100%);
  color: var(--parchment-hi);
}

.replay-log-item .st {
  color: var(--brass-hi);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  min-width: 24px;
}

/* ==========================================================================
   MCP & ASL TAB
   ========================================================================== */
.code-box {
  background: #06110e;
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  padding: 8px 9px;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 10.5px;
  line-height: 1.45;
  color: #dff5ec;
  white-space: pre-wrap;
  word-break: break-all;
  user-select: text;
}

.endpoint-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.endpoint-row .code-box {
  flex: 1 1 auto;
  padding: 5px 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tool-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 11px;
}

.tool-item {
  background: var(--inset-bg);
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  padding: 6px 8px;
}

.tool-item code {
  color: var(--asl);
  font-family: ui-monospace, Consolas, monospace;
  font-size: 11px;
  font-weight: 700;
}

.tool-item p {
  margin: 3px 0 0 0;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.35;
}

/* ==========================================================================
   LIVE SPECTATOR MODE ("🔴 Titta Live")
   ========================================================================== */
@keyframes livePulse {
  0%,
  100% {
    opacity: 1;
    box-shadow: 0 0 0 0 rgba(255, 92, 92, 0.78), 0 0 8px rgba(255, 92, 92, 0.92);
  }
  50% {
    opacity: 0.72;
    box-shadow: 0 0 0 4px rgba(255, 92, 92, 0), 0 0 4px rgba(255, 92, 92, 0.45);
  }
}

.live-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #ff5952;
  flex: 0 0 7px;
  animation: livePulse 1.5s ease-in-out infinite;
}

button.btn.btn-live-top {
  display: none;
  background: linear-gradient(180deg, #df3642 0%, #9b1a25 100%);
  border-color: #ffd396;
  color: #fffaf0;
  font-weight: 700;
  max-width: 270px;
  padding: 4px 10px;
  border-radius: 999px;
  gap: 6px;
  box-shadow: 0 0 12px rgba(255, 89, 82, 0.42);
}

button.btn.btn-live-top.visible {
  display: inline-flex;
}

button.btn.btn-live-top:hover {
  background: linear-gradient(180deg, #ef434f 0%, #b0202d 100%);
  border-color: var(--brass-hi);
}

.live-top-txt {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mode-pill.live {
  border-color: #ff8e84;
  color: #fff6e8;
  background: linear-gradient(180deg, rgba(188, 34, 44, 0.94) 0%, rgba(108, 18, 26, 0.96) 100%);
  box-shadow: 0 0 14px rgba(236, 68, 62, 0.45);
}

.live-card {
  display: none;
  background: linear-gradient(180deg, rgba(168, 30, 42, 0.34) 0%, rgba(12, 31, 26, 0.96) 100%);
  border-color: rgba(242, 108, 96, 0.65);
  border-left: 3px solid #f25c54;
}

.live-card.open {
  display: block;
}

.live-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #ffc5ba;
}

.live-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.live-entry {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 7px;
  background: rgba(8, 22, 18, 0.86);
  border: 1px solid rgba(242, 108, 96, 0.38);
  border-radius: 6px;
  padding: 6px 8px;
}

.live-entry.watching {
  border-color: var(--brass-hi);
  background: rgba(74, 24, 30, 0.62);
}

button.btn.btn-live-watch,
button.btn.btn-live-jump {
  background: linear-gradient(180deg, #d8313d 0%, #9b1c26 100%);
  border-color: #f68c88;
  color: #fffaf0;
  font-weight: 700;
}

button.btn.btn-live-watch:hover,
button.btn.btn-live-jump:hover {
  background: linear-gradient(180deg, #eb3f4b 0%, #b0222e 100%);
  border-color: var(--brass-hi);
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: #081512;
}

::-webkit-scrollbar-thumb {
  background: #224a3d;
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--brass);
}

/* Responsive adjustments for 1280x800 and narrower screens */
@media (max-width: 1320px) {
  .app {
    grid-template-columns: minmax(0, 1fr) 334px;
  }
  .hotkey-hint {
    display: none;
  }
  .brand h1 {
    font-size: 13.5px;
  }
  .brand .seed-pill {
    display: none;
  }
  button.btn.btn-live-top {
    max-width: 205px;
  }
}

@media (max-width: 960px) {
  html,
  body {
    overflow: auto;
  }
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: 50px auto auto;
    height: auto;
    min-height: 100vh;
  }
  .stage-wrap {
    aspect-ratio: 16 / 9;
    flex: none;
  }
  aside.sidebar {
    border-left: none;
    border-top: 1px solid var(--border);
  }
}
