:root {
  color-scheme: dark;
  --maroon: #500000;
  --maroon-bright: #7f1d1d;
  --ink: #090a0c;
  --panel: #131519;
  --panel-strong: #181b20;
  --line: #2a2d33;
  --muted: #989da8;
  --cream: #f5efe3;
  --white: #fffdf8;
  --gold: #e7b564;
  --green: #5bc58a;
  --radius: 16px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-width: 320px;
  min-height: 100%;
  margin: 0;
  background: var(--ink);
  color: var(--white);
}

body {
  min-height: 100vh;
  overflow: hidden;
}

button,
a {
  font: inherit;
}

button:focus-visible,
a:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}

.app-shell {
  min-height: 100vh;
  height: 100vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background:
    radial-gradient(circle at 92% 0%, rgba(80, 0, 0, 0.38), transparent 29rem),
    var(--ink);
}

.topbar {
  min-height: 78px;
  padding: 14px 18px 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(9, 10, 12, 0.92);
}

.brand-lockup,
.header-status,
.clock-cluster,
.room-title-wrap,
.dialog-actions {
  display: flex;
  align-items: center;
}

.brand-lockup {
  gap: 13px;
  min-width: 0;
}

.brand-mark {
  width: 47px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 12px;
  border: 1px solid #8c4343;
  background: var(--maroon);
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.04);
  color: var(--cream);
  font-family: Georgia, serif;
  font-size: 29px;
  font-weight: 700;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--gold);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.17em;
  line-height: 1;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  color: var(--white);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(21px, 1.75vw, 29px);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1;
}

.header-status {
  gap: 9px;
  flex: 0 0 auto;
}

.clock-cluster {
  gap: 0;
}

.clock-block {
  min-width: 108px;
  padding: 0 14px;
  display: grid;
  justify-items: end;
  border-right: 1px solid var(--line);
}

.clock-block:first-child {
  padding-left: 0;
}

.clock-block time {
  font-variant-numeric: tabular-nums;
  font-size: 18px;
  font-weight: 740;
  letter-spacing: 0.04em;
}

.clock-block span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.event-clock time {
  color: #f1c47b;
}

.connection-pill {
  height: 36px;
  padding: 0 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid #275c3d;
  border-radius: 999px;
  background: #0d2418;
  color: #aee8c6;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.pulse-dot,
.status-key {
  width: 7px;
  height: 7px;
  display: inline-block;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(91, 197, 138, 0.12);
}

.pulse-dot {
  animation: pulse 2.2s ease-out infinite;
}

@keyframes pulse {
  50% { box-shadow: 0 0 0 8px rgba(91, 197, 138, 0); }
}

.icon-button,
.close-button,
.text-button {
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-strong);
  color: var(--white);
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
}

.icon-button {
  width: 36px;
  padding: 9px;
}

.icon-button:hover,
.close-button:hover,
.text-button:hover {
  border-color: #525761;
  background: #22262c;
}

.icon-button:active,
.close-button:active,
.text-button:active {
  transform: translateY(1px);
}

.icon-button svg,
.expand-cue svg,
.placeholder-icon svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
}

.timer-grid {
  min-height: 0;
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.room-card {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  display: grid;
  grid-template-rows: 43px minmax(0, 1fr);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
}

.room-card.is-connected {
  border-color: #41454e;
}

.room-header {
  padding: 0 11px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #1a1d22, #15171b);
}

.room-title-wrap {
  min-width: 0;
  gap: 8px;
}

.room-number {
  flex: 0 0 auto;
  color: var(--gold);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.12em;
}

.room-name {
  overflow: hidden;
  margin: 0;
  color: var(--white);
  font-size: 14px;
  font-weight: 730;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.room-state {
  flex: 0 0 auto;
  padding: 5px 7px;
  border-radius: 999px;
  background: #24272d;
  color: #8e949e;
  font-size: 8px;
  font-weight: 850;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.is-connected .room-state {
  background: #0d2b1b;
  color: #8cdfae;
}

.timer-stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  background: #030405;
  color: inherit;
  cursor: zoom-in;
}

.timer-stage iframe,
.dialog-stage iframe {
  width: 100%;
  height: 100%;
  display: block;
  border: 0;
  background: #030405;
  pointer-events: none;
}

.loading-indicator {
  position: absolute;
  inset: 50% auto auto 50%;
  z-index: 0;
  width: 24px;
  height: 24px;
  margin: -12px 0 0 -12px;
  border: 2px solid #2b2e33;
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 6px;
  padding: 18px;
  background:
    linear-gradient(rgba(255,255,255,.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.018) 1px, transparent 1px),
    #0e1013;
  background-size: 24px 24px;
  text-align: center;
}

.placeholder[hidden] {
  display: none;
}

.placeholder-icon {
  width: 28px;
  height: 28px;
  margin-bottom: 3px;
  color: #5f646e;
}

.placeholder strong {
  color: #d1d3d7;
  font-size: 12px;
}

.placeholder small {
  max-width: 200px;
  color: #777d87;
  font-size: 9px;
  line-height: 1.35;
}

.expand-cue {
  position: absolute;
  right: 8px;
  bottom: 8px;
  z-index: 2;
  width: 27px;
  height: 27px;
  padding: 6px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.68);
  color: rgba(255, 255, 255, 0.86);
  opacity: 0;
  transform: translateY(3px);
  transition: opacity 140ms ease, transform 140ms ease;
}

.timer-stage:hover .expand-cue,
.timer-stage:focus-visible .expand-cue {
  opacity: 1;
  transform: translateY(0);
}

.footer-bar {
  min-height: 34px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 20px;
  border-top: 1px solid var(--line);
  background: #0c0e10;
  color: var(--muted);
  font-size: 9px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.footer-bar p {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 7px;
}

.footer-note {
  margin-left: auto !important;
}

.focus-dialog {
  width: min(1400px, calc(100vw - 48px));
  height: min(860px, calc(100vh - 48px));
  padding: 0;
  overflow: hidden;
  border: 1px solid #454a54;
  border-radius: 20px;
  background: var(--panel);
  color: var(--white);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.7);
}

.focus-dialog::backdrop {
  background: rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(8px);
}

.dialog-shell {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-rows: 68px minmax(0, 1fr);
}

.dialog-header {
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.dialog-header h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 22px;
}

.dialog-actions {
  gap: 8px;
}

.text-button,
.close-button {
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.text-button {
  border-color: #6e3535;
  background: var(--maroon);
}

.dialog-stage {
  min-height: 0;
  background: #020304;
}

@media (max-width: 1080px) {
  body { overflow: auto; }
  .app-shell { height: auto; min-height: 100vh; }
  .timer-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: none;
  }
  .room-card { min-height: 280px; }
}

@media (max-width: 720px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }
  .header-status { width: 100%; }
  .clock-cluster { margin-right: auto; }
  .clock-block { align-items: start; justify-items: start; }
  .connection-pill { display: none; }
  .timer-grid { grid-template-columns: 1fr; }
  .room-card { min-height: 320px; }
  .footer-note { display: none !important; }
  .focus-dialog { width: calc(100vw - 20px); height: calc(100vh - 20px); }
  .text-button { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
