:root {
  --bg-deep: #090b10;
  --bg-surface: #0f131d;
  --bg-card: rgba(18, 23, 36, 0.85);
  --coral-accent: #f95738;
  --coral-glow: rgba(249, 87, 56, 0.4);
  --neon-green: #10b981;
  --neon-gold: #f59e0b;
  --text-main: #f8fafc;
  --text-muted: #828fa3;
  --border-subtle: rgba(255, 255, 255, 0.07);
}

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

html, body {
  background-color: var(--bg-deep);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  height: 100vh;
  width: 100vw;
  max-width: 100vw;
  overflow: hidden !important;
  display: flex;
  flex-direction: column;
}

.focusable {
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  cursor: pointer;
  position: relative;
}
.focusable.focused {
  outline: 2px solid var(--coral-accent) !important;
  outline-offset: 2px;
  box-shadow: 0 0 16px var(--coral-glow) !important;
  border-color: var(--coral-accent) !important;
  z-index: 10;
}

header {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: rgba(12, 15, 23, 0.98);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
  gap: 12px;
  z-index: 50;
}

.brand-section { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.brand-logo-img { height: 36px; width: auto; object-fit: contain; }
.brand-name { font-size: 18px; font-weight: 900; letter-spacing: 1px; color: #fff; }

.room-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap !important;
}
.room-badge .dot { color: var(--neon-green); font-size: 8px; }
.room-badge b { color: #fff; font-weight: 700; }

.header-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.nav-tabs { display: flex; gap: 6px; }
.nav-tab {
  background: transparent;
  border: 1px solid transparent;
  padding: 6px 14px;
  border-radius: 20px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.nav-tab.active {
  background: rgba(249, 87, 56, 0.15);
  border-color: rgba(249, 87, 56, 0.4);
  color: #fff;
}
.nav-tab .tab-icon { display: none; font-size: 14px; }

.btn-hamburger {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  color: #fff;
  width: 34px;
  height: 34px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  cursor: pointer;
}

main {
  flex: 1;
  position: relative;
  overflow: hidden;
  padding: 10px 16px;
  max-width: 100vw !important;
}

.view {
  position: absolute;
  inset: 10px 16px;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  overflow-y: auto;
  overflow-x: hidden !important;
  transition: opacity 0.15s ease;
  z-index: 1;
  max-width: calc(100vw - 32px);
}
.view.active {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
  z-index: 10;
  display: flex;
  flex-direction: column;
}

.cinema-layout {
  display: grid;
  grid-template-columns: 1fr clamp(300px, 25vw, 350px);
  gap: 14px;
  height: 100%;
  width: 100%;
  max-width: 100%;
}

.stage-column {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  overflow-x: hidden;
  height: 100%;
  padding-right: 4px;
}

.video-container {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: 56vh;
  background: #000;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  box-shadow: 0 8px 30px rgba(0,0,0,0.8);
  flex-shrink: 0;
}
#ytPlayer { width: 100%; height: 100%; border: none; }

div#videoContainer::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 10;
  background: #0000ff00;
  pointer-events: auto;
}

.stage-action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 8px 14px;
  flex-shrink: 0;
}
.stage-title-wrap {
  flex: 1;
  overflow: hidden;
}
.stage-huge-title {
  font-size: 16px;
  font-weight: 900;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-transform: uppercase;
}
.stage-meta-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}
.stage-meta-row b { color: var(--coral-accent); }
.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid var(--neon-green);
  color: var(--neon-green);
  padding: 2px 6px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 700;
}
.live-badge .dot { font-size: 7px; }

.stage-controls-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.ctrl-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}
.ctrl-btn.play-main {
  background: var(--coral-accent);
  border-color: var(--coral-accent);
  width: 44px;
  height: 36px;
  font-size: 15px;
}

