/* SAO Tebak Lagu Stacia Window design system (DESIGN.md) */

:root {
  --bg-canvas: #090714;
  --bg-window: rgba(20, 15, 40, 0.9);
  --bg-panel: rgba(26, 19, 51, 0.88);
  --bg-tile: rgba(38, 25, 72, 0.78);
  --bg-tile-hover: rgba(58, 36, 108, 0.88);

  --accent-magenta: #d946ef;
  --accent-magenta-hi: #e879f9;
  --accent-magenta-soft: rgba(217, 70, 239, 0.22);
  --accent-indigo: #6366f1;
  --accent-indigo-hi: #818cf8;
  --accent-indigo-soft: rgba(99, 102, 241, 0.24);

  --text-primary: #ffffff;
  --text-secondary: #c4b5fd;
  --text-muted: #a5b4fc;

  --status-ready: #34d399;
  --status-warn: #fbbf24;
  --status-danger: #fb7185;

  --border-subtle: rgba(165, 175, 255, 0.62);
  --border-strong: rgba(232, 121, 249, 0.78);
  --glow-magenta: 0 0 18px rgba(217, 70, 239, 0.35);
  --glow-indigo: 0 0 14px rgba(99, 102, 241, 0.28);

  --font-hud: "Rajdhani", "Segoe UI", system-ui, sans-serif;
  --font-body: "Plus Jakarta Sans", "Noto Sans JP", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace;

  --chamfer-lg: polygon(16px 0, calc(100% - 16px) 0, 100% 16px, 100% calc(100% - 16px), calc(100% - 16px) 100%, 16px 100%, 0 calc(100% - 16px), 0 16px);
  --chamfer-md: polygon(10px 0, calc(100% - 10px) 0, 100% 10px, 100% calc(100% - 10px), calc(100% - 10px) 100%, 10px 100%, 0 calc(100% - 10px), 0 10px);
  --chamfer-md-inner: polygon(9.4px 0, calc(100% - 9.4px) 0, 100% 9.4px, 100% calc(100% - 9.4px), calc(100% - 9.4px) 100%, 9.4px 100%, 0 calc(100% - 9.4px), 0 9.4px);
  --chamfer-sm: polygon(7px 0, calc(100% - 7px) 0, 100% 7px, 100% calc(100% - 7px), calc(100% - 7px) 100%, 7px 100%, 0 calc(100% - 7px), 0 7px);
  --chamfer-sm-inner: polygon(6.4px 0, calc(100% - 6.4px) 0, 100% 6.4px, 100% calc(100% - 6.4px), calc(100% - 6.4px) 100%, 6.4px 100%, 0 calc(100% - 6.4px), 0 6.4px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background-color: var(--bg-canvas);
  background-image:
    radial-gradient(circle at 18% 12%, rgba(99, 102, 241, 0.18), transparent 46%),
    radial-gradient(circle at 84% 86%, rgba(217, 70, 239, 0.16), transparent 48%);
  color: var(--text-primary);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

:focus-visible {
  outline: 2px solid var(--accent-magenta-hi);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Main Stacia window shell */

.stacia-shell {
  max-width: 1220px;
  margin: 0 auto;
  padding: 12px;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.stacia-window {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-window);
  border: 1.5px solid var(--border-subtle);
  box-shadow: inset 0 0 0 1px rgba(217, 70, 239, 0.16);
  padding: 16px;
}

/* Iconic white Stacia corner brackets */
.stacia-window::before,
.stacia-window::after {
  content: "";
  position: absolute;
  top: -2px;
  width: 28px;
  height: 28px;
  pointer-events: none;
}

.stacia-window::before {
  left: -2px;
  border-top: 3px solid var(--text-primary);
  border-left: 3px solid var(--text-primary);
}

.stacia-window::after {
  right: -2px;
  border-top: 3px solid var(--text-primary);
  border-right: 3px solid var(--text-primary);
}

/* Top HUD header */

.hud-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 14px;
}

.hud-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.hud-community-logo {
  height: 34px;
  width: auto;
  max-width: 132px;
  object-fit: contain;
  flex-shrink: 0;
  display: block;
}

.hud-brand-copy {
  min-width: 0;
}

.hud-title {
  margin: 0;
  font-family: var(--font-hud);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1.1;
}

.hud-subtitle {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

.hud-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.hud-btn-fullscreen.is-active {
  border-color: var(--accent-magenta-hi);
  background: var(--accent-magenta-soft);
  color: var(--text-primary);
}

.unit-type-badge {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-family: var(--font-hud);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--border-strong);
  border: none;
  color: var(--text-primary);
  clip-path: var(--chamfer-sm);
  isolation: isolate;
}

.unit-type-badge::before {
  content: "";
  position: absolute;
  inset: 1.5px;
  background: linear-gradient(90deg, #3c1758, #221d52);
  clip-path: var(--chamfer-sm-inner);
  z-index: -1;
  pointer-events: none;
}

.hud-tab-group {
  display: inline-flex;
  background: rgba(12, 9, 26, 0.85);
  border: 1px solid var(--border-subtle);
  padding: 3px;
  gap: 4px;
}

.hud-tab-btn,
.hud-btn {
  min-height: 48px;
  padding: 8px 14px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-tile);
  color: var(--text-secondary);
  font-family: var(--font-hud);
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.hud-tab-btn {
  border-color: transparent;
  background: transparent;
}

.hud-tab-btn.is-active {
  background: linear-gradient(90deg, rgba(217, 70, 239, 0.34), rgba(99, 102, 241, 0.34));
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.hud-btn:hover,
.hud-tab-btn:hover {
  background: var(--bg-tile-hover);
  color: var(--text-primary);
}

.hud-btn-offline {
  border-color: rgba(251, 191, 36, 0.65);
  color: var(--status-warn);
}

.hud-btn-offline.is-ready {
  border-color: rgba(52, 211, 153, 0.65);
  color: var(--status-ready);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

/* Offline readiness alert banner */

.offline-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  margin-bottom: 14px;
  background: rgba(251, 191, 36, 0.1);
  border: 1px solid rgba(251, 191, 36, 0.55);
  color: #fef3c7;
  font-size: 0.88rem;
}

.offline-banner strong {
  color: var(--status-warn);
}

/* Booth Player two-column Stacia grid */

.player-grid {
  display: grid;
  grid-template-columns: minmax(290px, 0.92fr) minmax(340px, 1.38fr);
  gap: 16px;
  align-items: start;
}

/* Left Inspection Panel (UNIT ID + Visualizer + Answer Card) */
.stacia-inspect-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 14px;
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  box-shadow: inset 0 2px 0 rgba(217, 70, 239, 0.6), inset 0 -2px 0 rgba(217, 70, 239, 0.5);
}

.unit-id-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  background: linear-gradient(90deg, rgba(217, 70, 239, 0.28), rgba(99, 102, 241, 0.18));
  border-bottom: 1px solid var(--border-strong);
}

.unit-id-label {
  font-family: var(--font-hud);
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  color: var(--text-secondary);
  text-transform: uppercase;
}

.unit-id-code {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
}

.deck-counter {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--text-secondary);
  background: rgba(9, 7, 20, 0.7);
  border: 1px solid var(--border-subtle);
  padding: 4px 8px;
}

.visualizer-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 170px;
  padding: 8px;
  background: radial-gradient(circle at center, rgba(99, 102, 241, 0.18), rgba(9, 7, 20, 0.65) 72%);
  border: 1px solid rgba(99, 102, 241, 0.28);
}

