:root {
  color-scheme: light;
  --blue: #401ffb;
  --black: #000;
  --white: #fff;
  --gray: #f1eeee;
  --orange: #fb541f;
  --border: 1px solid var(--black);
  --sans: Arial, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Monaco, Consolas, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body { color: var(--black); font-family: var(--sans); }
button, a { font: inherit; }

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

.sr-only {
  clip: rect(0, 0, 0, 0);
  height: 1px; width: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  position: absolute;
  white-space: nowrap;
}

.technical-label {
  font-family: var(--mono);
  font-size: 0.7rem; font-weight: 600;
  letter-spacing: 0.08em;
}

.brand {
  align-items: center; display: inline-flex; gap: 10px;
  color: inherit; text-decoration: none;
}

.brand-mark {
  align-items: center; display: inline-flex; justify-content: center;
  background: var(--blue);
  height: 32px; width: 32px;
}

.brand-mark img { display: block; height: 25px; width: 25px; }
.brand-name { font-size: 1.25rem; line-height: 1; }
.status-line { align-items: center; display: flex; gap: 9px; }

.status-dot {
  background: var(--gray); border: var(--border); border-radius: 50%;
  flex: 0 0 auto;
  height: 12px; width: 12px;
}

.status-dot.ready,
.status-dot.active { background: var(--blue); }
.status-dot.busy,
.status-dot.cleaning { background: var(--orange); }
.status-dot.unavailable { background: var(--black); }

.primary-action,
.end-session,
.session-link {
  align-items: center; display: inline-flex; justify-content: center;
  border: var(--border);
  min-height: 44px; padding: 0 18px;
}

.primary-action {
  background: var(--blue); color: var(--white);
  cursor: pointer; text-decoration: none;
}
.primary-action:hover:not(:disabled) { background: var(--black); }
.primary-action:disabled,
.end-session:disabled { cursor: not-allowed; opacity: 0.55; }

.status-error,
.session-error {
  color: #9c1602;
  font-size: 0.85rem; line-height: 1.35;
}

/* Waiting room */
.waiting-page { background: var(--blue); }

.queue-screen {
  align-items: center; display: flex; justify-content: center;
  min-height: 100vh; min-height: 100dvh;
  padding: 24px;
}

.queue-card {
  background: var(--white); border: var(--border); border-top-width: 8px;
  padding: clamp(26px, 5vw, 42px);
  width: min(100%, 540px);
}

.queue-card-header {
  align-items: center; display: flex; justify-content: space-between;
  border-bottom: var(--border);
  padding-bottom: 24px;
}

.queue-status { margin-top: clamp(32px, 6vw, 50px); }
.queue-card h1 {
  font-size: clamp(3rem, 9vw, 5rem); font-weight: 400;
  letter-spacing: -0.055em; line-height: 0.88;
  margin: 18px 0 20px;
}

.queue-detail {
  font-size: 1.08rem; line-height: 1.35;
  margin: 0 0 34px;
  min-height: 2.7em;
}

.queue-actions { display: grid; gap: 13px; }
.queue-actions .primary-action { width: 100%; }
.text-action {
  background: transparent; border: 0;
  cursor: pointer; padding: 4px;
  text-decoration: underline; text-underline-offset: 3px;
}
.text-action:hover { color: var(--blue); }
.queue-card .status-error { margin: -18px 0 18px; }

/* Active simulator session */
.session-page {
  --session-bar-height: 64px;
  background: var(--black);
  height: 100vh; height: 100dvh;
  overflow: hidden;
}

.session-bar {
  align-items: center; display: flex; gap: 12px;
  background: var(--black); color: var(--white);
  height: var(--session-bar-height); padding: 8px 16px;
  position: relative; z-index: 2;
}

.session-bar .brand-mark { background: var(--white); }
.session-bar .brand-mark img { filter: invert(1); }
.session-links { display: flex; gap: 8px; margin-left: auto; }

.session-link {
  border-color: var(--white); color: var(--white);
  gap: 7px; padding: 0 12px;
  text-decoration: none; white-space: nowrap;
}

.session-link:hover,
.end-session:hover:not(:disabled) {
  background: var(--white); color: var(--black);
}

.session-link.buy-robot-link {
  background: var(--blue); border-color: var(--blue);
}
.session-link.buy-robot-link:hover {
  background: var(--white); border-color: var(--white);
}
.github-mark { fill: currentColor; height: 16px; width: 16px; }

.session-clock {
  align-items: flex-end; display: flex; flex-direction: column;
  min-width: 66px;
}
.session-clock strong {
  font-family: var(--mono);
  font-size: 1.2rem; font-weight: 500;
}

.end-session {
  background: transparent; border-color: var(--white); color: var(--white);
  cursor: pointer; white-space: nowrap;
}

.session-progress {
  background: var(--blue);
  bottom: 0; left: 0; position: absolute;
  height: 4px; width: 100%;
  transition: width 0.25s linear;
}

.session-error {
  background: var(--white); border: var(--border);
  padding: 7px 10px;
  position: absolute; right: 16px; top: calc(100% + 8px);
}

.simulator-frame-shell {
  height: calc(100vh - var(--session-bar-height));
  height: calc(100dvh - var(--session-bar-height));
  position: relative;
}
#simulator-frame {
  background: var(--white); border: 0;
  display: block; height: 100%; width: 100%;
}

