:root {
  --bg: #f3f5f9;
  --card: #fff;
  --ink: #1b2233;
  --muted: #667085;
  --brand: #1f2a44;
  --entrance: #1a7f4b;
  --exit: #b45309;
  --danger: #b42318;
  --radius: 16px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #11151f; --card: #1c2333; --ink: #eef1f7; --muted: #9aa4b8; --brand: #0b0f18; }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
}

.top {
  background: var(--brand);
  color: #fff;
  padding: calc(1rem + env(safe-area-inset-top)) 16px 1rem;
  text-align: center;
}
.top h1 { margin: 0; font-size: 1.5rem; letter-spacing: .01em; }
.top .brand { font-size: .72rem; letter-spacing: .18em; text-transform: uppercase; opacity: .6; margin: 0 0 .15rem; }
.status { margin: .25rem 0 0; font-size: .85rem; opacity: .8; }
.status.ok::before { content: "● "; color: #4ade80; }
.status.bad::before { content: "● "; color: #f87171; }

main { max-width: 640px; margin: 0 auto; padding: 32px 16px 24px; }

.notice {
  background: var(--card);
  border-left: 4px solid var(--danger);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 16px;
}

.doors {
  list-style: none;
  margin: 0;
  padding: 8px 0 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 36px 28px;
}
.door-item { display: flex; flex-direction: column; align-items: center; gap: 14px; width: 168px; }

.door {
  --c: var(--entrance);
  position: relative;
  width: 168px;
  height: 168px;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: radial-gradient(circle at 30% 25%, color-mix(in srgb, var(--c) 78%, #fff), var(--c) 62%);
  box-shadow: 0 10px 24px color-mix(in srgb, var(--c) 45%, transparent), inset 0 -6px 12px rgba(0, 0, 0, .18);
  display: grid;
  place-items: center;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.door.exit { --c: var(--exit); }
.door::after { /* anillo exterior */
  content: "";
  position: absolute;
  inset: -9px;
  border-radius: 50%;
  border: 3px solid color-mix(in srgb, var(--c) 40%, transparent);
}
.door svg { width: 64px; height: 64px; stroke: currentColor; fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.door .state { position: absolute; bottom: 26px; font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; opacity: .95; }
.door:focus-visible { outline: 4px solid #93c5fd; outline-offset: 6px; }
.door:disabled { cursor: default; }
.door.busy { filter: saturate(.7); }
.door.busy svg { animation: spin 1s linear infinite; }
.door.done { --c: #15803d; }
.door.wait { opacity: .6; }

.caption { text-align: center; line-height: 1.25; }
.caption strong { display: block; font-size: 1.1rem; }
.caption span { font-size: .85rem; color: var(--muted); }

@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: no-preference) {
  .door { transition: transform .12s, box-shadow .12s; }
  .door:active:not(:disabled) { transform: scale(.94); }
  .door:not(:disabled):not(.busy) { animation: pulse 2.8s ease-in-out infinite; }
}
@media (prefers-reduced-motion: reduce) { .door.busy svg { animation: none; } }
@keyframes pulse {
  0%, 100% { box-shadow: 0 10px 24px color-mix(in srgb, var(--c) 45%, transparent), inset 0 -6px 12px rgba(0,0,0,.18), 0 0 0 0 color-mix(in srgb, var(--c) 35%, transparent); }
  50% { box-shadow: 0 10px 24px color-mix(in srgb, var(--c) 45%, transparent), inset 0 -6px 12px rgba(0,0,0,.18), 0 0 0 14px transparent; }
}

dialog {
  border: 0;
  border-radius: var(--radius);
  padding: 20px;
  width: min(92vw, 380px);
  background: var(--card);
  color: var(--ink);
}
dialog::backdrop { background: rgba(0, 0, 0, .55); }
dialog h2 { margin: 0 0 .25rem; font-size: 1.2rem; }
dialog p { margin: 0 0 1rem; color: var(--muted); }
.actions { display: flex; gap: 10px; }
.btn {
  flex: 1;
  min-height: 52px;
  border: 0;
  border-radius: 12px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-secondary { background: transparent; color: var(--ink); border: 1px solid var(--muted); }

.toast {
  position: fixed;
  left: 16px; right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  max-width: 520px;
  margin: 0 auto;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--entrance);
  color: #fff;
  font-weight: 600;
  text-align: center;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .3);
}
.toast.error { background: var(--danger); }

@media (prefers-reduced-motion: no-preference) {
  .door { transition: transform .08s; }
  .door:active:not(:disabled) { transform: scale(.98); }
}
