/* Timer room page + themes */
body.room-body { padding-bottom: 0; min-height: 100dvh; background: var(--room-bg, var(--bg)); background-attachment: fixed; }

/* ---------- Themes ---------- */
body[data-room-theme="christmas"] {
  --bg: #0e2a1e; --surface: #133a2a; --surface-2: #1b4a36; --text: #fdf7ec; --muted: #c4d6c6; --border: #2b5d45;
  --accent: #e5383b; --accent-text: #fff; --ok: #7bd389; --warn: #f4c95d; --over: #ff6b6b; --stage-bg: #0b2218;
  --room-bg: radial-gradient(1200px 600px at 50% -10%, #1f5a3f, #0b2218 60%, #071a12);
  color-scheme: dark;
}
body[data-room-theme="halloween"] {
  --bg: #140b1f; --surface: #21122f; --surface-2: #2d1a40; --text: #f6ecff; --muted: #c5b3d9; --border: #3d2657;
  --accent: #ff7a1a; --accent-text: #1a0d00; --ok: #9be15d; --warn: #ffb000; --over: #ff4d6d; --stage-bg: #10081a;
  --room-bg: radial-gradient(1000px 600px at 80% 0%, #3b1d5c, #140b1f 55%, #0a0510);
  color-scheme: dark;
}
body[data-room-theme="newyear"] {
  --bg: #0a0f24; --surface: #121a38; --surface-2: #1a2450; --text: #fffaf0; --muted: #b8c0e0; --border: #2a356b;
  --accent: #f5c542; --accent-text: #1a1400; --ok: #6ee7b7; --warn: #f5c542; --over: #ff6b81; --stage-bg: #070b1c;
  --room-bg: radial-gradient(1200px 700px at 50% 0%, #1d2b6b, #0a0f24 60%, #05081a);
  color-scheme: dark;
}
body[data-room-theme="birthday"] {
  --bg: #2a0f2e; --surface: #3a1640; --surface-2: #4a1d52; --text: #fff5fb; --muted: #e3c4de; --border: #5e2a66;
  --accent: #ff5fa2; --accent-text: #2a0018; --ok: #7ee0c3; --warn: #ffd166; --over: #ff6b6b; --stage-bg: #22091f;
  --room-bg: radial-gradient(1100px 650px at 30% 0%, #6b2a74, #2a0f2e 58%, #160616);
  color-scheme: dark;
}
body.room-body { transition: background-color .5s; }

/* ---------- Last 10 seconds + celebration message ---------- */
.final {
  position: absolute; inset: 0; z-index: 4; display: grid; place-items: center; pointer-events: none;
  font-weight: 800; font-variant-numeric: tabular-nums; color: var(--accent);
  font-size: clamp(120px, 34vw, 360px); line-height: 1;
  background: color-mix(in srgb, var(--stage-bg) 94%, transparent);
  text-shadow: 0 0 40px color-mix(in srgb, var(--accent) 45%, transparent);
}
.final[hidden] { display: none; }
.final.msg { font-size: clamp(36px, 8vw, 96px); text-align: center; padding: 0 16px; color: var(--text); }
.final.pop { animation: pop .9s ease-out; }
@keyframes pop { 0% { transform: scale(1.5); opacity: .2; } 30% { transform: scale(1); opacity: 1; } 100% { transform: scale(.94); opacity: 1; } }
.stage:fullscreen .final, .stage.pseudo-fs .final { font-size: min(60vh, 50vw); }
.stage:fullscreen .final.msg, .stage.pseudo-fs .final.msg { font-size: min(14vh, 9vw); }

/* ---------- Host announcement ---------- */
.note {
  display: inline-block; max-width: min(92%, 900px); margin: 14px auto 0; padding: 10px 20px; border-radius: 16px;
  background: var(--accent); color: var(--accent-text); font-weight: 700; line-height: 1.3;
  font-size: clamp(1.2rem, 3.8vw, 2rem); overflow-wrap: anywhere; text-wrap: balance;
}
.note[hidden] { display: none; }
.note.pop { animation: note-pop .6s ease-out; }
@keyframes note-pop { 0% { transform: scale(.7); opacity: 0; } 55% { transform: scale(1.06); opacity: 1; } 100% { transform: scale(1); } }
.stage:fullscreen .note, .stage.pseudo-fs .note { font-size: min(5.5vw, 7vh); padding: 1.6vh 3vw; border-radius: 2.4vh; margin-top: 3vh; }
body.remote .note { font-size: 1.05rem; }
@media (prefers-reduced-motion: reduce) { .note.pop { animation: none; } }

/* ---------- "I'm done" tally + button ---------- */
.tally { margin-top: 10px; font-weight: 700; font-size: clamp(1.05rem, 3vw, 1.5rem); font-variant-numeric: tabular-nums; color: var(--text); }
.tally[hidden] { display: none; }
.stage:fullscreen .tally, .stage.pseudo-fs .tally { font-size: min(4.4vw, 5.4vh); margin-top: 2vh; }
.done-row { display: flex; justify-content: center; }
.done-row .btn { margin-top: 14px; min-height: 52px; padding: 0 26px; font-size: 1.1rem; }
.done-row .btn[hidden] { display: none; }
body.remote .done-row { display: none; }

/* ---------- TV mode: fullscreen + "scan to join" corner ---------- */
.tv-join { display: none; }
.stage.tv:fullscreen .tv-join, .stage.tv.pseudo-fs .tv-join {
  display: flex; align-items: center; gap: 2vh; position: absolute; right: 3vw; bottom: 3vh; z-index: 5;
  background: #fff; color: #111; border-radius: 1.6vh; padding: 1.4vh 2vh 1.4vh 1.4vh; text-align: left;
}
.tv-qr svg { width: 17vh; height: 17vh; display: block; }
.tv-txt b { display: block; font-size: 2.6vh; }
.tv-txt span { font-size: 2vh; color: #444; }
.stage.tv .stage-tools { opacity: .25; }
.room-wrap:has(.stage.pseudo-fs) { z-index: 1001; }
.room-main .stage:fullscreen, .room-main .stage.pseudo-fs {
  background: var(--room-bg, var(--stage-bg)); background-color: var(--stage-bg);
  backdrop-filter: none; -webkit-backdrop-filter: none;
}

/* ---------- Calendar row (fixed-date rooms) ---------- */
.cal-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; margin-top: 12px; color: var(--muted); font-size: .92rem; }
.cal-row[hidden] { display: none; }
.cal-row .btn { min-height: 40px; padding: 0 14px; font-size: .92rem; text-decoration: none; color: var(--text); }

/* ---------- Phone remote mode ---------- */
.remote-tag { display: none; font-weight: 700; color: var(--accent); }
body.remote .remote-tag { display: inline; }
body.remote #fx, body.remote .reactions, body.remote .side, body.remote .host-tag,
body.remote #btn-remote, body.remote #btn-invite, body.remote .stage-tools, body.remote .final { display: none !important; }
body.remote .room-wrap { grid-template-columns: minmax(0, 1fr); }
body.remote .room-main .time { font-size: clamp(56px, 20vw, 120px); }
body.remote.is-host .host-bar { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
body.remote .host-bar .btn { min-height: 76px; font-size: 1.25rem; }
body.remote #btn-toggle { grid-column: 1 / -1; min-height: 96px; font-size: 1.6rem; }
body.preload, body.preload * { transition: none !important; }

#fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 0; }

/* ---------- Layout ---------- */
.room-top {
  position: relative; z-index: 2; display: flex; align-items: center; gap: 10px;
  max-width: 1200px; margin: 0 auto; padding: 12px 16px;
}
.room-top .logo { white-space: nowrap; }
.room-top .spacer { flex: 1; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 12px; border-radius: 99px;
  border: 1px solid var(--border); background: color-mix(in srgb, var(--surface) 80%, transparent); color: var(--text);
  font-weight: 600; cursor: pointer; font-size: .92rem;
}
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.pill.offline .dot { background: var(--over); }

.room-wrap {
  position: relative; z-index: 1; max-width: 1200px; margin: 0 auto; padding: 0 16px 20px;
  display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start;
}
@media (max-width: 860px) { .room-wrap { grid-template-columns: minmax(0, 1fr); } }

.room-main .stage {
  background: color-mix(in srgb, var(--stage-bg) 72%, transparent);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  overflow: hidden; padding-top: 28px;
}
.room-main .stage-label { font-size: clamp(1.1rem, 3.2vw, 1.7rem); color: var(--text); font-weight: 700; padding: 0 44px; }
.room-main .time { font-size: clamp(64px, 15vw, 210px); }
.room-main .stage-seg { margin-top: 10px; font-size: 1rem; }
.stage .theme-icon { font-size: 1.4rem; display: block; min-height: 1.6rem; }

.floaty {
  position: absolute; bottom: 12px; font-size: 38px; pointer-events: none; z-index: 3;
  animation: floaty 2.6s ease-out forwards;
}
@keyframes floaty {
  0% { transform: translateY(0) scale(.6); opacity: 0; }
  15% { transform: translateY(-20px) scale(1.1); opacity: 1; }
  100% { transform: translateY(-260px) scale(1); opacity: 0; }
}

.reactions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 14px 0 6px; }
.reactions button {
  width: 52px; height: 52px; border-radius: 50%; border: 1px solid var(--border); cursor: pointer; font-size: 24px;
  background: color-mix(in srgb, var(--surface) 85%, transparent);
}
@media (max-width: 420px) {
  .reactions { gap: 6px; }
  .reactions button { width: 46px; height: 46px; font-size: 21px; }
}
.room-main .time.long { font-size: clamp(44px, 11vw, 150px); }
.reactions button:hover { transform: translateY(-2px); }
.reactions button:active { transform: scale(.92); }

.host-bar { display: none; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 10px; }
body.is-host .host-bar { display: flex; }
body.is-fixed .host-bar [data-fixed-hide] { display: none; }
.host-tag {
  display: none; font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: var(--accent); text-align: center; margin-top: 14px;
}
body.is-host .host-tag { display: block; }

/* ---------- Side panel ---------- */
.side {
  background: color-mix(in srgb, var(--surface) 88%, transparent); border: 1px solid var(--border);
  border-radius: var(--radius); display: flex; flex-direction: column; min-height: 360px; max-height: 70vh;
}
@media (max-width: 860px) { .side { max-height: none; } }
.side-tabs { display: flex; border-bottom: 1px solid var(--border); }
.side-tabs button {
  flex: 1; min-height: 48px; background: none; border: 0; cursor: pointer; font-weight: 700; color: var(--muted);
  border-bottom: 2px solid transparent;
}
.side-tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.badge { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 99px; background: var(--accent); color: var(--accent-text); font-size: .75rem; margin-left: 4px; }
.badge:empty { display: none; }
.side-pane { flex: 1; overflow: auto; padding: 10px 12px; display: none; }
.side-pane.active { display: block; }
.people { list-style: none; margin: 0; padding: 0; }
.people li { display: flex; align-items: center; gap: 8px; padding: 8px 6px; border-bottom: 1px solid var(--border); }
.people li:last-child { border-bottom: 0; }
.people .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag { font-size: .7rem; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--muted); }
.tag.host { background: var(--accent); color: var(--accent-text); }
.kick { background: none; border: 1px solid var(--border); border-radius: 10px; width: 40px; height: 40px; cursor: pointer; color: var(--muted); }

.chat-pane { display: none; flex-direction: column; flex: 1; min-height: 0; }
.chat-pane.active { display: flex; }
.chat-log { flex: 1; overflow: auto; padding: 10px 12px; list-style: none; margin: 0; min-height: 200px; }
.chat-log li { margin: 0 0 8px; line-height: 1.4; word-wrap: break-word; }
.chat-log .who { font-weight: 700; margin-right: 6px; }
.chat-log .who.host { color: var(--accent); }
.chat-log .sys { color: var(--muted); font-size: .88rem; font-style: italic; }
.chat-form { display: flex; gap: 6px; padding: 10px; border-top: 1px solid var(--border); }
.chat-form input { flex: 1; min-width: 0; min-height: 44px; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg); }
.chat-form .btn { min-height: 44px; padding: 0 14px; }
.chat-off { padding: 8px 12px; font-size: .85rem; color: var(--muted); border-top: 1px solid var(--border); }

/* ---------- Overlays ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px;
  background: color-mix(in srgb, var(--bg) 70%, transparent); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.overlay[hidden] { display: none; }
.card {
  width: min(420px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 24px;
  text-align: center; box-shadow: 0 20px 60px rgb(0 0 0 / .35);
}
.card h1 { font-size: 1.5rem; margin: 6px 0 4px; }
.card p { color: var(--muted); margin: 0 0 16px; }
.card .big-icon { font-size: 44px; }
.card input { width: 100%; min-height: 50px; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--bg); font-size: 1.05rem; text-align: center; margin-bottom: 12px; }
.card .btn { width: 100%; }

.theme-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.theme-grid label {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--border);
  cursor: pointer; font-weight: 600; color: var(--text); background: var(--bg);
}
.theme-grid input { accent-color: var(--accent); }
.theme-grid label:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
dialog .field-row { margin-top: 12px; }
dialog form h2 { margin-bottom: 4px; }

/* fullscreen: only the stage */
.room-main .stage:fullscreen .floaty, .room-main .stage.pseudo-fs .floaty { font-size: 64px; }

@media (prefers-reduced-motion: reduce) { .floaty { animation-duration: .01s; } }

/* ---------- Seasonal countdown pages ---------- */
.season { text-align: center; padding: 28px 16px 8px; }
.season h1 { font-size: clamp(1.7rem, 5vw, 2.6rem); margin: 6px 0 4px; letter-spacing: -0.02em; }
.season .season-date { color: var(--muted); margin: 0 0 18px; }
.season-live { font-weight: 700; color: var(--accent); min-height: 1.5em; }
.season-clock { display: flex; justify-content: center; gap: clamp(8px, 2vw, 18px); margin: 10px 0 22px; flex-wrap: wrap; }
.season-clock div {
  min-width: clamp(72px, 18vw, 140px); padding: 14px 8px; border-radius: 16px; border: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 80%, transparent);
}
.season-clock b { display: block; font-size: clamp(2.2rem, 9vw, 4.6rem); line-height: 1; font-variant-numeric: tabular-nums; }
.season-clock span { color: var(--muted); font-size: .85rem; text-transform: uppercase; letter-spacing: .08em; }
.season .btn.primary { min-height: 58px; font-size: 1.1rem; padding: 0 26px; }
.season .alt { display: block; margin-top: 12px; }
body.season-body .site-header { background: transparent; border-bottom-color: var(--border); }
body.season-body .site-footer, body.season-body .tabbar { background: var(--surface); }

/* ---------- New Year around the world ---------- */
.world-next-label { color: var(--muted); font-weight: 600; margin: 0; }
.world-next-name { font-size: clamp(1.35rem, 5vw, 2.2rem); font-weight: 750; letter-spacing: -0.03em; margin: 2px 0 12px; min-height: 1.3em; overflow-wrap: anywhere; }
.content .world-list { list-style: none; margin: 0; padding: 0; }
.world-list li {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; margin: 0 0 8px;
  border: 1px solid color-mix(in srgb, var(--border) 70%, transparent); border-radius: 16px; background: var(--surface);
}
.world-list .w-main { flex: 1; min-width: 0; }
.world-list strong { font-weight: 650; overflow-wrap: anywhere; }
.world-list .tag { margin-left: 6px; white-space: nowrap; }
.world-list .w-when { display: block; font-size: .85rem; color: var(--muted); text-wrap: balance; }
.world-list .w-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex: none; }
.world-list .w-left { font-variant-numeric: tabular-nums; font-weight: 700; }
.world-list .btn { min-height: 40px; min-width: 0; padding: 0 12px; font-size: .88rem; }
.world-list li.done { background: color-mix(in srgb, var(--accent) 9%, var(--surface)); }
.world-list li.done .btn { display: none; }
.world-list li.next { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }

