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

  :root {
    --gold: #c9a84c;
    --gold-dim: #8a6f2e;
    --bg: #0a0a0c;
    --surface: #111115;
    --surface2: #18181e;
    --surface3: #1f1f27;
    --text: #f0ede8;
    --text-muted: #8a8880;
    --red: #e63946;
    --border: rgba(201,168,76,0.15);
  }

  html, body {
    background: var(--bg);
    color: var(--text);
    font-family: 'DM Sans', sans-serif;
    font-weight: 300;
  }

  /* ── HEADER ── */
  header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(10,10,12,0.92);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    height: 64px;
  }

  .logo-link {
    display: flex;
    align-items: center;
    text-decoration: none;
  }

  #main-logo {
    height: 80px;
    width: auto;
    display: block;
    object-fit: contain;
  }

  .viewers-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--text-muted);
    letter-spacing: 0.05em;
  }

  .live-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--red);
    animation: pulse 2s infinite;
  }

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

  /* ── PLAYER ── */
  .player-wrap {
    position: relative;
    background: #000;
    width: 100%;
  }

  video {
    width: 100%;
    height: 100%;
    display: block;
    background: #000;
  }

  .player-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.45);
    cursor: pointer;
    transition: opacity 0.3s;
  }

  .player-overlay.hidden { opacity: 0; pointer-events: none; }

  .play-btn {
    width: 88px; height: 88px;
    border-radius: 50%;
    background: rgba(10,10,12,0.6);
    border: 3px solid rgba(201,168,76,0.8);
    display: flex; align-items: center; justify-content: center;
    transition: transform 0.25s cubic-bezier(.34,1.56,.64,1), background 0.2s, border-color 0.2s;
    box-shadow: 0 0 40px rgba(201,168,76,0.25), 0 0 0 0 rgba(201,168,76,0);
    animation: play-ring 2.5s ease-in-out infinite;
  }
  @keyframes play-ring {
    0%,100% { box-shadow: 0 0 30px rgba(201,168,76,0.2), 0 0 0 0 rgba(201,168,76,0.15); }
    50%      { box-shadow: 0 0 50px rgba(201,168,76,0.35), 0 0 0 16px rgba(201,168,76,0); }
  }
  .play-btn:hover { background: rgba(201,168,76,0.2); transform: scale(1.12); border-color: var(--gold); }
  .play-btn svg { margin-left: 6px; }

  /* ── MOVIE INFO ── */
  .movie-info {
    padding: 1rem 1rem 2rem;
  }

  .movie-header {
    display: flex;
    align-items: flex-start;
    gap: 1.5rem;
    margin-bottom: 1.25rem;
  }

  .movie-poster {
    width: 90px;
    height: 130px;
    border-radius: 3px;
    object-fit: cover;
    flex-shrink: 0;
    border: 1px solid var(--border);
  }

  .movie-poster-placeholder {
    width: 90px;
    height: 130px;
    border-radius: 3px;
    background: var(--surface2);
    border: 1px solid var(--border);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 0.7rem;
    text-align: center;
    padding: 8px;
  }

  .movie-meta { flex: 1; }

  .movie-title {
    font-family: 'Playfair Display', serif;
    font-size: 1.8rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--text);
    margin-bottom: 0.4rem;
  }

  .movie-subtitle {
    font-size: 0.82rem;
    color: var(--text-muted);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 0.75rem;
  }

  .movie-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 0.75rem;
  }

  .tag {
    font-size: 0.72rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 3px 10px;
    border-radius: 2px;
    border: 1px solid var(--border);
    color: var(--text-muted);
  }

  .rating-row {
    display: flex;
    align-items: center;
    gap: 1rem;
  }

  .csfd-rating {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--gold);
    font-weight: 500;
  }

  .stars {
    font-size: 1rem;
    letter-spacing: 1px;
  }

  .csfd-link {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: color 0.2s, border-color 0.2s;
  }

  .csfd-link:hover { color: var(--gold); border-color: var(--gold-dim); }

  .movie-plot {
    font-size: 0.88rem;
    line-height: 1.8;
    color: rgba(240,237,232,0.65);
    max-width: 680px;
  }

  /* ── CSFD SEARCH ── */
  .csfd-search {
    margin-top: 1rem;
    display: flex;
    gap: 8px;
  }

  .csfd-search input {
    flex: 1;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 8px 12px;
    color: var(--text);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.85rem;
    outline: none;
    transition: border-color 0.2s;
  }

  .csfd-search input:focus { border-color: var(--gold-dim); }
  .csfd-search input::placeholder { color: var(--text-muted); }

  .btn-gold {
    background: transparent;
    border: 1px solid var(--gold-dim);
    color: var(--gold);
    padding: 8px 16px;
    border-radius: 3px;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.8rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    white-space: nowrap;
  }

  .btn-gold:hover { background: rgba(201,168,76,0.12); }