.session-ended {
  align-items: flex-start; display: flex; flex-direction: column;
  background: var(--white);
  inset: 0; justify-content: center;
  padding: clamp(30px, 8vw, 100px); position: absolute;
}

.session-ended > .technical-label { margin: 0 0 18px; }
.session-ended h1 {
  font-size: clamp(3rem, 8vw, 7rem); font-weight: 400;
  letter-spacing: -0.05em; line-height: 0.9;
  margin: 0;
}
.session-ended > p:not(.technical-label) {
  font-size: 1.1rem; line-height: 1.45;
  margin: 24px 0 32px; max-width: 580px;
}

@media (max-width: 760px) {
  .queue-screen { padding: 12px; }
  .queue-card { padding: 24px; }
  .queue-card h1 { font-size: clamp(2.8rem, 15vw, 4.5rem); }
  .session-page { --session-bar-height: 112px; }
  .session-bar {
    align-content: center; flex-wrap: wrap;
    gap: 8px 10px; padding: 8px 12px;
  }
  .session-bar .brand-name { display: none; }
  .session-links {
    flex: 1 0 100%; margin-left: 0; order: 2;
  }
  .session-link { flex: 1; }
  .session-clock { margin-left: auto; }
}

@media (prefers-reduced-motion: reduce) {
  .session-progress { transition: none; }
}

/* admin */
.admin-card { max-width: 46rem; }
.admin-tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.75rem; margin: 1rem 0; }
.admin-tile { display: flex; flex-direction: column; gap: 0.25rem; padding: 0.75rem; border: 1px solid rgba(255,255,255,0.14); border-radius: 0.5rem; }
.admin-tile strong { font-size: 1.6rem; line-height: 1; }
.admin-target { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1rem; }
.admin-target input { width: 5rem; padding: 0.4rem 0.5rem; border-radius: 0.4rem; border: 1px solid rgba(255,255,255,0.2); background: transparent; color: inherit; font: inherit; }
.admin-rows { display: flex; flex-direction: column; gap: 0.4rem; }
.admin-row { display: grid; grid-template-columns: 1fr auto auto auto; gap: 0.75rem; align-items: center; padding: 0.5rem 0; border-top: 1px solid rgba(255,255,255,0.08); }
.admin-row code { font-size: 0.85rem; opacity: 0.85; }
.admin-chart { margin-bottom: 1rem; }
.admin-chart-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 0.4rem; }
.admin-chart-head i { display: inline-block; width: 0.6rem; height: 0.6rem; margin: 0 0.25rem 0 0.6rem; border-radius: 1px; }
.key-claimed { background: var(--blue); }
.key-refused { background: var(--orange); }
.admin-bars { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; align-items: end; gap: 2px; height: 4.5rem; padding: 0 0 2px; border-bottom: 1px solid rgba(255,255,255,0.14); }
.admin-bar { display: flex; flex-direction: column; justify-content: flex-end; height: 100%; min-height: 1px; }
.bar-claimed { background: var(--blue); min-height: 2px; }
.bar-refused { background: var(--orange); min-height: 2px; }
.admin-poolbar { display: flex; gap: 3px; }
.pool-cell { flex: 1; height: 0.9rem; border-radius: 2px; border: 1px solid rgba(255,255,255,0.14); }
.pool-leased { background: var(--blue); border-color: var(--blue); }
.pool-ready { background: rgba(255,255,255,0.55); border-color: transparent; }
.pool-starting { background: var(--orange); border-color: var(--orange); }
.pool-free { background: transparent; }
.admin-image { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1rem; }
.admin-image input { flex: 1; min-width: 0; padding: 0.4rem 0.5rem; border-radius: 0.4rem; border: 1px solid rgba(255,255,255,0.2); background: transparent; color: inherit; font: inherit; font-size: 0.85rem; }
