* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #14171d;
  font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
  color: #f8fafc;
}

#canvas-container {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
}

.hud {
  position: fixed;
  z-index: 20;
  display: flex;
  gap: 10px;
  align-items: center;
  pointer-events: none;
}

.hud button {
  pointer-events: auto;
}

.top-left {
  top: 16px;
  left: 16px;
  flex-wrap: wrap;
}

.top-right {
  top: 16px;
  right: 16px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.bottom-left {
  bottom: 16px;
  left: 16px;
}

.badge, .hud-btn, .controls-hint {
  background: rgba(18, 22, 30, 0.68);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}

.badge {
  padding: 9px 14px;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.title-badge .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #ff4d3d;
  box-shadow: 0 0 10px #ff4d3d;
}

.stats-badge .sep {
  opacity: 0.35;
}

#speed-display {
  font-variant-numeric: tabular-nums;
  min-width: 64px;
  text-align: right;
  color: #7dd3fc;
}

.gpu-pill {
  font-size: 12px;
  font-weight: 700;
  color: #34d399;
  letter-spacing: 0.3px;
}

.hud-btn {
  color: #f8fafc;
  padding: 9px 14px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.hud-btn:hover {
  background: rgba(36, 44, 58, 0.85);
  border-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
}

.hud-btn:active {
  transform: translateY(1px);
}

.controls-hint {
  padding: 10px 14px;
  font-size: 12.5px;
  line-height: 1.7;
  color: rgba(248, 250, 252, 0.88);
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

kbd {
  display: inline-block;
  padding: 1px 6px;
  margin: 0 2px;
  font-size: 11px;
  font-weight: 700;
  font-family: inherit;
  color: #fff;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 5px;
}

.toast {
  position: fixed;
  top: 74px;
  left: 50%;
  transform: translateX(-50%) translateY(0);
  z-index: 30;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
}

.toast.hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(-10px);
}

/* Live 2D Floor Plan Minimap */
.minimap-wrap {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 20;
  background: rgba(18, 22, 30, 0.72);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 14px;
  padding: 8px 8px 6px 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.32);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  pointer-events: none;
}

#minimap {
  border-radius: 8px;
  background: rgba(12, 15, 20, 0.55);
  pointer-events: auto;
  cursor: crosshair;
}

.minimap-caption {
  font-size: 10.5px;
  font-weight: 600;
  color: rgba(248, 250, 252, 0.75);
  letter-spacing: 0.2px;
}

/* Touch controls for mobile / tablet */
.touch-controls {
  display: none;
  position: fixed;
  bottom: 20px;
  left: 16px;
  right: 16px;
  z-index: 25;
  justify-content: space-between;
  align-items: flex-end;
  pointer-events: none;
}

.touch-group {
  display: flex;
  gap: 10px;
  pointer-events: auto;
}

.touch-btn {
  width: 58px;
  height: 58px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(18, 22, 30, 0.65);
  backdrop-filter: blur(8px);
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  touch-action: none;
}

.touch-btn.active {
  background: rgba(255, 77, 61, 0.85);
  transform: scale(0.95);
}

.touch-boost {
  background: rgba(234, 179, 8, 0.35);
}

@media (pointer: coarse), (max-width: 768px) {
  .touch-controls {
    display: flex;
  }
  .controls-hint {
    display: none;
  }
  .badge, .hud-btn {
    padding: 7px 10px;
    font-size: 12.5px;
  }
}

/* ================================================================ ARC Christmas Run */
:root {
  --arc-violet: #8a5cf6;
  --arc-cyan: #35c3f3;
  --arc-ink: #0b0a14;
  --xmas-red: #d0102c;
  --gold: #ffd166;
}

.brand-badge img { width: 22px; height: 22px; border-radius: 50%; }
#minimap { cursor: default; }
.minimap-wrap { padding: 6px; }

