:root {
  --primary: #ff0055;
  --secondary: #00f0ff;
  --accent: #ffe600;
  --bg: #000000;
  --surface: rgba(10, 14, 24, 0.75);
  --surface-border: rgba(255, 255, 255, 0.15);
  --text: #ffffff;
  
  /* Authentic Karaoke Lyric Colors */
  --sung-color: #00d2ff;
  --unsung-color: #ffffff;
  --stroke-color: #003b46;
}

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

/* iOS Safari cannot type into inputs that have user-select: none */
input, textarea {
  user-select: text;
  -webkit-user-select: text;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overflow: hidden !important;
  height: 100%;
}

button {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  font-family: inherit;
}

/* Uniform Heroicons SVG utility */
.h-ic {
  display: inline-block;
  width: 1.18em;
  height: 1.18em;
  vertical-align: -0.18em;
  fill: currentColor;
  flex-shrink: 0;
}

/* Universal scrollbar removal - eliminates visible scrollbars & prevents black bar gaps */
*::-webkit-scrollbar {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
}
* {
  scrollbar-width: none !important;
  -ms-overflow-style: none !important;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  height: 100vh;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden !important;
  overscroll-behavior: none !important;
  touch-action: none;
}

/* Full-Bleed Fixed Video Background (Always fills 100% of screen without exposing black borders) */
#bg-video {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  min-width: 100%;
  min-height: 100%;
  object-fit: cover;
  z-index: 0;
  filter: brightness(0.7) contrast(1.15) saturate(1.1);
  transition: opacity 0.5s ease;
  pointer-events: none;
}

.vignette {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  background: radial-gradient(circle at center, transparent 40%, rgba(0, 0, 0, 0.6) 100%),
              linear-gradient(to bottom, rgba(0,0,0,0.45) 0%, transparent 20%, transparent 65%, rgba(0,0,0,0.85) 100%);
  z-index: 1;
  pointer-events: none;
}

/* UI Layout - Anchored inside viewport boundary */
.app-container {
  position: fixed;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  height: 100vh;
  height: 100dvh;
  max-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 24px 44px;
  overflow: hidden !important;
  touch-action: manipulation;
}

/* Header */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* Famous Brand Identity: Crown Emblem Icon above Brand Name */
.brand-identity {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  user-select: none;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.brand-identity:hover {
  transform: scale(1.04);
}

.brand-logo-wrap {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: radial-gradient(circle at center, rgba(255, 0, 85, 0.4) 0%, rgba(10, 14, 24, 0.85) 100%);
  border: 1.5px solid rgba(255, 0, 85, 0.55);
  box-shadow: 0 4px 18px rgba(255, 0, 85, 0.45), inset 0 0 10px rgba(255, 0, 85, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3px;
  transition: all 0.25s ease;
}

.brand-identity:hover .brand-logo-wrap {
  border-color: var(--secondary);
  box-shadow: 0 4px 22px rgba(0, 240, 255, 0.6), inset 0 0 12px rgba(0, 240, 255, 0.35);
}

.brand-logo-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 9px;
  display: block;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.8));
}

.brand-title {
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-weight: 900;
  font-size: 13px;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: #ffffff;
  margin-top: 4px;
  line-height: 1;
  text-shadow: 0 0 12px rgba(255, 0, 85, 0.8), 0 2px 4px rgba(0, 0, 0, 0.95);
  white-space: nowrap;
}

.logo-badge {
  display: none;
}

.audio-btn {
  background: rgba(255, 0, 85, 0.25);
  border: 1px solid var(--primary);
  color: #fff;
  padding: 8px 18px;
  border-radius: 30px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  backdrop-filter: blur(8px);
  transition: all 0.2s;
}