.visualizer-hit-btn {
  width: 100%;
  padding: 4px;
  background: transparent;
  border: 1px solid transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 140ms ease, border-color 140ms ease, transform 100ms ease;
}

.visualizer-hit-btn:hover:not(:disabled) {
  background: rgba(217, 70, 239, 0.09);
  border-color: rgba(232, 121, 249, 0.4);
}

.visualizer-hit-btn:active:not(:disabled) {
  transform: scale(0.985);
}

.visualizer-hit-btn:disabled {
  cursor: default;
  opacity: 0.7;
}

.visualizer-canvas {
  width: 100%;
  max-width: 260px;
  height: 150px;
  display: block;
  pointer-events: none;
}

.visualizer-readout {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-top: 6px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-muted);
}

.audio-source-pill {
  font-family: var(--font-hud);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 2px 7px;
  border: 1px solid var(--border-subtle);
  color: var(--status-ready);
}

/* Visualizer Seek / Progress Bar */
.visualizer-seek-wrap {
  width: 100%;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(129, 140, 248, 0.24);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.seek-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.seek-time {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--text-secondary);
  min-width: 42px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.stacia-seek-slider {
  --seek-pct: 0%;
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 44px;
  background: transparent;
  cursor: pointer;
  margin: 0;
}

.stacia-seek-slider:disabled {
  cursor: default;
  opacity: 0.72;
}

.stacia-seek-slider::-webkit-slider-runnable-track {
  height: 8px;
  background: linear-gradient(
    90deg,
    var(--accent-magenta) 0%,
    var(--accent-indigo-hi) var(--seek-pct),
    rgba(99, 102, 241, 0.24) var(--seek-pct),
    rgba(99, 102, 241, 0.24) 100%
  );
  border: 1px solid rgba(129, 140, 248, 0.55);
}

.stacia-seek-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 22px;
  margin-top: -8px;
  background: var(--text-primary);
  border: 2px solid var(--accent-magenta-hi);
  clip-path: polygon(4px 0, calc(100% - 4px) 0, 100% 4px, 100% calc(100% - 4px), calc(100% - 4px) 100%, 4px 100%, 0 calc(100% - 4px), 0 4px);
}

