:root {
  color-scheme: light dark;
  --background: #f4f7fb;
  --surface: rgba(255, 255, 255, 0.92);
  --surface-strong: #ffffff;
  --text: #111827;
  --muted: #64748b;
  --border: #d7dee8;
  --primary: #2563eb;
  --primary-text: #ffffff;
  --secondary: #e2e8f0;
  --secondary-text: #111827;
  --danger: #dc2626;
  --danger-dark: #7f1d1d;
  --success: #15803d;
  --shadow: 0 20px 50px rgba(15, 23, 42, 0.12);
}

@media (prefers-color-scheme: dark) {
  :root {
    --background: #0b1020;
    --surface: rgba(15, 23, 42, 0.92);
    --surface-strong: #111827;
    --text: #f8fafc;
    --muted: #94a3b8;
    --border: #334155;
    --primary: #3b82f6;
    --secondary: #334155;
    --secondary-text: #f8fafc;
    --success: #4ade80;
    --shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  }
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at top, color-mix(in srgb, var(--primary) 16%, transparent), transparent 32rem),
    var(--background);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  touch-action: manipulation;
}

.app-shell {
  width: min(calc(100% - 2rem), 760px);
  margin: 0 auto;
  padding: max(1.25rem, env(safe-area-inset-top)) 0 max(2rem, env(safe-area-inset-bottom));
}

.app-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.eyebrow {
  margin: 0 0 0.25rem;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(1.8rem, 6vw, 2.7rem);
}

.panel {
  border: 1px solid var(--border);
  border-radius: 1.5rem;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: clamp(1.2rem, 4vw, 2rem);
  backdrop-filter: blur(12px);
}

.panel--center {
  text-align: center;
}

label {
  display: block;
  margin: 1.25rem 0 0.5rem;
  font-weight: 700;
}

input {
  width: 100%;
  min-height: 3.25rem;
  border: 1px solid var(--border);
  border-radius: 0.9rem;
  background: var(--surface-strong);
  color: var(--text);
  padding: 0.85rem 1rem;
  outline: none;
}

input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 20%, transparent);
}

.button {
  width: 100%;
  min-height: 3.2rem;
  margin-top: 1rem;
  border: 0;
  border-radius: 0.9rem;
  padding: 0.85rem 1rem;
  font-weight: 800;
  cursor: pointer;
}

.button--primary {
  background: var(--primary);
  color: var(--primary-text);
}

.button--secondary {
  margin-top: 2rem;
  background: var(--secondary);
  color: var(--secondary-text);
}

.button:disabled,
.buzzer:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.status {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 0.45rem 0.75rem;
  font-size: 0.82rem;
  font-weight: 800;
}

.status--online {
  background: color-mix(in srgb, var(--success) 18%, transparent);
  color: var(--success);
}

.status--offline {
  background: color-mix(in srgb, var(--danger) 18%, transparent);
  color: var(--danger);
}

.status--loading {
  background: color-mix(in srgb, var(--primary) 16%, transparent);
  color: var(--primary);
}

.user-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  margin-bottom: 1.5rem;
}

.user-meta {
  text-align: left;
}

.avatar {
  display: grid;
  width: 3.5rem;
  height: 3.5rem;
  place-items: center;
  border-radius: 50%;
  background: var(--secondary);
  font-size: 2rem;
}

.muted {
  color: var(--muted);
}

.timer {
  margin-bottom: 1.35rem;
  font-size: clamp(2.1rem, 11vw, 4.6rem);
  font-variant-numeric: tabular-nums;
  font-weight: 900;
}

.buzzer {
  width: min(72vw, 330px);
  aspect-ratio: 1;
  border: 12px solid var(--danger-dark);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 28%, #fb7185, var(--danger) 48%, #991b1b);
  color: white;
  box-shadow:
    0 1rem 0 #450a0a,
    0 1.45rem 2.6rem rgba(0, 0, 0, 0.34);
  font-size: clamp(1.8rem, 9vw, 3.4rem);
  font-weight: 1000;
  letter-spacing: 0.04em;
  cursor: pointer;
  user-select: none;
}

.buzzer:active:not(:disabled) {
  transform: translateY(0.65rem);
  box-shadow:
    0 0.35rem 0 #450a0a,
    0 0.7rem 1.4rem rgba(0, 0, 0, 0.28);
}

.winner {
  padding: 1rem 0;
}

.winner__trophy {
  font-size: 3.5rem;
}

.winner__label {
  margin-bottom: 0.65rem;
  color: #d97706;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.winner__avatar {
  font-size: 4.6rem;
}

.winner h2 {
  margin: 0.4rem 0;
  font-size: clamp(2.1rem, 9vw, 4rem);
}

.winner__time {
  font-size: clamp(2.1rem, 10vw, 4.7rem);
  font-variant-numeric: tabular-nums;
  font-weight: 1000;
}

.error {
  min-height: 1.4rem;
  margin: 0.75rem 0 0;
  color: var(--danger);
}

.hidden {
  display: none !important;
}

@media (max-width: 520px) {
  .app-header {
    align-items: flex-start;
  }

  .status {
    max-width: 9rem;
    text-align: center;
  }
}