.next-ticker-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 6px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.ticker-left { display: flex; align-items: center; gap: 8px; overflow: hidden; }
.badge-next {
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: var(--neon-gold);
  font-size: 9px;
  font-weight: 900;
  padding: 2px 5px;
  border-radius: 3px;
  letter-spacing: 0.5px;
}
.ticker-title { font-size: 12px; font-weight: 700; color: #fff; }
.ticker-singer { font-size: 11px; color: var(--text-muted); }
.ticker-time { font-size: 11px; color: var(--text-muted); }

.adsterra-horizontal-wrapper {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
  margin-top: 2px;
}
.ad-slot-728 { display: flex; justify-content: center; width: 728px; height: 90px; }
.ad-slot-468 { display: none; justify-content: center; width: 468px; height: 60px; }
.ad-slot-320 { display: none; justify-content: center; width: 320px; height: 50px; }

@media (max-width: 900px) and (min-width: 601px) {
  .ad-slot-728 { display: none !important; }
  .ad-slot-468 { display: flex !important; }
  .ad-slot-320 { display: none !important; }
}

@media (max-width: 600px) {
  .ad-slot-728 { display: none !important; }
  .ad-slot-468 { display: none !important; }
  .ad-slot-320 { display: flex !important; }
  .live-badge { display: none; }
}

.queue-sidebar {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  height: 100%;
  overflow: hidden;
}
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 8px;
  flex-shrink: 0;
}
.sidebar-header h3 { font-size: 12px; font-weight: 800; letter-spacing: 1px; color: #fff; }
.queued-pill {
  background: rgba(16, 185, 129, 0.12);
  color: var(--neon-green);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 8px;
}

.sidebar-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-right: 2px;
}

.sidebar-now-card {
  background: rgba(249, 87, 56, 0.1);
  border: 1px solid var(--coral-accent);
  border-radius: 6px;
  padding: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.sidebar-now-badge {
  background: var(--coral-accent);
  color: #fff;
  font-size: 8px;
  font-weight: 900;
  padding: 2px 4px;
  border-radius: 3px;
}

.sidebar-item {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 6px 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.item-index { font-size: 11px; font-weight: 800; color: var(--coral-accent); width: 16px; }
.item-details { flex: 1; overflow: hidden; }
.item-title { font-size: 12px; font-weight: 700; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-singer { font-size: 10px; color: var(--text-muted); margin-top: 1px; }

.item-remove {
  background: rgba(249, 87, 56, 0.1);
  border: 1px solid rgba(249, 87, 56, 0.35);
  color: var(--coral-accent);
  width: 24px;
  height: 24px;
  border-radius: 4px;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.item-remove.focused {
  background: var(--coral-accent) !important;
  color: #fff !important;
  border-color: #fff !important;
  outline: 2px solid #fff !important;
}

.adsterra-sidebar-wrapper {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
  margin-top: auto;
  padding-top: 4px;
}

.search-bar { display: flex; gap: 8px; margin-bottom: 12px; }
.search-input-box {
  flex: 1;
  font-size: 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  padding: 10px 14px;
  border-radius: 6px;
  color: #fff;
  outline: none;
}
.search-input-box:focus { border-color: var(--coral-accent); }

.osk-grid { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; margin-bottom: 12px; }
.osk-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  padding: 8px 0;
  text-align: center;
  border-radius: 4px;
}

.grid-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px;
  padding: 4px 4px 40px 4px;
  overflow-x: hidden !important;
}

.song-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 8px;
  display: flex;
  gap: 8px;
  align-items: center;
}
.song-thumb {
  width: 68px;
  height: 42px;
  border-radius: 4px;
  object-fit: cover;
  background: #111;
  flex-shrink: 0;
}
.song-details { flex: 1; overflow: hidden; }
.song-title { font-size: 12px; font-weight: 700; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.song-artist { font-size: 10px; color: var(--text-muted); }

.screen-toast {
  position: absolute;
  top: 14px;
  right: 14px;
  background: #0f1422;
  border: 2px solid var(--coral-accent);
  padding: 8px 14px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 2147483647;
  transform: translateX(120%);
  opacity: 0;
  transition: transform 0.3s ease;
  pointer-events: none;
}
.screen-toast.show { transform: translateX(0); opacity: 1; }
.screen-toast .toast-icon { font-size: 16px; color: var(--coral-accent); }
.screen-toast .toast-title { font-size: 12px; font-weight: 800; color: #fff; }
.screen-toast .toast-sub { font-size: 10px; color: var(--neon-gold); }

#toastBox {
  position: fixed;
  top: 65px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: #0f1422;
  border: 2px solid var(--coral-accent);
  color: #fff;
  padding: 8px 18px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 10px 30px rgba(0,0,0,0.8);
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s ease;
  z-index: 500;
}
#toastBox.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.drawer-backdrop.active { opacity: 1; pointer-events: auto; }

.side-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(320px, 85vw);
  background: #0f131d;
  border-left: 1px solid var(--border-subtle);
  z-index: 1001;
  transform: translateX(100%);
  transition: transform 0.2s ease;
  display: flex;
  flex-direction: column;
  padding: 20px;
}
.side-drawer.open { transform: translateX(0); }

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-subtle);
}
.drawer-header h2 { font-size: 16px; font-weight: 800; color: #fff; }
.close-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-subtle);
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.drawer-menu-list { display: flex; flex-direction: column; gap: 8px; }
.drawer-btn {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: #fff;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 700;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}
.modal-overlay.active { display: flex; }
.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  padding: 20px 24px;
  border-radius: 10px;
  width: min(400px, 90vw);
}