.stacia-seek-slider:disabled::-webkit-slider-thumb {
  width: 10px;
  height: 16px;
  margin-top: -5px;
  background: var(--accent-indigo-hi);
  border-color: var(--text-primary);
  box-shadow: none;
}

.stacia-seek-slider::-moz-range-track {
  height: 8px;
  background: rgba(99, 102, 241, 0.24);
  border: 1px solid rgba(129, 140, 248, 0.55);
}

.stacia-seek-slider::-moz-range-progress {
  height: 8px;
  background: linear-gradient(90deg, var(--accent-magenta), var(--accent-indigo-hi));
}

.stacia-seek-slider::-moz-range-thumb {
  width: 18px;
  height: 22px;
  background: var(--text-primary);
  border: 2px solid var(--accent-magenta-hi);
  border-radius: 0;
}

.seek-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.3;
}

.visualizer-seek-wrap.is-freeplay .seek-hint {
  color: var(--accent-magenta-hi);
}

/* Anti-Spoiler Answer Card */
.answer-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  background: rgba(11, 8, 26, 0.85);
  border: 1px solid var(--border-subtle);
}

.answer-card.is-revealed {
  border-color: var(--border-strong);
}

.answer-masked {
  text-align: center;
  padding: 14px 8px;
}

.answer-masked-code {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  color: var(--accent-indigo-hi);
  margin-bottom: 6px;
}

.answer-masked-hint {
  font-size: 0.86rem;
  color: var(--text-secondary);
}

.answer-title-slot {
  min-height: 54px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.answer-title {
  margin: 0;
  font-size: 1.28rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.25;
}

.answer-title-jp {
  font-size: 0.92rem;
  color: var(--accent-magenta-hi);
  margin-top: 2px;
}

.answer-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.answer-meta strong {
  color: var(--text-primary);
}

.answer-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
}