/* Informative Audio Status Pill */
.audio-status-pill {
  background: rgba(46, 125, 50, 0.25);
  border: 1px solid rgba(129, 199, 132, 0.4);
  color: #81c784;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
  pointer-events: none;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #81c784;
  box-shadow: 0 0 10px #81c784;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}

/* Classic CRT Videoke Reserved OSD (Full width, larger text, below header) */
.reserved-osd {
  position: absolute;
  top: 76px;
  left: 44px;
  right: 44px;
  display: none;
  align-items: baseline;
  gap: 24px;
  font-family: 'Outfit', -apple-system, sans-serif;
  font-weight: 900;
  font-size: clamp(28px, 2.8vw, 44px);
  color: #ffffff;
  letter-spacing: 1.5px;
  text-shadow: 2.5px 2.5px 0px #000, -2.5px -2.5px 0px #000, 2.5px -2.5px 0px #000, -2.5px 2.5px 0px #000, 0px 4px 12px rgba(0,0,0,0.95);
  pointer-events: none;
  z-index: 10;
  white-space: nowrap;
  overflow: hidden;
  width: calc(100vw - 88px);
}

.reserved-osd .reserved-count {
  color: #ffffff;
  font-weight: 900;
  margin-right: 12px;
  flex-shrink: 0;
}

.reserved-osd .reserved-list {
  display: inline-flex;
  align-items: baseline;
  gap: 28px;
  color: #ffffff;
  font-weight: 800;
  overflow: hidden;
  white-space: nowrap;
  flex-grow: 1;
}

.reserved-osd .r-song-num {
  display: inline-block;
  flex-shrink: 0;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.remote-link {
  background: var(--surface);
  backdrop-filter: blur(14px);
  border: 1px solid var(--surface-border);
  padding: 8px 18px;
  border-radius: 30px;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.75);
}
.remote-link b {
  color: var(--accent);
}

.header-btn {
  background: var(--surface);
  border: 1px solid var(--surface-border);
  color: #fff;
  padding: 8px 14px;
  border-radius: 30px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  backdrop-filter: blur(14px);
  transition: all 0.2s;
}
.header-btn:hover {
  background: rgba(255,255,255,0.2);
}

/* Top Floating Song Info Banner */
.song-banner {
  display: none;
  position: absolute;
  top: 136px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.22);
  padding: 8px 32px;
  border-radius: 40px;
  text-align: center;
  z-index: 5;
  box-shadow: 0 8px 30px rgba(0,0,0,0.65);
  animation: bannerSlideDown 0.3s ease-out;
}