.idle-stage-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 25;
  background: #090c14;
}
.idle-guide-card {
  position: relative;
  z-index: 2;
  background: #0f1422;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 18px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
  max-width: 90%;
}
.idle-left-info { display: flex; flex-direction: column; gap: 4px; max-width: 280px; }
.idle-badge-pill {
  align-self: flex-start;
  background: rgba(249, 87, 56, 0.15);
  border: 1px solid var(--coral-accent);
  color: var(--coral-accent);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 1px;
  padding: 2px 6px;
  border-radius: 12px;
}
.idle-title { font-size: 16px; font-weight: 900; color: #fff; }
.idle-steps { font-size: 11px; color: var(--text-muted); line-height: 1.4; }
.idle-steps b { color: #fff; }
.idle-qr-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: #fff;
  padding: 6px;
  border-radius: 8px;
  flex-shrink: 0;
}
#idleQrImg { width: 95px; height: 95px; display: block; }
.idle-qr-tag { font-size: 9px; font-weight: 800; color: #000; }

:fullscreen body { padding: 0; margin: 0; background: #000; }
:fullscreen header { display: none !important; }
:fullscreen main { padding: 0 !important; inset: 0 !important; }
:fullscreen .view { inset: 0 !important; max-width: 100vw !important; }
:fullscreen .cinema-layout { grid-template-columns: 1fr !important; gap: 0 !important; }
:fullscreen .queue-sidebar,
:fullscreen .stage-action-bar,
:fullscreen .next-ticker-card,
:fullscreen .adsterra-horizontal-wrapper { display: none !important; }
:fullscreen .video-container {
  width: 100vw !important;
  height: 100vh !important;
  max-width: 100vw !important;
  max-height: 100vh !important;
  border-radius: 0 !important;
  border: none !important;
}

@media (max-width: 900px) {
  header { height: 50px; padding: 0 12px; }
  .brand-logo-img { height: 26px; }
  .brand-name { display: none !important; }
  .room-badge { font-size: 11px; padding: 3px 8px; }
  .nav-tabs { gap: 4px; }
  .nav-tab { padding: 6px 10px; border-radius: 14px; }
  .nav-tab .tab-text { display: none !important; }
  .nav-tab .tab-icon { display: inline-block !important; }

  .cinema-layout {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow-y: auto;
    gap: 10px;
  }
  .stage-column { overflow: visible; height: auto; padding-right: 0; }
  .video-container { max-height: unset; aspect-ratio: 16 / 9; width: 100%; }
  .queue-sidebar { height: auto; min-height: 250px; }
  .adsterra-sidebar-wrapper { display: none !important; }
  .view { inset: 4px; padding: 4px; max-width: calc(100vw - 8px); }
  main { padding: 4px; }
}

@media (max-height: 650px) and (min-width: 901px) {
  header { height: 50px; }
  .video-container { max-height: 44vh; }
  .adsterra-horizontal-wrapper { max-height: 60px; }
  .adsterra-sidebar-wrapper { min-height: 80px; max-height: 140px; }
  main { padding: 6px 12px; }
}