.meta-chip {
  font-family: var(--font-hud);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 3px 8px;
  background: var(--accent-indigo-soft);
  border: 1px solid var(--accent-indigo);
  color: var(--text-primary);
}

.meta-chip-magenta {
  background: var(--accent-magenta-soft);
  border-color: var(--accent-magenta);
}

/* Right panel cue rows and thumb controls */

.stacia-control-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.cue-rows {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cue-row-btn {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 10px;
  width: 100%;
  min-height: 68px;
  padding: 0;
  background: transparent;
  border: none;
  text-align: left;
}

.cue-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 6px;
  background: var(--accent-indigo);
  border: none;
  clip-path: var(--chamfer-sm);
  isolation: isolate;
  transition: background 160ms ease;
}

.cue-tile::before {
  content: "";
  position: absolute;
  inset: 1.5px;
  background: linear-gradient(180deg, #2d2469, #1d153c);
  clip-path: var(--chamfer-sm-inner);
  z-index: -1;
  pointer-events: none;
  transition: background 160ms ease;
}

.cue-tile-code {
  position: relative;
  z-index: 1;
  font-family: var(--font-hud);
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1;
  color: var(--text-primary);
}

.cue-tile-time {
  position: relative;
  z-index: 1;
  margin-top: 3px;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--text-secondary);
}

.cue-bar {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(217, 70, 239, 0.56);
  border: none;
  clip-path: var(--chamfer-md);
  isolation: isolate;
  transition: background 160ms ease, transform 120ms ease;
}