.top-center {
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  gap: 10px;
}
.score-card, .timer-card {
  background: rgba(11, 10, 20, 0.72);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(138, 92, 246, 0.45);
  border-radius: 14px;
  padding: 6px 16px;
  position: relative;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35), inset 0 0 18px rgba(138, 92, 246, 0.15);
}
.score-label { font-size: 10px; letter-spacing: 1.6px; text-transform: uppercase; opacity: 0.6; text-align: center; }
.score-value { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; min-width: 110px; text-align: center; }
.timer-value { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; padding-top: 9px; }
.timer-value.urgent { color: #ff5a6e; animation: blink 0.8s infinite; }
@keyframes blink { 50% { opacity: 0.45; } }
.combo {
  position: absolute; right: -14px; top: -10px;
  background: linear-gradient(135deg, var(--xmas-red), #ff7a1a);
  border-radius: 999px; padding: 2px 9px; font-weight: 900; font-size: 14px;
  box-shadow: 0 4px 14px rgba(208, 16, 44, 0.5);
}
.hidden { display: none !important; }

/* hide game HUD on menus */
body:not(.playing) #hud-center, body:not(.playing) .controls-hint, body:not(.playing) .touch-controls { display: none !important; }

/* floating score popups */
#popups { position: fixed; inset: 0; pointer-events: none; z-index: 22; }
.pop {
  position: absolute; left: 0; top: 0;
  font-weight: 900; font-size: 22px; color: #fff;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.6), 0 0 14px rgba(53, 195, 243, 0.8);
  white-space: nowrap;
}
.pop.gold { color: var(--gold); font-size: 30px; text-shadow: 0 0 18px rgba(255, 209, 102, 0.9); }
.pop.combo { color: #ff9a3d; }
.pop.minus { color: #ff5a6e; }

/* countdown */
.countdown {
  position: fixed; inset: 0; z-index: 40; display: grid; place-items: center;
  font-size: 140px; font-weight: 900; color: #fff; pointer-events: none;
  text-shadow: 0 0 40px rgba(138, 92, 246, 0.9), 0 10px 40px rgba(0, 0, 0, 0.5);
}
.countdown.pulse { animation: pop 0.75s ease-out; }
@keyframes pop { from { transform: scale(1.8); opacity: 0; } 30% { opacity: 1; } to { transform: scale(1); } }

/* full screen overlays */
.screen {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center; padding: 20px; overflow-y: auto;
  background: radial-gradient(ellipse at 50% 0%, rgba(138, 92, 246, 0.25), transparent 60%), rgba(6, 6, 14, 0.45);
}
#loading { background: #07070f; gap: 18px; align-content: center; }
.logo-pulse { width: 120px; height: 120px; animation: breathe 1.6s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(1.07); filter: drop-shadow(0 0 24px rgba(138, 92, 246, 0.8)); } }
.loading-text { opacity: 0.75; font-weight: 600; letter-spacing: 0.3px; }

.panel {
  width: min(560px, 100%);
  background: linear-gradient(180deg, rgba(20, 18, 36, 0.92), rgba(10, 10, 20, 0.94));
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 22px;
  padding: 28px 30px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(138, 92, 246, 0.15) inset;
  text-align: center;
  user-select: text; -webkit-user-select: text;
}
.panel-logo { width: 64px; height: 64px; margin-bottom: 8px; }
.eyebrow { text-transform: uppercase; letter-spacing: 2px; font-size: 12px; color: var(--arc-cyan); font-weight: 700; }
.panel h1 { font-size: 46px; line-height: 1.05; margin: 6px 0 12px; background: linear-gradient(90deg, #fff, #c9b6ff 50%, var(--arc-cyan)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.panel h2 { font-size: 30px; margin: 6px 0 8px; }
.panel h3 { font-size: 15px; margin: 18px 0 8px; opacity: 0.8; text-transform: uppercase; letter-spacing: 1.5px; }
.lead, .sub { color: rgba(248, 250, 252, 0.82); line-height: 1.55; font-size: 15px; }
.rules { list-style: none; text-align: left; margin: 18px auto; display: grid; gap: 8px; max-width: 420px; font-size: 14px; }
.rules li { display: flex; gap: 10px; align-items: center; background: rgba(255, 255, 255, 0.05); border-radius: 10px; padding: 8px 12px; }

.cta {
  margin-top: 10px; border: 0; cursor: pointer; color: #fff; font-weight: 800; font-size: 17px;
  padding: 14px 28px; border-radius: 999px;
  background: linear-gradient(135deg, var(--xmas-red), #ff4d6d 45%, var(--arc-violet));
  box-shadow: 0 10px 30px rgba(208, 16, 44, 0.45);
  transition: transform 0.12s ease, box-shadow 0.15s ease;
}
.cta:hover { transform: translateY(-2px); box-shadow: 0 14px 36px rgba(138, 92, 246, 0.5); }
.cta.small { font-size: 14px; padding: 11px 18px; margin-top: 0; }
.ghost, .link-btn { background: transparent; color: rgba(255, 255, 255, 0.85); border: 1px solid rgba(255, 255, 255, 0.25); border-radius: 999px; padding: 12px 22px; cursor: pointer; font-weight: 700; font-size: 14px; }
.link-btn { display: block; margin: 14px auto 0; border: 0; text-decoration: underline; opacity: 0.75; }
.end-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 18px; }

input, select, textarea {
  width: 100%; background: rgba(255, 255, 255, 0.07); border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 12px; padding: 11px 13px; color: #fff; font: inherit; font-size: 14px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--arc-violet); box-shadow: 0 0 0 3px rgba(138, 92, 246, 0.25); }
select option { color: #111; }
.row-form { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; margin-top: 14px; }
.form-msg { min-height: 18px; margin-top: 8px; font-size: 13px; color: var(--arc-cyan); }
.leaderboard { list-style: none; counter-reset: r; display: grid; gap: 4px; text-align: left; max-height: 250px; overflow-y: auto; }
.leaderboard li { counter-increment: r; display: flex; justify-content: space-between; gap: 10px; padding: 7px 12px; border-radius: 9px; background: rgba(255, 255, 255, 0.04); font-size: 14px; }
.leaderboard li::before { content: counter(r) '.'; opacity: 0.5; width: 22px; }
.leaderboard li span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leaderboard li.me { background: rgba(138, 92, 246, 0.3); }
.leaderboard li.muted { justify-content: center; opacity: 0.6; }
.leaderboard li.muted::before { content: ''; }

.invite-panel { width: min(620px, 100%); }
.inv-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 16px 0; }
.inv-grid div { background: rgba(255, 255, 255, 0.05); border-radius: 14px; padding: 12px; display: grid; gap: 3px; text-align: left; }
.inv-grid span { font-size: 11px; text-transform: uppercase; letter-spacing: 1.4px; opacity: 0.6; }
.inv-grid b { font-size: 15px; }
.inv-grid i { font-style: normal; font-size: 13px; opacity: 0.75; }
.rsvp-form { display: grid; gap: 9px; margin-top: 16px; text-align: left; }
.rsvp-form .two { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.persons { display: grid; gap: 4px; font-size: 12px; opacity: 0.85; }
.consent { display: flex; gap: 8px; align-items: flex-start; font-size: 12.5px; opacity: 0.8; }
.consent input { width: auto; margin-top: 2px; }
.rsvp-form .cta { justify-self: center; }
.deadline { text-align: center; font-size: 12.5px; opacity: 0.65; }
.rsvp-done { margin-top: 16px; display: grid; gap: 10px; justify-items: center; }

.touch-drift { background: rgba(53, 195, 243, 0.3); }

@media (max-width: 640px) {
  .panel { padding: 22px 18px; }
  .panel h1 { font-size: 36px; }
  .row-form, .rsvp-form .two, .inv-grid { grid-template-columns: 1fr; }
  .score-value, .timer-value { font-size: 20px; }
  .minimap-wrap { display: none; }
  .top-right .hud-btn span { display: none; }
  #hud-center { top: 64px; }
  #speed-display, .stats-badge .sep { display: none; }
  #room-display { display: none; }
  .touch-controls { left: 12px; right: 12px; bottom: calc(14px + env(safe-area-inset-bottom)); }
  .touch-btn { width: 62px; height: 62px; }
  .touch-right { display: grid; grid-template-columns: 62px 62px; gap: 10px; }
  .touch-left { align-self: flex-end; }
}

/* 3D asset credits (CC BY), folded away under the intro */
.credits { margin: 12px auto 0; max-width: 460px; font-size: 11px; line-height: 1.45; color: rgba(255, 255, 255, 0.55); text-align: left; }
.credits summary { cursor: pointer; text-align: center; opacity: 0.7; list-style: none; }
.credits summary::-webkit-details-marker { display: none; }
.credits summary:hover { opacity: 1; }
.credits[open] summary { margin-bottom: 6px; }
.credits ul { margin: 6px 0; padding-left: 16px; columns: 2; column-gap: 14px; }
.credits li { break-inside: avoid; margin-bottom: 2px; }
.credits a { color: rgba(255, 255, 255, 0.8); }
.credits p { margin: 4px 0; }
@media (max-width: 520px) { .credits ul { columns: 1; } }