.chat-panel {
  width: var(--chat-width, 340px);
  min-width: 200px;
  max-width: 600px;
  flex-shrink: 0; 
  height: 100%;
  min-height: 0;
  border-left: 1px solid var(--border);
  display: flex; 
  flex-direction: column; 
  overflow: hidden;
  /* Firefox fix */
  contain: strict;
}

  /* chat-header odstránený */

.chat-messages {
  flex: 1 1 0;
  min-height: 0;
  min-width: 0;
  overflow-y: auto;
  overflow-x: hidden;
  /* Firefox fix – obsah nesmie pretekať */
  width: 100%;
}

.chat-messages::-webkit-scrollbar { display: none; }
.chat-messages { scrollbar-width: none; }

.msg {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 2px 4px;
  border-radius: 4px;
  /* Firefox fix – orezaj dlhý obsah */
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  transition: background 0.1s;
  animation: fadeUp 0.2s ease;
  position: relative;
}

.msg:hover { background: rgba(255, 255, 255, 0.05); }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(2px); }
  to { opacity: 1; transform: translateY(0); }
}

.msg-meta {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.msg-author {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.msg-time {
  font-size: 0.7rem;
  color: var(--text-muted);
  opacity: 0.8;
}

.msg-text {
  font-size: 1rem;
  line-height: 1.4;
  color: #efeff1;
  word-break: break-word;
}

.msg-system {
  font-size: 1rem;
  color: var(--text-muted);
  text-align: left;
  font-style: normal;
  padding: 2px 0;
}

.msg-react-btn {
  opacity: 0;
  position: absolute;
  right: 4px;
  top: 2px;
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 4px;
  font-size: 0.7rem;
  height: 18px;
  display: flex;
  align-items: center;
  cursor: pointer;
  color: var(--text-muted);
  transition: opacity 0.15s, background 0.15s;
}

.msg:hover .msg-react-btn { opacity: 1; }

.msg-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.reaction-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0px 5px;
  font-size: 0.7rem;
  cursor: pointer;
  transition: background 0.15s;
}

.reaction-count { font-size: 0.65rem; color: var(--text-muted); }

.emoji-picker {
  display: none; position: absolute; right: 0; top: 24px; z-index: 200;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 6px; padding: 8px; width: 220px;
  max-height: 260px; overflow-y: auto; scrollbar-width: thin;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
}
.emoji-picker.open { display: block; }
.emoji-picker.open-up { top: auto; bottom: 24px; }

.emoji-category {
  font-size: 0.6rem;
  color: var(--text-muted);
  text-transform: uppercase;
  margin: 6px 0 3px;
}

.emoji-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
}