.cue-bar::before {
  content: "";
  position: absolute;
  inset: 1.5px;
  background: linear-gradient(90deg, #261647, #161030);
  clip-path: var(--chamfer-md-inner);
  z-index: 0;
  pointer-events: none;
  transition: background 160ms ease;
}

.cue-bar-progress {
  position: absolute;
  inset: 1.5px auto 1.5px 1.5px;
  width: 0%;
  background: linear-gradient(90deg, rgba(217, 70, 239, 0.48), rgba(232, 121, 249, 0.28));
  pointer-events: none;
  z-index: 1;
  transition: width 80ms linear;
}

.cue-bar-content {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cue-bar-title {
  font-family: var(--font-hud);
  font-size: 1.18rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-primary);
}

.cue-bar-sub {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.cue-bar-badge {
  position: relative;
  z-index: 2;
  font-family: var(--font-hud);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 4px 8px;
  border: 1px solid var(--border-subtle);
  background: rgba(9, 7, 20, 0.7);
  color: var(--text-secondary);
  white-space: nowrap;
}

/* Active & Playing states on Stacia Row */
.cue-row-btn.is-selected {
  filter: drop-shadow(0 0 8px rgba(217, 70, 239, 0.4));
}

.cue-row-btn.is-selected .cue-tile {
  background: var(--accent-magenta-hi);
}

.cue-row-btn.is-selected .cue-tile::before {
  background: linear-gradient(180deg, #6b217e, #332775);
}

.cue-row-btn.is-selected .cue-bar {
  background: var(--accent-magenta-hi);
}

.cue-row-btn.is-selected .cue-bar::before {
  background: linear-gradient(90deg, #4b1863, #24164a);
}

.cue-row-btn.is-unset .cue-tile {
  background: rgba(251, 191, 36, 0.65);
}

.cue-row-btn.is-unset .cue-tile-time {
  color: var(--status-warn);
}

.cue-row-btn.is-unset .cue-bar {
  background: rgba(251, 191, 36, 0.55);
  opacity: 0.88;
}

.cue-row-btn.is-unset .cue-bar-badge {
  border-color: rgba(251, 191, 36, 0.65);
  color: var(--status-warn);
}

.cue-row-btn:hover .cue-bar {
  background: var(--accent-magenta-hi);
}

.cue-row-btn:active .cue-bar {
  transform: scale(0.992);
}

/* Error / Notice Strip */
.status-alert {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  font-size: 0.88rem;
  border: 1px solid rgba(251, 113, 133, 0.65);
  background: rgba(251, 113, 133, 0.14);
  color: #ffe4e6;
}

.status-alert.is-warn {
  border-color: rgba(251, 191, 36, 0.65);
  background: rgba(251, 191, 36, 0.12);
  color: #fef3c7;
}

/* Primary action buttons */

.primary-controls {
  display: grid;
  grid-template-columns: 1.35fr 1fr 0.85fr;
  gap: 10px;
}

.action-btn {
  position: relative;
  min-height: 54px;
  padding: 10px 14px;
  border: none;
  background: var(--border-subtle);
  color: var(--text-primary);
  font-family: var(--font-hud);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  clip-path: var(--chamfer-sm);
  isolation: isolate;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 150ms ease, transform 100ms ease, filter 150ms ease;
}

.action-btn::before {
  content: "";
  position: absolute;
  inset: 1.5px;
  background: #211740;
  clip-path: var(--chamfer-sm-inner);
  z-index: -1;
  pointer-events: none;
  transition: background 150ms ease;
}

.action-btn:hover:not(:disabled)::before {
  background: #30205c;
}

.action-btn:active {
  transform: scale(0.985);
}

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

.action-btn-play {
  background: var(--accent-magenta-hi);
  filter: drop-shadow(0 0 8px rgba(217, 70, 239, 0.35));
}

.action-btn-play::before {
  background: linear-gradient(90deg, #9d1fa8, #4642a8);
}

.action-btn-play:hover:not(:disabled)::before {
  background: linear-gradient(90deg, #b524c2, #524ec2);
}

.action-btn-play.is-playing {
  background: var(--status-danger);
  filter: drop-shadow(0 0 8px rgba(251, 113, 133, 0.4));
}

.action-btn-play.is-playing::before {
  background: linear-gradient(90deg, #9f1239, #831843);
}

.action-btn-next {
  background: var(--accent-indigo-hi);
}

.action-btn-next::before {
  background: linear-gradient(90deg, #2f2c73, #1e153f);
}

.action-btn-reveal {
  width: 100%;
  min-height: 48px;
  background: var(--border-strong);
}

.action-btn-reveal::before {
  background: linear-gradient(90deg, #431a5f, #272366);
}

.action-btn-secondary {
  min-height: 48px;
  font-size: 0.88rem;
}

.action-btn-freeplay {
  min-height: 54px;
  font-size: 0.92rem;
  background: var(--border-subtle);
}

.action-btn-freeplay.is-active {
  background: var(--accent-magenta-hi);
  filter: drop-shadow(0 0 8px rgba(217, 70, 239, 0.38));
  color: var(--text-primary);
}

.action-btn-freeplay.is-active::before {
  background: linear-gradient(90deg, #5c1c75, #312978);
}

/* Playback Parameters Strip (Duration, Fade, Volume, Wake Lock) */
.settings-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 12px;
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
}

.setting-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.setting-label {
  font-family: var(--font-hud);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

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

.chip-btn {
  min-height: 48px;
  padding: 8px 12px;
  border: 1px solid var(--border-subtle);
  background: rgba(9, 7, 20, 0.75);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.84rem;
  font-weight: 600;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
}

.chip-btn.is-active {
  background: var(--accent-magenta-soft);
  border-color: var(--accent-magenta-hi);
  color: var(--text-primary);
}

.volume-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.volume-slider {
  flex: 1;
  accent-color: var(--accent-magenta);
  height: 48px;
}

/* Recent History Strip (Collapsible, Default Hidden) */
.history-panel {
  padding: 0;
  background: rgba(11, 8, 26, 0.72);
  border: 1px solid var(--border-subtle);
}

.history-toggle-btn {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  background: transparent;
  border: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  text-align: left;
}

.history-toggle-btn:hover {
  background: rgba(58, 36, 108, 0.35);
}

.history-toggle-indicator {
  font-family: var(--font-hud);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent-magenta-hi);
}

.history-list {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 0 12px 10px;
}

.history-item {
  flex: 0 0 auto;
  min-height: 48px;
  padding: 8px 12px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-tile);
  color: var(--text-secondary);
  font-size: 0.84rem;
  white-space: nowrap;
}

.history-item.is-current {
  border-color: var(--accent-magenta-hi);
  color: var(--text-primary);
}

/* Empty and exhausted deck state */

.empty-state {
  text-align: center;
  padding: 28px 16px;
  background: var(--bg-panel);
  border: 1px dashed var(--border-strong);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.empty-state h2 {
  margin: 0;
  font-family: var(--font-hud);
  font-size: 1.3rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.empty-state p {
  margin: 0;
  color: var(--text-secondary);
  max-width: 440px;
  font-size: 0.92rem;
}

/* Slide-over drawer for pool filter and offline audio manager */

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 3, 12, 0.72);
  z-index: 40;
  display: flex;
  justify-content: flex-end;
}

.drawer-backdrop[hidden] {
  display: none;
}

.drawer-panel {
  width: min(480px, 100vw);
  height: 100%;
  background: #100c24;
  border-left: 2px solid var(--border-strong);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(20, 15, 40, 0.95);
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.text-input {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  background: rgba(9, 7, 20, 0.9);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  font-size: 0.94rem;
}

.text-input::placeholder {
  color: rgba(196, 181, 253, 0.78);
}

.song-pick-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.song-pick-row {
  width: 100%;
  min-height: 52px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  text-align: left;
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
}

.song-pick-row:hover {
  border-color: var(--accent-magenta-hi);
  background: var(--bg-tile-hover);
}

.song-pick-row.is-active {
  border-color: var(--accent-magenta-hi);
  background: rgba(58, 36, 108, 0.78);
}

.song-pick-title {
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--text-primary);
}

.song-pick-sub {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.offline-card {
  padding: 14px;
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.progress-track {
  width: 100%;
  height: 12px;
  background: rgba(9, 7, 20, 0.85);
  border: 1px solid var(--border-subtle);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-indigo), var(--accent-magenta));
  width: 0%;
  transition: width 180ms ease;
}

/* Cue Point Editor view */

.editor-grid {
  display: grid;
  grid-template-columns: minmax(260px, 0.85fr) minmax(360px, 1.45fr);
  gap: 16px;
  align-items: start;
}

.editor-list-pane {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 74dvh;
}

.editor-song-scroll {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-right: 4px;
}

.editor-main-pane {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
}

.waveform-box {
  position: relative;
  width: 100%;
  background: rgba(9, 7, 20, 0.9);
  border: 1px solid var(--border-subtle);
  padding: 8px;
}

.waveform-canvas {
  width: 100%;
  height: 130px;
  display: block;
  cursor: pointer;
}

.editor-cue-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.editor-cue-card {
  padding: 10px;
  background: rgba(11, 8, 26, 0.82);
  border: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.editor-cue-card.is-filled {
  border-color: rgba(52, 211, 153, 0.55);
}

.file-input-label:focus-within {
  outline: 2px solid var(--accent-magenta-hi);
  outline-offset: 2px;
}

.editor-cue-actions {
  display: flex;
  gap: 6px;
}

.editor-cue-actions .hud-btn {
  flex: 1;
  min-height: 48px;
  font-size: 0.8rem;
  padding: 6px 8px;
}

/* Music Player view */

.music-grid {
  display: grid;
  grid-template-columns: minmax(290px, 0.92fr) minmax(340px, 1.38fr);
  gap: 16px;
  align-items: start;
}

.music-transport-controls {
  display: grid;
  grid-template-columns: 0.85fr 1.3fr 0.85fr;
  gap: 8px;
}

.music-toggle-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.music-toggle-row .chip-btn {
  padding: 6px 6px;
  font-size: 0.76rem;
  text-align: center;
}

.music-track-head {
  min-height: 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.music-cover-stage {
  position: relative;
  width: min(230px, 100%);
  aspect-ratio: 1 / 1;
  margin: 4px auto;
  overflow: hidden;
  background: #120d26;
  border: 1.5px solid var(--border-strong);
}

.music-cover-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.music-cover-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-hud);
  font-size: 0.82rem;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  background: radial-gradient(circle at center, rgba(99, 102, 241, 0.25), #120d26 75%);
}

.music-cover-fallback[hidden],
.music-cover-img[hidden],
.music-cover-visualizer[hidden] {
  display: none;
}

.music-cover-fallback-icon {
  width: 56px;
  height: 56px;
  opacity: 0.8;
}

.music-cover-visualizer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}

.floating-toast {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  max-width: min(440px, calc(100vw - 24px));
  padding: 10px 16px;
  background: rgba(20, 15, 40, 0.95);
  border: 1.5px solid var(--accent-magenta-hi);
  color: var(--text-primary);
  font-family: var(--font-hud);
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-align: center;
  pointer-events: none;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

.floating-toast[hidden] {
  display: none;
}

.music-library-pane {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
}

.music-list-scroll {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 58dvh;
  overflow-y: auto;
  padding-right: 4px;
}

.music-browse-row {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 8px;
  background: rgba(11, 8, 26, 0.85);
  border: 1px solid var(--border-subtle);
}

.music-browse-row.is-active {
  border-color: var(--accent-magenta-hi);
  background: rgba(58, 36, 108, 0.65);
}

.music-row-main {
  flex: 1;
  min-width: 0;
  min-height: 52px;
  padding: 8px 12px;
  background: transparent;
  border: none;
  text-align: left;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
}

.music-row-main:hover {
  background: rgba(58, 36, 108, 0.4);
}

.music-row-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 8px 6px 0;
  flex-shrink: 0;
}

.music-q-btn {
  min-height: 48px;
  padding: 6px 10px;
  font-size: 0.78rem;
}

.music-src-tag {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  padding: 0 4px;
}

.music-src-tag.is-offline {
  color: var(--status-ready);
}

/* Community footer credit */

.stacia-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 8px 12px;
  border-top: 1px solid rgba(165, 175, 255, 0.32);
  color: var(--text-secondary);
  font-size: 0.8rem;
  text-align: center;
}

.footer-logo {
  height: 18px;
  width: auto;
  object-fit: contain;
  display: block;
}

.footer-credit strong {
  color: var(--text-primary);
}

/* Responsive breakpoints: phone portrait (< 600px) and tablet portrait (600px - 899px) */

@media (max-width: 899px) {
  .stacia-shell {
    padding: 6px;
  }

  .stacia-window {
    padding: 12px;
  }

  .stacia-window::before,
  .stacia-window::after {
    width: 20px;
    height: 20px;
  }

  .hud-header {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding-bottom: 10px;
    margin-bottom: 10px;
  }

  .hud-brand {
    justify-content: flex-start;
    gap: 10px;
  }

  .hud-community-logo {
    height: 28px;
    max-width: 102px;
  }

  .hud-title {
    font-size: 1.06rem;
  }

  .hud-subtitle {
    font-size: 0.68rem;
  }

  .hud-actions {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 6px;
    width: 100%;
  }

  .hud-tab-group {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    width: 100%;
  }

  .hud-tab-btn,
  .hud-btn {
    padding: 8px 8px;
    font-size: 0.82rem;
  }

  #btn-open-pool {
    width: 100%;
  }

  .unit-type-badge {
    display: none;
  }

  .offline-banner {
    padding: 8px 10px;
    margin-bottom: 10px;
    font-size: 0.8rem;
    gap: 8px;
  }

  .offline-banner .hud-btn {
    width: 100%;
  }

  .player-grid,
  .music-grid,
  .editor-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .music-library-pane {
    padding: 10px;
  }

  .music-list-scroll {
    max-height: 46dvh;
  }

  .stacia-inspect-panel {
    padding: 10px;
    gap: 10px;
  }

  .unit-id-bar {
    padding: 6px 8px;
  }

  .visualizer-stage {
    min-height: 0;
    padding: 8px 8px 6px;
  }

  .visualizer-canvas {
    height: 82px;
    max-width: 220px;
  }

  .visualizer-seek-wrap {
    margin-top: 6px;
    padding-top: 6px;
  }

  .answer-card {
    padding: 10px;
    gap: 8px;
  }

  .answer-masked {
    padding: 6px 4px;
  }

  .answer-masked-code {
    font-size: 0.74rem;
    margin-bottom: 2px;
  }

  .answer-masked-hint {
    font-size: 0.8rem;
  }

  .answer-title {
    font-size: 1.12rem;
  }

  /* Compact 2-row 2-column Cue Grid on Mobile Portrait ONLY (Tablet/Desktop untouched) */
  .cue-rows {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .cue-row-btn {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    gap: 4px;
    min-height: 76px;
  }

  .cue-row-btn:nth-child(3) {
    grid-column: 1 / -1;
    grid-template-columns: 76px 1fr;
    grid-template-rows: 1fr;
    gap: 8px;
    min-height: 58px;
  }

  .cue-tile {
    flex-direction: row;
    justify-content: space-between;
    padding: 5px 10px;
  }

  .cue-row-btn:nth-child(3) .cue-tile {
    flex-direction: column;
    justify-content: center;
    padding: 6px 4px;
  }

  .cue-tile-code {
    font-size: 0.95rem;
  }

  .cue-tile-time {
    margin-top: 0;
    font-size: 0.72rem;
  }

  .cue-bar {
    padding: 8px 10px;
    gap: 6px;
  }

  .cue-bar-title {
    font-size: 0.96rem;
  }

  .cue-bar-sub {
    display: none;
  }

  .cue-bar-badge {
    font-size: 0.66rem;
    padding: 3px 6px;
  }

  .primary-controls {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .primary-controls .action-btn-play {
    grid-column: 1 / -1;
    min-height: 54px;
  }

  .primary-controls .action-btn-next,
  .primary-controls .action-btn-freeplay {
    min-height: 50px;
    font-size: 0.88rem;
    padding: 8px 10px;
  }

  .settings-strip {
    grid-template-columns: 1fr;
    padding: 10px;
    gap: 10px;
  }

  .settings-strip .chip-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(56px, 1fr));
    gap: 6px;
  }

  .settings-strip .chip-btn {
    padding: 6px 6px;
    text-align: center;
  }

  .editor-cue-grid {
    grid-template-columns: 1fr;
  }

  .editor-list-pane {
    max-height: 36dvh;
  }
}

@media (min-width: 600px) and (max-width: 899px) {
  .stacia-shell {
    padding: 10px;
  }

  .stacia-window {
    padding: 14px;
  }

  .hud-actions {
    grid-template-columns: minmax(240px, 1fr) auto auto;
  }

  .hud-tab-group {
    grid-column: auto;
  }

  #btn-open-pool {
    width: auto;
  }

  #view-player .stacia-inspect-panel {
    display: grid;
    grid-template-columns: 1.05fr 0.95fr;
    gap: 12px;
    align-items: stretch;
  }

  #view-player .unit-id-bar {
    grid-column: 1 / -1;
  }

  .primary-controls {
    grid-template-columns: 1.3fr 1fr 0.9fr;
  }

  .primary-controls .action-btn-play {
    grid-column: auto;
  }

  .settings-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 430px) {
  .stacia-shell {
    padding: 4px;
  }

  .stacia-window {
    padding: 10px;
  }

  .seek-hint {
    font-size: 0.68rem;
  }
}
