.watch-layout {
  --cinema-rule:#baaa814f;
  --cinema-accent:#b3dbca;
  --cinema-seat:#335447;
  max-width:1220px; min-width:0; margin:auto; padding:24px;
}
[data-theme=light] .watch-layout {
  --cinema-rule:#8c765774;
  --cinema-accent:#2d594b;
  --cinema-seat:#284c3c;
}
.watch-heading,.watch-actions { display:flex; align-items:center; flex-wrap:wrap; gap:10px; }
.watch-heading { justify-content:space-between; gap:16px 24px; margin-bottom:14px; }
.watch-heading h1 { color:var(--gold); overflow-wrap:anywhere; text-wrap:balance; }
.watch-layout:has(#room:not([hidden])) .watch-heading {padding-block:10px 14px;border-bottom:1px solid var(--cinema-rule);}
.watch-layout:has(#room:not([hidden])) .watch-heading h1 {color:var(--gold);font-size:32px;font-weight:650;}
#viewers,#notice,#player-status { color:var(--muted); }
#viewers { margin-inline-end:4px; font-size:13px; font-variant-numeric:tabular-nums; }
#notice,#player-status { overflow-wrap:anywhere; }
#notice:empty { margin:0;min-height:0; }
#notice:not(:empty),#player-status:not(:empty) { margin-block:8px 12px; }
/* Overlap the original title and poster in the lobby; theatre moves the real
   heading, and the hall transition still picks up the entry panel's image. */
.watch-layout:has(#entry-panel:not([hidden])) {
  display:grid;
  max-width:720px;
  grid-template-columns:minmax(0,1fr);
  grid-template-areas:"poster" "notice" "entry" "history";
}
.watch-layout:has(#watch-history:not([hidden])):has(#entry-panel:not([hidden])) {
  max-width:900px;
  grid-template-columns:minmax(0,1.5fr) minmax(0,1fr);
  grid-template-areas:"poster poster" "notice notice" "entry history";
  column-gap:32px;
}
#entry-panel:not([hidden]) { display:contents; }
.watch-poster {
  position:relative;
  display:flex;
  justify-content:flex-end;
  grid-area:poster;
  height:200px;
  overflow:hidden;
  border-block:1px solid #a68b63;
  background:#0a292f;
}
.watch-poster img {
  width:min(54%,340px);
  height:100%;
  object-fit:cover;
  object-position:center 52%;
  mask-image:linear-gradient(90deg,transparent,#000 33%);
}
.watch-poster::after {
  content:"";position:absolute;inset:6px;border:1px solid #edd7a361;pointer-events:none;
}
.watch-layout:has(#entry-panel:not([hidden])) > .watch-heading {
  grid-area:poster;
  z-index:1;
  align-self:end;
  max-width:58%;
  margin:0;
  padding:0 0 24px 24px;
}
.watch-layout:has(#entry-panel:not([hidden])) #watch-title {
  color:#fff0cf;font-size:42px;line-height:1.04;text-shadow:0 1px 6px #102024;
}
.watch-layout > #notice {grid-area:notice;}
#entry-panel #entry {grid-area:entry;align-self:start;margin-block:22px 0;}
.watch-layout #watch-history {grid-area:history;align-self:start;max-width:none;margin:22px 0 0;padding-inline-start:24px;border-inline-start:1px solid var(--cinema-rule);}
.watch-layout .room-modes {background:var(--input);border-color:var(--cinema-rule);}
.watch-layout .room-modes button[aria-pressed=true],.watch-layout :is(#enter,#queue-form .primary,#start) {
  background:var(--cinema-seat);color:#f8f5de;
}
.watch-layout :is(#enter,#queue-form .primary,#start):hover:not(:disabled) {background:#39644e;color:white;}
#entry { width:100%; min-width:0; gap:16px; }
.watch-page .room-modes { grid-template-columns:repeat(2,minmax(0,1fr)); }
.watch-page .room-modes button { min-width:0; }
.watch-page .nickname-sample {float:inline-end;max-width:45%;padding:1px 6px;border-radius:3px;background:#233330;}
.watch-page #entry-colors summary {min-height:44px;}
.watch-page #style-preview {max-width:100%;float:none;display:block;}
.watch-page :is(summary,select):focus-visible { outline:2px solid var(--gold); outline-offset:3px; }
.watch-page input { caret-color:var(--gold); }
.watch-page input::placeholder { color:var(--muted); opacity:1; }
.watch-page :is(#entry,#queue-form,#message-form) button { min-height:44px; }
.watch-page #entry .tool { width:44px; }
.watch-page input[readonly] { color:var(--muted); }
#watch-history { max-width:450px; margin:24px auto; }
#watch-history h2 { color:var(--gold); font-size:22px; font-weight:650; margin-bottom:8px; }
#watch-history-list li { gap:14px; }
#watch-history-list a { min-width:0; padding-block:10px; overflow-wrap:anywhere; font-variant-numeric:tabular-nums; }
#watch-history-list a:hover { text-decoration:underline; text-underline-offset:3px; }
.watch-room { display:grid; grid-template-columns:minmax(0,1fr) minmax(255px,330px); align-items:start; gap:24px; }
.watch-stage,.watch-chat,#watch-video { min-width:0; }
#screen { min-height:200px; aspect-ratio:16/9; position:relative; background:#101b1e; border:1px solid #8e7756; border-radius:4px; overflow:hidden; }
#screen.twitch-screen { min-height:300px; }
#empty-screen,#video-slot { position:absolute; inset:0; }
#empty-screen { display:grid; place-content:center; justify-items:center; gap:10px; background:#10262a; color:#eee4c9;font:600 20px/1.2 var(--woodays-type,Georgia,serif); }
#empty-screen::before {content:"";position:absolute;inset:7px;border:1px solid #c4b38540;pointer-events:none;}
#empty-screen img {border:1px solid #bdab775e;border-radius:4px;width:80px;height:80px;}
#video-slot iframe { width:100%; height:100%; border:0; display:block; }
.player-actions { margin-block:0 12px; padding:8px 0; gap:8px;border-bottom:1px solid var(--cinema-rule); }
.player-actions > button { min-height:44px; }
.player-actions .tool { width:44px; }
.player-actions #theatre { margin-inline-start:auto; flex:none; }
#seek-label { flex:1 1 180px; min-width:0; display:flex; align-items:center; gap:8px; font-size:13px; color:var(--muted); }
#seek { padding:0; min-height:36px; accent-color:var(--gold); }
#external { display:inline-flex; align-items:center; min-height:44px; color:var(--gold); font-size:13px; text-underline-offset:3px; }
#external:hover { text-decoration:underline; }
#mute [data-mute-cross],#mute.is-muted [data-mute-wave] { display:none; }
#mute.is-muted [data-mute-cross] { display:block; }
.watch-chat {border-top:2px solid var(--cinema-rule);padding-top:12px;}
.watch-room h2 {font-size:22px;font-weight:650;color:var(--gold);margin-bottom:10px;}
#queue-count {display:inline-block;vertical-align:middle;min-width:2ch;padding-inline:6px;border-inline-start:1px solid var(--cinema-rule);margin-inline-start:6px;color:var(--cinema-accent);font:600 13px/1.4 system-ui,sans-serif;font-variant-numeric:tabular-nums;}
#queue-form,#message-form { grid-template-columns:minmax(0,1fr) auto; align-items:stretch; }
.watch-empty { padding-block:12px; color:var(--muted); font-size:13px; overflow-wrap:anywhere; }
#queue { margin:8px 0 0; padding-left:24px; }
#queue:empty { margin:0; }
#queue li { padding:10px 0; border-bottom:1px solid var(--line); overflow-wrap:anywhere; }
#queue li::marker { color:var(--muted); font-variant-numeric:tabular-nums; }
.queue-item { display:flex; align-items:center; justify-content:space-between; gap:12px; min-height:44px; }
.queue-details { display:grid; gap:3px; min-width:0; }
.queue-details span { color:var(--muted); font-size:12px; }
#queue li a { color:var(--gold); text-underline-offset:3px; }
#queue li a:hover { text-decoration:underline; }
#queue li button { width:44px; min-height:44px; }
.watch-chat-history { position:relative; margin-bottom:12px;background:var(--input);border-block:1px solid var(--cinema-rule); }
#watch-chat-empty { position:absolute; inset:0 10px auto; pointer-events:none; }
#watch-log { height:clamp(165px,42vh,450px); padding:4px; overflow:auto; overflow-wrap:anywhere; scrollbar-gutter:stable; scrollbar-color:var(--muted) transparent; overscroll-behavior:contain; }
#watch-log:focus-visible { outline:2px solid var(--gold); outline-offset:2px; border-radius:4px; }
#watch-log p {padding:6px;line-height:1.5;}
#watch-log strong { color:var(--gold); }
#reaction-layer { position:absolute; inset:0; pointer-events:none; overflow:hidden; }
#reaction-layer span { position:absolute; left:var(--reaction-x); bottom:10%; max-width:30%; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; padding:6px 9px; color:#fff; background:#21191bd9; border-radius:8px; animation:watch-reaction 2.6s ease-out forwards; }
@keyframes watch-reaction { 0% { opacity:0; transform:translateY(8px) scale(.85); } 15% { opacity:1; transform:translateY(-10px) scale(1); } 75% { opacity:1; } 100% { opacity:0; transform:translateY(-115px); } }
@media (prefers-reduced-motion: reduce) { #reaction-layer span { animation:none; } }
#watch-time { font-size:13px; font-variant-numeric:tabular-nums; white-space:nowrap; }
#watch-live-status { display:flex; justify-content:flex-end; min-height:30px; margin-bottom:6px; }
#watch-live { align-self:center; background:#b42433; color:white; padding:4px 10px; border-radius:4px; font-size:15px; font-weight:750; opacity:0; transition:opacity 150ms ease; }
#watch-live.is-visible { opacity:1; }
@media (prefers-reduced-motion: reduce) { #watch-live { transition:none; } }
html:has(#room.theatre) { overflow:hidden; }
#room.theatre { position:fixed; inset:0; z-index:100; overflow:auto; overscroll-behavior:contain; background:var(--panel); padding:18px; grid-template-columns:minmax(0,1fr) minmax(220px,28vw); align-content:start; gap:16px 24px; }
#watch-theatre-header { grid-column:1 / -1; min-width:0; }
#watch-theatre-header .watch-heading { margin-bottom:0; }
#watch-theatre-header h1 { font-size:28px; }
#watch-theatre-header #notice:empty { display:none; }
#watch-theatre-header #notice:not(:empty) { margin-bottom:0; }
#room.theatre #screen:not(.twitch-screen) { width:min(100%,calc((100dvh - 180px)*16/9)); min-height:0; margin-inline:auto; }
#room.theatre #watch-log { height:clamp(120px,65dvh,78dvh); }
#reactions { display:flex; flex-wrap:wrap; gap:5px; margin-bottom:8px; }
#reactions button { min-width:44px; min-height:44px; padding-inline:5px;background:transparent;border-color:var(--cinema-rule); }
#reactions button:hover:not(:disabled) {background:var(--hover);}
.watch-page #watch-chat-status { block-size:auto; min-block-size:1.5em; overflow-wrap:anywhere; }
.watch-page dialog { max-height:calc(100dvh - 32px); overflow:auto; }
.watch-page dialog :is(h2,p,.player-name) { overflow-wrap:anywhere; }
@media (max-width:780px) {
  .watch-layout { padding:16px; }
  .watch-heading h1 { font-size:32px; }
  .watch-room { grid-template-columns:minmax(0,1fr); }
  #screen:not(.twitch-screen) { min-height:0; }
  #room.theatre { grid-template-columns:minmax(0,1fr); padding:16px; }
  #room.theatre #watch-log { height:200px; }
  #watch-log { height:200px; }
  .watch-page :is(input,select) { font-size:16px; }
  .watch-page button { min-height:44px; }
  #room-tools .tool { width:44px; }
}
@media (max-width:480px) {
  .watch-page > .bar { flex-wrap:wrap; gap:12px; padding-inline:16px; }
  .watch-page > .bar .back { padding-left:12px; }
  .watch-heading h1 { font-size:28px; }
  #room-tools { gap:8px; }
  #viewers { flex-basis:100%; }
  #queue-form { grid-template-columns:minmax(0,1fr); }
  #seek-label { flex-basis:100%; }
  .watch-page .color-row { grid-template-columns:minmax(0,1fr) 42px minmax(72px,90px); }
  #room.theatre { padding:12px; }
  #watch-theatre-header .watch-heading { gap:12px; }
  #watch-theatre-header #viewers { flex-basis:auto; }
  .watch-page dialog .actions { flex-wrap:wrap; }
}
@media (max-width:650px) {
  .watch-layout:has(#watch-history:not([hidden])):has(#entry-panel:not([hidden])) {
    grid-template-columns:minmax(0,1fr);
    grid-template-areas:"poster" "notice" "entry" "history";
  }
  .watch-layout #watch-history {border:0;border-top:1px solid var(--cinema-rule);padding:14px 0 0;}
  .watch-poster {height:156px;}
  .watch-layout:has(#entry-panel:not([hidden])) > .watch-heading {max-width:61%;padding:0 0 18px 17px;}
  .watch-layout:has(#entry-panel:not([hidden])) #watch-title {font-size:32px;}
  .watch-layout:has(#room:not([hidden])) .watch-heading h1 {font-size:26px;}
}