@keyframes bannerSlideDown {
  from { opacity: 0; transform: translate(-50%, -15px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.song-banner h1 {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: #fff;
}

.song-banner h2 {
  font-size: 15px;
  color: var(--secondary);
  font-weight: 600;
  margin-top: 1px;
}

/* Up Next Song Banner (Shown 15s before song ends for 5s) */
.up-next-banner {
  display: none;
  position: absolute;
  top: 136px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, rgba(233, 30, 99, 0.95), rgba(156, 39, 176, 0.95));
  border: 2px solid rgba(255, 255, 255, 0.45);
  padding: 10px 32px;
  border-radius: 40px;
  align-items: center;
  gap: 14px;
  z-index: 25;
  box-shadow: 0 10px 40px rgba(233, 30, 99, 0.75);
  animation: popBounce 0.35s ease-out;
  pointer-events: none;
}

.up-next-badge {
  background: #ffffff;
  color: #c2185b;
  font-weight: 900;
  font-size: 13px;
  padding: 4px 12px;
  border-radius: 20px;
  letter-spacing: 1px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}

.up-next-title {
  font-size: 20px;
  font-weight: 800;
  color: #ffffff;
  text-shadow: 0 2px 8px rgba(0,0,0,0.6);
  white-space: nowrap;
}

@keyframes popBounce {
  0% { opacity: 0; transform: translate(-50%, -20px) scale(0.9); }
  70% { opacity: 1; transform: translate(-50%, 4px) scale(1.03); }
  100% { opacity: 1; transform: translate(-50%, 0) scale(1); }
}

/* ==========================================================
   AUTHENTIC 2-LINE KARAOKE STAGE (LOWERED TO BOTTOM CENTER)
   ========================================================== */
.karaoke-stage {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end; /* Lower lyrics towards bottom */
  align-items: center;
  padding: 0 40px 24px 40px;
  position: relative;
  overflow: hidden;
}

/* [ 0 ] [ 1 ] [ 2 ] [ 3 ] Beat Countdown Box */
.countdown-box {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 16px;
}

.count-card {
  width: 46px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
  font-weight: 900;
  color: #ffffff;
  border: 3.5px solid #000000;
  border-radius: 8px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.8);
  opacity: 1;
  visibility: visible;
  transform: scale(1);
  transition: opacity 0.1s ease-out, transform 0.1s ease-out, visibility 0.1s;
}

.count-card.box-0 { background: #df7a1d; } /* Amber / Orange */
.count-card.box-1 { background: #16a085; } /* Teal / Cyan */
.count-card.box-2 { background: #27ae60; } /* Green */
.count-card.box-3 { background: #962d22; } /* Dark Red */

/* Disappeared Card in 3 -> 2 -> 1 -> 0 sequence (no pulse) */
.count-card.hidden {
  opacity: 0;
  visibility: hidden;
  transform: scale(0.8);
  pointer-events: none;
}

.karaoke-lines-container {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  max-width: 1800px;
  justify-content: center;
  align-items: center;
  text-align: center;
  margin-bottom: 24px;
  position: relative;
  z-index: 1000; /* Ensure lyrics are ALWAYS in front of any search popups */
  pointer-events: none;
  overflow: visible;
}

/* Distinct Top and Bottom Karaoke Lines - Strictly 2 Lines, Never Wrap */
.karaoke-line {
  font-size: clamp(32px, 4.4vw, 76px);
  font-weight: 900;
  letter-spacing: 0.8px;
  line-height: 1.2;
  min-height: 1.25em;
  text-align: center;
  white-space: nowrap !important;
  word-break: keep-all !important;
  word-wrap: normal !important;
  overflow: visible;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 100%;
  transition: opacity 0.25s ease-out;
}

.k-line-inner {
  display: inline-block;
  white-space: nowrap !important;
  word-break: keep-all !important;
  word-wrap: normal !important;
  text-align: center;
  transform-origin: center center;
  will-change: transform;
  max-width: 100%;
}

/* ==========================================================
   OUTER-ONLY OUTLINE (NO INNER LINES)
   Uses `paint-order: stroke fill;` so stroke is strictly behind
   the solid fill, completely eliminating internal contour lines.
   ========================================================== */
.k-syllable {
  display: inline-block;
  position: relative;
  white-space: pre !important;
  color: var(--unsung-color);
  -webkit-text-stroke: var(--stroke-w, 7px) var(--stroke-color);
  paint-order: stroke fill;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.9));
  transition: color 0.08s ease-out;
}

/* Sung Syllable: Solid Cyan/Blue Fill with crisp outer contour */
.k-syllable.sung {
  color: var(--sung-color);
  -webkit-text-stroke: var(--stroke-w, 7px) #002b36;
  paint-order: stroke fill;
  filter: drop-shadow(0 0 16px rgba(0, 210, 255, 0.85)) drop-shadow(0 4px 8px rgba(0,0,0,0.9));
}

/* Actively Singing Right Now */
.k-syllable.active {
  color: #ffff00;
  -webkit-text-stroke: var(--stroke-w, 7px) #4a3500;
  paint-order: stroke fill;
  filter: drop-shadow(0 0 20px rgba(255, 255, 0, 0.95)) drop-shadow(0 4px 8px rgba(0,0,0,0.9));
  transform: scale(1.04);
}

/* Idle / Waiting state placeholder (centered) */
.karaoke-idle-box {
  position: absolute;
  top: 45%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.karaoke-idle-title {
  font-size: 56px;
  font-weight: 900;
  color: #ffffff;
  -webkit-text-stroke: var(--stroke-w-title, 6px) #003b46;
  paint-order: stroke fill;
  filter: drop-shadow(0 0 20px rgba(0, 240, 255, 0.8));
  letter-spacing: 1.5px;
}

.karaoke-idle-sub {
  font-size: 24px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.85);
  text-shadow: 0 2px 10px rgba(0,0,0,0.9);
}

/* Bottom Control Bar */
.controls-panel {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
}

.btn-search-trigger {
  background: var(--surface);
  backdrop-filter: blur(18px);
  border: 1px solid var(--surface-border);
  color: #fff;
  padding: 13px 22px;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 4px 18px rgba(0,0,0,0.4);
  transition: all 0.2s;
}

.btn-search-trigger:hover {
  background: var(--primary);
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(255, 0, 85, 0.4);
}

/* Search Pop-up Modal (Clean Floating Card, No Blur Backdrop) */
.search-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  background: transparent !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  pointer-events: none;
  z-index: 200;
  display: none;
  justify-content: center;
  align-items: flex-start;
  padding-top: 60px;
}

/* Modal card positioned towards the top with solid dark background */
.search-modal-card {
  pointer-events: auto;
  width: 90%;
  max-width: 680px;
  max-height: 52vh;
  background: #0d111a;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 20px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.95);
  display: flex;
  flex-direction: column;
  padding: 20px;
  gap: 14px;
  animation: modalSlideDown 0.2s ease-out;
}

@keyframes modalSlideDown {
  from { opacity: 0; transform: translateY(-20px); }
  to { opacity: 1; transform: translateY(0); }
}

.search-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.search-modal-title {
  font-size: 18px;
  font-weight: 800;
  color: #fff;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.search-modal-close {
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  line-height: 1;
  padding: 6px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.search-modal-close .h-ic {
  width: 22px;
  height: 22px;
}

.search-modal-close:hover {
  color: #ff0055;
  background: rgba(255,255,255,0.1);
}

.search-input-wrapper {
  position: relative;
}

.search-input-wrapper input {
  width: 100%;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 12px;
  padding: 12px 16px;
  color: #fff;
  font-size: 16px;
  font-family: inherit;
  outline: none;
  transition: border 0.2s;
}

.search-input-wrapper input:focus {
  border-color: var(--secondary);
}

.search-results-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 4px;
  max-height: 320px;
}

.search-empty-hint {
  text-align: center;
  padding: 28px;
  font-size: 14px;
  color: rgba(255,255,255,0.6);
}

/* Song row: Song Code Badge separate from Title */
.song-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.song-row:hover {
  background: rgba(255, 0, 85, 0.22);
  border-color: rgba(255, 0, 85, 0.4);
}

.song-code {
  min-width: 58px;
  padding: 6px 8px;
  text-align: center;
  border-radius: 8px;
  background: rgba(0, 240, 255, 0.15);
  color: var(--secondary);
  font-weight: 900;
  font-size: 14px;
  font-family: monospace;
  letter-spacing: 0.5px;
  border: 1px solid rgba(0, 240, 255, 0.3);
}

.song-info {
  flex: 1;
  min-width: 0;
}

.song-row-title {
  font-weight: 700;
  font-size: 15px;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.song-row-artist {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.65);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.song-row-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}

.song-row-btn:hover {
  background: #ff3377;
}

/* Actions & Volume on Bottom Right */
.actions-card {
  display: flex;
  align-items: center;
  gap: 12px;
}

.volume-box {
  background: var(--surface);
  backdrop-filter: blur(18px);
  border: 1px solid var(--surface-border);
  padding: 12px 18px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 600;
}

.volume-box input[type=range] {
  width: 90px;
  accent-color: var(--secondary);
  cursor: pointer;
}

.sync-box {
  background: var(--surface);
  backdrop-filter: blur(18px);
  border: 1px solid var(--surface-border);
  padding: 10px 14px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
}

.sync-btn {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

.sync-btn:hover {
  background: var(--secondary);
  border-color: var(--secondary);
  color: #000;
}

#sync-display {
  font-family: monospace;
  font-size: 12px;
  min-width: 54px;
  text-align: center;
  color: var(--secondary);
}

.btn {
  background: var(--surface);
  backdrop-filter: blur(18px);
  border: 1px solid var(--surface-border);
  color: #fff;
  padding: 13px 20px;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}

.btn:hover {
  transform: translateY(-2px);
  border-color: rgba(255,255,255,0.4);
}

.btn-play {
  background: linear-gradient(135deg, #2e7d32, #1b5e20);
  border-color: #388e3c;
}

.btn-pause {
  background: linear-gradient(135deg, #f57c00, #e65100);
  border-color: #fb8c00;
}

.btn-stop {
  background: linear-gradient(135deg, #c2185b, #880e4f);
  border-color: #d81b60;
}

.btn-skip {
  background: linear-gradient(135deg, #0288d1, #01579b);
  border-color: #03a9f4;
}

/* Unmute overlay banner if audioContext suspended */
#audio-gate {
  position: fixed;
  top: 76px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 0, 85, 0.95);
  color: #fff;
  padding: 12px 28px;
  border-radius: 30px;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.5px;
  z-index: 100;
  box-shadow: 0 8px 30px rgba(255, 0, 85, 0.6);
  cursor: pointer;
  animation: bounce 1.6s infinite ease-in-out;
  display: none;
}

@keyframes bounce {
  0%, 100% { transform: translate(-50%, 0); }
  50% { transform: translate(-50%, -8px); }
}

/* ==========================================================
   MICROPHONE & VOCAL EFFECTS CONTROLS & MODAL
   ========================================================== */
.btn-mic {
  background: var(--surface);
  backdrop-filter: blur(18px);
  border: 1px solid var(--surface-border);
  color: #fff;
  padding: 11px 16px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
  box-shadow: 0 4px 18px rgba(0,0,0,0.3);
}

.btn-mic:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
  border-color: rgba(255,255,255,0.4);
}

.btn-mic.active {
  background: linear-gradient(135deg, rgba(46, 125, 50, 0.8), rgba(27, 94, 32, 0.9));
  border-color: #81c784;
  box-shadow: 0 4px 20px rgba(76, 175, 80, 0.4);
}

.mic-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #757575;
  display: inline-block;
  transition: all 0.2s;
}

.mic-status-dot.active {
  background: #00e676;
  box-shadow: 0 0 10px #00e676;
  animation: pulse 1.5s infinite;
}

/* Mic Modal Card */
.mic-modal-card {
  max-width: 640px !important;
  max-height: 85vh !important;
  overflow-y: auto;
}

.mic-modal-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.mic-warning-tip {
  background: rgba(255, 152, 0, 0.12);
  border: 1px solid rgba(255, 152, 0, 0.35);
  color: #ffb74d;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.4;
  display: flex;
  align-items: center;
  gap: 8px;
}

.mic-warning-tip .tip-ic {
  width: 1.35em;
  height: 1.35em;
  flex-shrink: 0;
  color: #ffa726;
}

.mic-power-box {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.mic-toggle-btn {
  background: linear-gradient(135deg, #2e7d32, #1b5e20);
  border: 1px solid #388e3c;
  color: #ffffff;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  transition: all 0.2s;
}

.mic-toggle-btn:hover {
  filter: brightness(1.15);
  transform: translateY(-1px);
}

.mic-toggle-btn.active {
  background: linear-gradient(135deg, #d32f2f, #b71c1c);
  border-color: #f44336;
}

.mic-vu-container {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
}

.mic-vu-label {
  font-size: 12px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.7);
  letter-spacing: 0.5px;
}

.mic-vu-track {
  flex: 1;
  height: 14px;
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 7px;
  overflow: hidden;
  position: relative;
}

.mic-vu-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(to right, #00e676 0%, #ffeb3b 75%, #ff5252 100%);
  border-radius: 7px;
  transition: width 0.05s ease-out;
}

.mic-sliders-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

@media (max-width: 600px) {
  .mic-sliders-grid {
    grid-template-columns: 1fr;
  }
}

.mic-slider-item {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mic-slider-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.mic-slider-header label {
  font-size: 13px;
  font-weight: 700;
  color: #ffffff;
}

.mic-val-badge {
  font-family: monospace;
  font-size: 12px;
  font-weight: 700;
  color: var(--secondary);
  background: rgba(0, 240, 255, 0.12);
  padding: 2px 8px;
  border-radius: 6px;
  border: 1px solid rgba(0, 240, 255, 0.25);
}

.mic-slider-item input[type=range] {
  width: 100%;
  accent-color: var(--secondary);
  cursor: pointer;
  margin-top: 2px;
}

.mic-modal-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.mic-footer-btn {
  padding: 9px 18px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.15s;
}

.mic-footer-btn.reset {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.85);
}

.mic-footer-btn.reset:hover {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}

.mic-footer-btn.close {
  background: var(--primary);
  border: none;
  color: #fff;
}

.mic-footer-btn.close:hover {
  background: #ff3377;
}

/* ==========================================================
   DYNAMIC REMOTE LINK, QR CODE & SINGLE-HOST LOCK
   ========================================================== */
.remote-link {
  background: var(--surface);
  backdrop-filter: blur(14px);
  border: 1px solid var(--surface-border);
  padding: 6px 14px;
  border-radius: 30px;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.85);
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.remote-link:hover {
  background: rgba(255, 255, 255, 0.18);
  border-color: var(--secondary);
  transform: translateY(-1px);
}

.remote-qr-thumb {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: #ffffff;
  padding: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.remote-qr-thumb img {
  width: 100%;
  height: 100%;
  display: block;
}

.remote-link-btn-label {
  font-weight: 700;
  font-size: 13px;
  color: #ffffff;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.qr-wifi-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 240, 255, 0.12);
  border: 1px solid rgba(0, 240, 255, 0.35);
  padding: 6px 14px;
  border-radius: 20px;
  margin: 4px auto 10px;
  font-size: 13px;
}

.qr-wifi-label {
  color: rgba(255, 255, 255, 0.85);
  font-weight: 700;
}

.qr-wifi-code {
  color: var(--accent);
  font-family: monospace;
  font-size: 14px;
  letter-spacing: 0.8px;
}

.remote-link-text {
  display: none;
}

/* Large QR Code Modal */
.qr-modal-card {
  max-width: 440px !important;
  text-align: center;
  align-items: center;
  padding: 24px !important;
}

.qr-code-box {
  background: #ffffff;
  padding: 14px;
  border-radius: 16px;
  display: inline-flex;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6);
  margin: 10px auto;
}

.qr-code-box img {
  width: 210px;
  height: 210px;
  display: block;
}

.qr-url-text {
  font-family: monospace;
  font-size: 14px;
  font-weight: 700;
  color: var(--secondary);
  background: rgba(0, 240, 255, 0.1);
  border: 1px solid rgba(0, 240, 255, 0.25);
  padding: 8px 14px;
  border-radius: 10px;
  word-break: break-all;
  user-select: all;
  margin: 6px 0 12px;
  width: 100%;
}

/* Idle Screen QR Prompt */
.idle-qr-prompt {
  display: flex;
  align-items: center;
  gap: 16px;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 10px 20px;
  border-radius: 20px;
  margin-top: 14px;
  cursor: pointer;
  transition: transform 0.2s, border-color 0.2s;
}

.idle-qr-prompt:hover {
  transform: scale(1.03);
  border-color: var(--secondary);
}

.idle-qr-img {
  width: 60px;
  height: 60px;
  background: #fff;
  border-radius: 8px;
  padding: 3px;
  display: block;
  flex-shrink: 0;
}

.idle-qr-text {
  text-align: left;
}

.idle-qr-text h4 {
  font-size: 16px;
  font-weight: 800;
  color: #fff;
}

.idle-qr-text p {
  font-size: 13px;
  color: var(--secondary);
  margin-top: 2px;
  font-weight: 600;
}

/* Single-Host Lock Barrier Overlay */
.host-lock-overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 9, 16, 0.96);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
}

.host-lock-card {
  max-width: 520px;
  background: #0e131f;
  border: 2px solid rgba(255, 0, 85, 0.5);
  border-radius: 24px;
  padding: 32px 28px;
  box-shadow: 0 20px 60px rgba(255, 0, 85, 0.25);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.host-lock-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}

.host-lock-icon .h-ic {
  width: 56px;
  height: 56px;
  color: var(--secondary);
}

.host-lock-title {
  font-size: 22px;
  font-weight: 900;
  color: #fff;
}

.host-lock-desc {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.75);
  line-height: 1.5;
}

.host-lock-actions {
  display: flex;
  gap: 12px;
  margin-top: 8px;
  width: 100%;
}

.host-lock-btn {
  flex: 1;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}

.host-lock-btn.primary {
  background: var(--primary);
  color: #fff;
}

.host-lock-btn.primary:hover {
  background: #ff3377;
}

.host-lock-btn.secondary {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.host-lock-btn.secondary:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ==========================================================
   TOAST + IMMERSIVE (fullscreen fallback) HELPERS
   ========================================================== */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(20px);
  background: rgba(0, 0, 0, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  padding: 12px 18px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  z-index: 20000;
  width: max-content;
  max-width: 90vw;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

body.immersive .remote-link,
body.immersive .audio-status-pill {
  display: none;
}

/* ==========================================================
   MOBILE / TABLET RESPONSIVE LAYOUT
   Applies to narrow screens (portrait phones / tablets) AND
   short screens (phones held in landscape).
   ========================================================== */
@media (max-width: 900px), (max-height: 520px) {
  :root {
    --stroke-w: 4px;
    --stroke-w-title: 4px;
    --safe-top: max(10px, env(safe-area-inset-top));
    --hdr-h: 46px;
  }

  .app-container {
    padding: var(--safe-top)
             max(12px, env(safe-area-inset-right))
             max(10px, env(safe-area-inset-bottom))
             max(12px, env(safe-area-inset-left));
  }

  /* ---- Header ---- */
  header {
    flex-wrap: nowrap;
    gap: 8px;
    min-height: var(--hdr-h);
  }
  .brand { gap: 8px; min-width: 0; }
  .brand-logo-wrap {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    padding: 2px;
  }
  .brand-title {
    font-size: 9px;
    letter-spacing: 1.2px;
    margin-top: 2px;
  }
  .logo-badge { display: none; }
  .audio-status-pill { display: none; }
  .header-right { gap: 6px; flex-shrink: 0; }
  .remote-link { padding: 5px; gap: 0; }
  .remote-link-text { display: none; }
  .remote-qr-thumb { width: 30px; height: 30px; }
  .header-btn {
    padding: 8px 12px;
    font-size: 13px;
    min-height: 40px;
    white-space: nowrap;
  }

  /* ---- On-screen banners ---- */
  .reserved-osd {
    top: calc(var(--safe-top) + var(--hdr-h));
    left: max(12px, env(safe-area-inset-left));
    right: max(12px, env(safe-area-inset-right));
    width: auto;
    font-size: clamp(16px, 4.6vw, 28px);
    gap: 10px;
    letter-spacing: 0.5px;
    text-shadow: 1.5px 1.5px 0 #000, -1.5px -1.5px 0 #000, 1.5px -1.5px 0 #000, -1.5px 1.5px 0 #000, 0 2px 6px rgba(0,0,0,0.95);
  }
  .reserved-osd .reserved-count { margin-right: 4px; }
  .reserved-osd .reserved-list { gap: 14px; }

  .song-banner,
  .up-next-banner {
    top: calc(var(--safe-top) + var(--hdr-h) + 40px);
    max-width: 94vw;
  }
  .song-banner { padding: 6px 18px; border-radius: 22px; }
  .song-banner h1 {
    font-size: 16px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .song-banner h2 {
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .up-next-banner { padding: 7px 14px; gap: 8px; border-radius: 22px; }
  .up-next-badge { font-size: 10px; padding: 3px 8px; white-space: nowrap; }
  .up-next-title {
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 62vw;
  }

  #audio-gate {
    top: calc(var(--safe-top) + var(--hdr-h) + 8px);
    width: max-content;
    max-width: 92vw;
    padding: 10px 16px;
    font-size: 13px;
    text-align: center;
    line-height: 1.3;
  }

  /* ---- Lyric stage ---- */
  .karaoke-stage {
    padding: 0 4px 6px;
    min-height: 0;
    overflow: hidden;
  }
  .countdown-box { gap: 5px; margin-bottom: 6px; }
  .count-card {
    width: 34px;
    height: 40px;
    font-size: 24px;
    border-width: 2.5px;
    border-radius: 6px;
  }
  .karaoke-lines-container {
    gap: 6px;
    margin-bottom: 6px;
    width: 100%;
  }
  .karaoke-line {
    font-size: clamp(20px, 5.8vw, 38px);
    min-height: 1.25em;
    letter-spacing: 0.3px;
    white-space: nowrap !important;
    word-break: keep-all !important;
    word-wrap: normal !important;
  }
  /* lighter glow = smoother on phones */
  .k-syllable { filter: drop-shadow(0 2px 4px rgba(0,0,0,0.9)); }
  .k-syllable.sung {
    filter: drop-shadow(0 0 8px rgba(0, 210, 255, 0.8)) drop-shadow(0 2px 4px rgba(0,0,0,0.9));
  }
  .k-syllable.active {
    filter: drop-shadow(0 0 10px rgba(255, 255, 0, 0.9)) drop-shadow(0 2px 4px rgba(0,0,0,0.9));
  }

  .karaoke-idle-box { top: 42%; padding: 0 12px; gap: 8px; }
  .karaoke-idle-title { font-size: clamp(30px, 9vw, 52px); }
  .karaoke-idle-sub { font-size: clamp(14px, 3.4vw, 20px); }
  .idle-qr-prompt {
    padding: 8px 14px;
    gap: 12px;
    margin-top: 8px;
    max-width: 92vw;
  }
  .idle-qr-img { width: 52px; height: 52px; }
  .idle-qr-text h4 { font-size: 14px; }
  .idle-qr-text p { font-size: 11px; word-break: break-all; }

  /* ---- Bottom controls ---- */
  .controls-panel {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .btn-search-trigger {
    width: 100%;
    justify-content: center;
    padding: 11px 14px;
    font-size: 14px;
    min-height: 44px;
  }
  .actions-card {
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
  }
  .actions-card .btn {
    flex: 1 1 22%;
    min-width: 0;
    justify-content: center;
    padding: 11px 6px;
    font-size: 13px;
    min-height: 44px;
    gap: 4px;
    white-space: nowrap;
  }
  .btn-mic {
    flex: 1 1 auto;
    justify-content: center;
    min-height: 44px;
    padding: 10px 12px;
  }
  .sync-box {
    flex: 1 1 auto;
    justify-content: center;
    padding: 6px 10px;
  }
  .sync-btn { padding: 8px 10px; font-size: 12px; min-height: 36px; }
  .volume-box { flex: 1 1 100%; padding: 8px 14px; }
  .volume-box input[type=range] { flex: 1; width: auto; }

  /* ---- Modals ---- */
  .search-modal-backdrop { padding-top: max(8px, env(safe-area-inset-top)); }
  .search-modal-card {
    width: 96%;
    max-height: 48vh;
    max-height: 48dvh;
    padding: 14px;
    border-radius: 16px;
    gap: 10px;
  }
  .search-results-list { max-height: none; }
  .search-modal-title { font-size: 15px; }
  .song-row { padding: 8px 10px; gap: 8px; }
  .song-code { min-width: 50px; font-size: 12px; }
  .song-row-btn { padding: 8px 12px; }
  .mic-modal-card {
    max-height: 92vh !important;
    max-height: 92dvh !important;
  }
  .mic-power-box { flex-wrap: wrap; gap: 10px; padding: 12px; }
  .mic-vu-container { flex: 1 1 100%; }
  .qr-modal-card { padding: 16px !important; }
  .qr-code-box img {
    width: min(210px, 60vw);
    height: min(210px, 60vw);
  }
  .host-lock-card { padding: 22px 18px; }
  .host-lock-title { font-size: 19px; }
  .host-lock-actions { flex-direction: column; }
}

/* Very narrow phones: icon-only header buttons */
@media (max-width: 480px) {
  .btn-label { display: none; }
  .header-btn { padding: 8px 12px; font-size: 16px; }
  .brand-logo-wrap { width: 26px; height: 26px; border-radius: 7px; }
  .brand-title { font-size: 8px; letter-spacing: 1px; margin-top: 2px; }
}

/* Phones held sideways (short screens): compact everything */
@media (max-height: 520px) and (orientation: landscape) {
  :root {
    --stroke-w: 3px;
    --stroke-w-title: 3px;
    --safe-top: max(6px, env(safe-area-inset-top));
    --hdr-h: 40px;
  }
  .app-container { padding-bottom: max(6px, env(safe-area-inset-bottom)); }
  .brand-identity { flex-direction: row; gap: 6px; }
  .brand-logo-wrap { width: 26px; height: 26px; border-radius: 7px; padding: 2px; }
  .brand-title { font-size: 11px; margin-top: 0; letter-spacing: 1.5px; }
  .logo-badge { display: none; }
  .header-btn { min-height: 34px; padding: 6px 12px; font-size: 12px; }
  .remote-qr-thumb { width: 26px; height: 26px; }
  .reserved-osd { font-size: clamp(14px, 4vh, 22px); }
  .song-banner,
  .up-next-banner { top: calc(var(--safe-top) + var(--hdr-h) + 32px); }
  .karaoke-line {
    font-size: clamp(16px, 7vh, 32px);
    min-height: 1.15em;
    white-space: nowrap !important;
    word-break: keep-all !important;
    word-wrap: normal !important;
  }
  .karaoke-lines-container { gap: 3px; margin-bottom: 3px; }
  .karaoke-idle-box { top: 40%; }
  .karaoke-idle-sub { display: none; }
  .idle-qr-prompt { margin-top: 2px; }
  .controls-panel {
    flex-direction: row;
    align-items: center;
    gap: 6px;
  }
  .btn-search-trigger {
    width: auto;
    flex-shrink: 0;
    min-height: 36px;
    padding: 6px 10px;
    font-size: 12px;
  }
  .actions-card {
    flex: 1;
    justify-content: flex-end;
    gap: 6px;
  }
  .actions-card .btn {
    flex: 0 0 auto;
    min-height: 36px;
    padding: 6px 10px;
    font-size: 12px;
  }
  .btn-mic { min-height: 36px; padding: 6px 10px; font-size: 12px; flex: 0 0 auto; }
  .sync-box { flex: 0 0 auto; padding: 4px 8px; }
  .sync-btn { min-height: 28px; padding: 4px 8px; }
  .volume-box { flex: 0 1 auto; padding: 4px 10px; }
  .volume-box input[type=range] { width: 70px; flex: none; }
  .search-modal-card { max-height: 80vh; max-height: 80dvh; }
}

/* Touch devices: no sticky hover lift */
@media (hover: none) {
  .btn:hover,
  .btn-search-trigger:hover,
  .btn-mic:hover,
  .remote-link:hover,
  .idle-qr-prompt:hover,
  .mic-toggle-btn:hover {
    transform: none;
  }
}