/* ===================== Design polish (overrides above) ===================== */
.room-top { padding: 14px 16px; }
.pill {
  border: 0; min-height: 40px; padding: 0 14px; font-size: .9rem; font-variant-numeric: tabular-nums;
  background: color-mix(in srgb, var(--surface) 75%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.room-top .btn.share { min-height: 40px !important; border-radius: 12px; }
.room-top .lang-menu > summary { padding: 0 10px; }
@media (max-width: 480px) {
  .room-top .lang-menu > summary span { display: none; }
  .room-top .lang-menu ul { right: auto; left: 50%; transform: translateX(-50%); }
}
.room-main .stage {
  border-color: color-mix(in srgb, var(--border) 70%, transparent);
  background: color-mix(in srgb, var(--stage-bg) 78%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  padding-top: 36px;
}
.room-main .stage-label { font-size: clamp(1.05rem, 2.8vw, 1.5rem); font-weight: 650; letter-spacing: -0.03em; }
.room-main .stage-seg { font-size: .95rem; }
.stage .theme-icon { font-size: 1.25rem; margin-bottom: 2px; }

.reactions { gap: 6px; margin: 16px 0 4px; }
.reactions button {
  width: 48px; height: 48px; border: 0; font-size: 22px;
  background: color-mix(in srgb, var(--surface) 78%, transparent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--border) 70%, transparent);
  transition: transform .12s, background-color .15s;
}
.reactions button:hover { background: var(--surface); }
@media (max-width: 420px) { .reactions button { width: 44px; height: 44px; font-size: 20px; } }

.host-tag { font-size: .7rem; letter-spacing: .1em; color: var(--muted); margin-top: 18px; }
.host-bar { gap: 8px; }

.side { border-color: color-mix(in srgb, var(--border) 70%, transparent); border-radius: 20px; overflow: hidden; background: color-mix(in srgb, var(--surface) 90%, transparent); }
.side-tabs { border: 0; padding: 6px; gap: 4px; margin: 8px 8px 0; background: var(--surface-2); border-radius: 12px; }
.side-tabs button { min-height: 40px; border: 0; border-radius: 9px; font-weight: 600; font-size: .92rem; }
.side-tabs button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgb(0 0 0 / .08); }
.side-pane { padding: 8px 14px; }
.people li { padding: 8px 2px; border-bottom-color: color-mix(in srgb, var(--border) 60%, transparent); }
.people .nm { font-weight: 500; }
.tag { font-size: .68rem; font-weight: 650; padding: 3px 8px; letter-spacing: 0; }
.tag.host { background: var(--accent-soft, var(--surface-2)); color: var(--accent); }
.kick { border: 0; background: var(--surface-2); border-radius: 10px; font-size: .9rem; }
.kick:hover { color: var(--text); }
.chat-log { padding: 12px 14px; }
.chat-log li { line-height: 1.55; font-size: .95rem; }
.chat-log .who { font-weight: 650; }
.chat-form { padding: 10px 12px 12px; border-top-color: color-mix(in srgb, var(--border) 60%, transparent); }
.chat-form input { border-radius: 12px; }
.chat-form input:focus { outline: none; border-color: var(--accent); }
.chat-off { border-top-color: color-mix(in srgb, var(--border) 60%, transparent); }

.card { border-radius: 22px; padding: 28px 24px; box-shadow: 0 24px 64px rgb(0 0 0 / .28); }
.card h1 { font-size: 1.4rem; font-weight: 700; letter-spacing: -0.03em; }
.card .big-icon { font-size: 40px; }
.theme-grid label { border-radius: 14px; font-weight: 550; padding: 11px 12px; }
.cal-row { gap: 6px; font-size: .88rem; }
.cal-row .btn { min-height: 36px; border-radius: 10px; padding: 0 12px; font-size: .88rem; }
.season h1 { font-weight: 750; letter-spacing: -0.04em; }
.season-clock div { border-radius: 18px; border-color: color-mix(in srgb, var(--border) 70%, transparent); }
.season-clock b { font-weight: 650; letter-spacing: -0.04em; }
.season-clock span { font-size: .74rem; letter-spacing: .12em; font-weight: 600; }
/* soft accent follows each room theme */
body.room-body:not([data-room-theme="classic"]) { --accent-soft: color-mix(in srgb, var(--accent) 20%, var(--surface)); }
@media (max-width: 860px) { .side { min-height: 0; } .side-pane { min-height: 96px; } }