.emoji-btn {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  border-radius: 4px;
  cursor: pointer;
  background: transparent;
  border: none;
  color: inherit;
}
  .emoji-btn:hover { background: var(--surface3); }

  /* Emoji in input button */
  .emoji-toggle-btn {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 2px;
    color: var(--text-muted);
    padding: 0 8px;
    font-size: 1.1rem;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    display: flex; align-items: center;
  }
  .emoji-toggle-btn:hover { background: var(--surface3); border-color: var(--gold-dim); }

  /* Global picker for input */
  #global-emoji-picker {
    display: none;
    position: absolute;
    bottom: 100%;
    right: 0;
    margin-bottom: 6px;
    z-index: 300;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px;
    width: 240px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.6);
    max-height: 260px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--surface3) transparent;
  }
  #global-emoji-picker.open { display: block; }
  .chat-input-area { position: relative; }

  .chat-input-area {
    padding: 0.875rem 1.25rem;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
    overflow: hidden;
  }

  .nickname-row {
    display: flex;
    gap: 6px;
    align-items: center;
    min-width: 0;
    overflow: hidden;
  }

  .nick-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    letter-spacing: 0.06em;
    white-space: nowrap;
  }

  .mention-option {
    padding: 6px 12px;
    font-size: 0.82rem;
    cursor: pointer;
    color: var(--text);
    transition: background 0.1s;
  }
  .mention-option:hover { background: var(--surface3); color: var(--gold); }

  .nick-input {
    flex: 1;
    min-width: 0;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 2px;
    padding: 5px 8px;
    color: var(--gold);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.8rem;
    outline: none;
    overflow: hidden;
  }

  .nick-input:focus { border-color: var(--gold-dim); }

  .msg-row {
    display: flex;
    gap: 6px;
    min-width: 0;
    overflow: hidden;
  }

  .msg-input {
    flex: 1;
    min-width: 0;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 2px;
    padding: 8px 10px;
    color: var(--text);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.85rem;
    outline: none;
    resize: none;
    transition: border-color 0.2s;
  }

  .msg-input:focus { border-color: var(--gold-dim); }
  .msg-input::placeholder { color: var(--text-muted); }

  .send-btn {
    background: transparent;
    border: 1px solid var(--gold-dim);
    color: var(--gold);
    padding: 8px 14px;
    border-radius: 2px;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .send-btn:hover { background: rgba(201,168,76,0.12); }

  /* ── NICK COLOR SWATCH ── */
  .nick-color-swatch {
    width: 22px; height: 22px;
    border-radius: 50%;
    border: 2px solid var(--border);
    cursor: pointer;
    flex-shrink: 0;
    transition: border-color 0.2s, transform 0.15s;
    background: #c9a84c;
  }
  .nick-color-swatch:hover { border-color: var(--gold); transform: scale(1.15); }

  .nick-color-picker {
    display: none;
    position: absolute;
    bottom: calc(100% + 6px);
    left: 0;
    z-index: 400;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.7);
    width: 220px;
  }
  .nick-color-picker.open { display: block; }
  .nick-color-picker-label {
    font-size: 0.68rem;
    color: var(--text-muted);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 6px;
  }
  .color-palette {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-bottom: 8px;
  }
  .color-dot {
    width: 22px; height: 22px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.1s, border-color 0.1s;
  }
  .color-dot:hover { transform: scale(1.2); }
  .color-dot.selected { border-color: white; }
  .color-custom-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
  }
  .color-custom-row label { font-size: 0.72rem; color: var(--text-muted); }
  .color-custom-row input[type=color] {
    width: 36px; height: 28px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface3);
    cursor: pointer;
    padding: 2px;
  }

  /* ── REPLY ── */
  .msg-reply-preview {
    font-size: 0.75rem;
    color: var(--text-muted);
    border-left: 2px solid var(--gold-dim);
    padding-left: 6px;
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
  }
  .msg-reply-preview .reply-author { color: var(--gold-dim); font-weight: 500; }

  /* ── @MENTION ── */
  .mention {
    color: var(--gold);
    font-weight: 500;
    background: rgba(201,168,76,0.1);
    border-radius: 3px;
    padding: 0 2px;
  }
  .mention-mine {
    background: rgba(201,168,76,0.2);
    animation: mention-flash 1s ease;
  }
  @keyframes mention-flash {
    0%,100% { background: rgba(201,168,76,0.2); }
    50% { background: rgba(201,168,76,0.45); }
  }

  /* ── KAPPA + ANIMATED EMOTES ── */
  .emote {
    display: inline-block;
    vertical-align: middle;
    font-size: 1.1em;
    line-height: 1;
  }
  .emote-kappa {
    display: inline-block;
    vertical-align: middle;
    width: 1.4em; height: 1.4em;
    background: url('https://static-cdn.jtvnw.net/emoticons/v2/25/default/dark/1.0') center/contain no-repeat;
  }
  /* Generic emote images rendered via emoteImg() are <img> tags, styled inline */
  @keyframes bounce { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-4px)} }
  @keyframes spin    { from{transform:rotate(0deg)} to{transform:rotate(360deg)} }
  @keyframes shake   { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-3px)} 75%{transform:translateX(3px)} }
  @keyframes pulse-e { 0%,100%{transform:scale(1)} 50%{transform:scale(1.3)} }
  @keyframes flip    { 0%{transform:rotateY(0)} 50%{transform:rotateY(180deg)} 100%{transform:rotateY(360deg)} }
  .e-bounce { animation: bounce 0.8s infinite; display:inline-block; }
  .e-spin    { animation: spin 1.2s linear infinite; display:inline-block; }
  .e-shake   { animation: shake 0.5s infinite; display:inline-block; }
  .e-pulse   { animation: pulse-e 1s infinite; display:inline-block; }
  .e-flip    { animation: flip 1.5s infinite; display:inline-block; }

  /* ── REACTION TOOLTIP ── */
  .reaction-pill { position: relative; }
  .reaction-tooltip {
    display: none;
    position: absolute;
    bottom: calc(100% + 4px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--surface3);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 0.72rem;
    color: var(--text);
    white-space: nowrap;
    z-index: 500;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  }
  .reaction-pill:hover .reaction-tooltip { display: block; }

  /* ── CINEMATIC GRAIN ── */
  body::after {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9999;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.035'/%3E%3C/svg%3E");
    opacity: 0.4;
  }

  /* ──  NOTICE ── */
  .firebase-notice {
    background: var(--surface2);
    border: 1px solid rgba(230,57,70,0.3);
    border-radius: 3px;
    padding: 10px 14px;
    margin: 8px 1.25rem;
    font-size: 0.75rem;
    color: rgba(230,57,70,0.8);
    line-height: 1.5;
  }

  .firebase-notice a { color: #e63946; }

  /* ── MODE TABS ── */
  .mode-tabs { display: none; gap: 4px; }
  .mode-tab {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 5px 12px;
    border-radius: 20px;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.78rem;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
  }
  .mode-tab.active {
    background: rgba(201,168,76,0.12);
    border-color: var(--gold-dim);
    color: var(--gold);
  }

  /* ── CHAT RESIZE HANDLE ── */
  .chat-resize-handle {
    width: 4px;
    background: transparent;
    cursor: col-resize;
    flex-shrink: 0;
    transition: background 0.2s;
    position: relative;
    z-index: 10;
  }
  .chat-resize-handle:hover,
  .chat-resize-handle.dragging { background: var(--gold-dim); }

/* ══ DESKTOP & TABLET LAYOUT (od 769px hore) ══ */
@media (min-width: 769px) {
  html, body { 
    height: 100dvh !important; 
    overflow: hidden !important; 
  }

  .page-body { 
    height: calc(100dvh - 64px) !important; 
    display: flex !important; 
    overflow: hidden !important; 
  }

  .main { 
    display: flex !important; 
    flex: 1; 
    min-width: 0; 
    height: 100%; 
  }

  .left-col-desktop {
    flex: 1; 
    min-width: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    scrollbar-width: none;
  }
  .left-col-desktop::-webkit-scrollbar { display: none; }

  .chat-panel {
    /* Ak JS nastavuje šírku, toto ju udrží pod kontrolou na tablete */
    width: var(--chat-width, 340px);
    @media (max-width: 1100px) { width: 280px; } 
    
    min-width: 200px;
    height: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    flex-shrink: 0;
    border-left: 1px solid var(--border);
    background: var(--surface);
  }

  /* Kľúč k tomu, aby nezmizol input */
  .chat-messages {
    flex: 1 1 0% !important;
    min-height: 0 !important;
    overflow-y: auto !important;
  }

  .chat-input-area {
    flex-shrink: 0 !important;
  }
}

  /* ══ MOBILE: video → chat → movie-info ══ */
  @media (max-width: 768px) {
    html, body { height: 100dvh; overflow: hidden; }
    header { padding: 0 1rem; height: 60px; }
    #main-logo { height: 60px; }
    .viewers-badge { font-size: 0.72rem; }
    .mode-tabs { display: flex; }

    .page-body {
      height: calc(100dvh - 60px);
      display: flex;
      flex-direction: column;
      overflow: hidden;
    }

    /* Stream mode: scrollovateľná stránka */
    .main {
      display: flex;
      flex-direction: column;
      flex: 1;
      min-height: 0;
      overflow-y: auto;
      overflow-x: hidden;
    }

    /* left-col-desktop sa na mobile správa ako normálny blok – nie flex */
    .left-col-desktop {
      display: contents; /* deti sa stanú priamymi potomkami .main */
    }

    #player-wrap-outer {
      width: 100%;
      aspect-ratio: 16/9;
      flex-shrink: 0;
      order: 1;
    }

    /* Chat hneď pod videom */
    .chat-panel {
      order: 2;
      width: 100%;
      height: 420px;
      min-height: 420px;
      flex-shrink: 0;
      border-left: none;
      border-top: 1px solid var(--border);
    }

    /* ČSFD až na konci */
    .movie-info {
      order: 3;
      padding: 0.75rem 0.75rem 2rem;
      flex-shrink: 0;
    }

    /* ── CHAT ONLY MODE ── */
    body.mode-chat .main {
      overflow: hidden;
      flex: 1;
    }
    body.mode-chat #player-wrap-outer { display: none; }
    body.mode-chat .movie-info { display: none; }
    body.mode-chat .chat-panel {
      order: 1;
      flex: 1;
      height: auto;
      min-height: 0;
      border-top: none;
    }

    .msg-input { font-size: 0.95rem; }
.chat-messages {
  flex: 1 1 0% !important; /* Hovorí chatu: "Zaber všetko miesto, čo ostane" */
  min-height: 0 !important; /* Dovolí elementu zmenšiť sa pod jeho obsah */
  overflow-y: auto !important;
}

.chat-input-area {
  flex-shrink: 0 !important; /* Hovorí inputu: "Ty sa nikdy nesmieš zmenšiť" */
  min-height: fit-content;
}
    .movie-title { font-size: 1.3rem; }
  }

  /* Color palette for usernames */
  .c1 { color: #c9a84c; }
  .c2 { color: #5dc8a5; }
  .c3 { color: #e07bb5; }
  .c4 { color: #7b9de0; }
  .c5 { color: #e07b7b; }
  .c6 { color: #a57be0; }
