:root {
  --ink: #20232a;
  --ink-2: #3a3f4a;
  --red: #c8102e;
  --red-2: #e01b3a;
  --red-dark: #a30d26;
  --bg: #ffffff;
  --bg-2: #f2f3f5;
  --silver: #e2e4e8;
  --border: #d5d8dd;
  --border-2: #c3c7cd;
  --text: #26282c;
  --muted: #6b7078;
  --danger: #b00020;
  --radius: 12px;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: "Inter", "Segoe UI", Roboto, sans-serif;
  background: radial-gradient(1200px 700px at 70% -100px, #ffffff 0%, var(--bg-2) 45%, var(--silver) 75%);
  color: var(--text);
  min-height: 100vh;
}
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }
ul, ol { padding-left: 1rem; }
pre { white-space: pre-wrap; word-break: break-all; }
.container { width: min(1200px, 92%); margin: 0 auto; }
.muted { color: var(--muted); }
.card { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; box-shadow: 0 1px 3px rgba(20,24,30,.06); }
.list-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .5rem; }
.actions { display: flex; gap: .5rem; margin-top: 1rem; flex-wrap: wrap; }
.btn { background: var(--bg-2); color: var(--text); border: 1px solid var(--border-2); border-radius: 8px; padding: .55rem 1rem; }
.btn.primary { background: var(--red); color: #fff; font-weight: 600; border-color: var(--red); }
.btn.primary:hover { background: var(--red-2); }
.btn:hover { background: #e7e8eb; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.icon { background: none; border: none; color: var(--muted); padding: .15rem .4rem; }
input, select, textarea { background: #fff; border: 1px solid var(--border-2); border-radius: 8px; color: var(--text); padding: .5rem .7rem; }
input:focus, select:focus, textarea:focus { border-color: var(--red); outline: none; }
input[type="checkbox"] { width: auto; }
label { display: flex; flex-direction: column; gap: .25rem; font-size: .85rem; }
label.inline { display: inline-flex; align-items: center; gap: .35rem; font-size: .8rem; flex-direction: row; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td { text-align: left; padding: .45rem .5rem; border-bottom: 1px solid var(--silver); font-size: .9rem; }
.data-table tr:hover td { background: var(--bg-2); }
.data-table th { color: var(--muted); font-weight: 600; text-transform: uppercase; font-size: .75rem; }
.data-table td.num, .data-table th.num { text-align: center; }
.summary { display: flex; gap: 1rem; flex-wrap: wrap; }
.summary li { list-style: none; }
.swatch { display: inline-block; width: 14px; height: 14px; border-radius: 4px; vertical-align: middle; margin-right: .4rem; color: transparent; }
.site-header { position: relative; z-index: 50; border-bottom: 1px solid var(--border); background: rgba(255,255,255,.9); backdrop-filter: blur(4px); }
.header-inner { height: 44px; display: flex; align-items: center; gap: 1rem; }
.logo { font-weight: 700; color: var(--red); letter-spacing: .05em; }
.logo-mark { font-size: 1.1rem; }
.logo-sub { font-size: .65rem; color: var(--muted); font-weight: 500; letter-spacing: .08em; margin-left: .25rem; }
.menu-title { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; }

/* Top navigation with dropdown groups */
.topnav { display: flex; align-items: center; gap: .25rem; flex-wrap: wrap; flex: 1; justify-content: flex-end; }
.nav-btn { background: none; border: none; color: var(--muted); font: inherit; font-size: .8rem; padding: .4rem .6rem; cursor: pointer; border-radius: 6px; white-space: nowrap; transition: color .15s, background .15s; }
.nav-btn:hover, .nav-btn:focus { color: var(--red); background: rgba(200,16,46,.08); outline: none; }
.nav-btn.active { color: var(--red); background: rgba(200,16,46,.12); font-weight: 600; }
.nav-link { text-decoration: none; }
.nav-link:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
.carot { font-size: .55rem; margin-left: .25rem; transition: transform .15s; }
.nav-group { position: relative; }
.nav-group .nav-btn[aria-haspopup="true"] { padding-right: 1.5rem; }
.nav-group.open > .nav-btn[aria-haspopup="true"] .carot { transform: rotate(180deg); }
.nav-menu { display: none; position: absolute; top: calc(100% + 4px); left: 0; min-width: 180px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgba(20,24,30,.12); padding: .4rem 0; z-index: 100; }
.nav-menu a { display: block; padding: .5rem 1rem; color: var(--text); text-decoration: none; font-size: .85rem; white-space: nowrap; }
.nav-menu a:hover, .nav-menu a:focus { background: var(--bg-2); color: var(--red); outline: none; }
.nav-menu a.active { background: rgba(200,16,46,.1); color: var(--red); font-weight: 600; }
.nav-group:hover .nav-menu, .nav-group:focus-within .nav-menu, .nav-group.open .nav-menu { display: block; }
.nav-toggle { display: none; background: none; border: 1px solid var(--border); border-radius: 6px; padding: .3rem .6rem; font-size: 1rem; cursor: pointer; margin-left: .5rem; }
.sound-toggle { font-size: 1.05rem; line-height: 1; padding: .3rem .4rem; margin-right: .25rem; }

/* keep old admin-nav for any legacy uses */
.admin-nav { display: flex; gap: .5rem; flex-wrap: wrap; padding: .75rem 0; }
.admin-nav a { color: var(--muted); font-size: .85rem; border-bottom: 2px solid transparent; }
.admin-nav a:hover { color: var(--text); border-color: var(--red); }

/* wheel page */
.wheel-page { display: block; }
.wheel-wrap { position: relative; width: 760px; margin: 0 auto; }
#wheel { width: 100%; height: auto; display: block; filter: drop-shadow(0 6px 18px rgba(32,35,36,.25)); }
.pointer { position: absolute; top: -18px; left: 50%; translate: -50%; width: 48px; height: 48px; }
.spin-btn { position: absolute; inset: 0; margin: auto; width: 96px; height: 96px; border-radius: 50%; background: var(--red); color: #fff; font-weight: 700; border: 3px solid #fff; box-shadow: 0 0 0 3px var(--red); cursor: pointer; z-index: 2; }
.spin-btn:disabled { filter: grayscale(.6); cursor: default; }
.spin-status { display: flex; align-items: center; justify-content: center; gap: .5rem; margin: 1rem auto .25rem; color: var(--muted); font-size: .95rem; }
.pulse-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--red); display: inline-block; animation: pulse 1.6s ease-in-out infinite; }
.pulse-dot.busy { background: var(--text); }
@keyframes pulse { 0%, 100% { opacity: .3; transform: scale(.8); } 50% { opacity: 1; transform: scale(1.15); } }
.counterbar { text-align: center; margin: .75rem 0; font-size: 1.05rem; }
.counterbar strong { color: var(--red); }

/* display page */
.display-page { text-align: center; }
.display-head h1 { font-size: 2rem; margin-bottom: .25rem; }
.winner-tiles { display: flex; flex-wrap: wrap; justify-content: center; gap: 1rem; padding: 1rem; }
.winner-tile { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.25rem; min-width: 200px; box-shadow: 0 1px 3px rgba(20,24,30,.06); }
.winner-tile-name { font-weight: 700; color: var(--red); font-size: 1.2rem; }
.winner-tile-prize { margin: .25rem 0; }
.winner-tile-company { font-size: .8rem; }

/* modal */
.modal { position: fixed; inset: 0; background: rgba(30,33,38,.5); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal-card { background: var(--bg); border: 2px solid var(--red); border-radius: var(--radius); padding: 2rem; text-align: center; max-width: 420px; box-shadow: 0 12px 40px rgba(20,24,30,.18); }
.modal-card h2 { margin-top: 0; color: var(--red); }
.winner-name { font-size: 2rem; font-weight: 800; margin: .5rem 0; }
.winner-prize { font-size: 1.3rem; color: var(--red-2); }
.error { color: var(--danger); }
.danger-zone { border-color: rgba(200,16,46,.35); }
.danger-zone h2 { color: var(--danger); }
.flash { background: rgba(200,16,46,.08); border-color: rgba(200,16,46,.4); color: var(--red-dark); font-weight: 600; }
.hidden { display: none !important; }
.login-shell { max-width: 360px; margin: 3rem auto; }
.login-shell .card input { width: 100%; }
.grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(180px,1fr)); gap: 1rem; }
.grid .card h2 { margin: 0; font-size: 1.6rem; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
@media (max-width: 640px){ .row { grid-template-columns: 1fr; } }

/* community CTA funnel */
.cta-band { width: min(900px, 92%); margin: 2.5rem auto; }
.cta-glass {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(600px 240px at 85% -60px, rgba(200,16,46,.18), transparent 60%),
    linear-gradient(180deg, #ffffff 0%, #f4f5f7 100%);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2.5rem 2rem;
  text-align: center;
  box-shadow: 0 12px 40px rgba(20,24,30,.10);
}
.cta-eyebrow {
  display: inline-block;
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--red);
  background: rgba(200,16,46,.08);
  border: 1px solid rgba(200,16,46,.25);
  border-radius: 999px;
  padding: .3rem .85rem;
  margin-bottom: 1rem;
}
.cta-title { font-size: 1.9rem; line-height: 1.15; margin: 0 0 .5rem; }
.cta-sub { color: var(--muted); margin: 0 auto 1.75rem; max-width: 520px; }
.cta-steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1.75rem;
}
.cta-step {
  display: flex;
  gap: .75rem;
  text-align: left;
  background: #fff;
  border: 1px solid var(--silver);
  border-radius: 12px;
  padding: 1rem 1.1rem;
}
.cta-step strong { display: block; margin-bottom: .15rem; }
.cta-step p { margin: 0; color: var(--muted); font-size: .85rem; line-height: 1.4; }
.cta-step-num {
  flex: 0 0 30px;
  width: 30px; height: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--red); color: #fff;
  font-weight: 700; font-size: .95rem;
  border-radius: 50%;
}
.cta-btn { font-size: 1.05rem; padding: .8rem 1.9rem; }
.cta-note { margin: .9rem 0 0; font-size: .85rem; }
.quickconnect {
  display: flex; align-items: center; gap: 1.25rem;
  margin: 1.75rem auto 0; max-width: 560px;
  text-align: left; background: #fff;
  border: 1px solid var(--silver); border-radius: 14px; padding: 1rem 1.25rem;
}
.quickconnect-qr { flex: 0 0 auto; }
.quickconnect-qr .qr, .quickconnect-qr svg { width: 108px; height: 108px; display: block; }
.quickconnect-info h3 { margin: 0 0 .25rem; color: var(--red); }
.quickconnect-info p { margin: 0; color: var(--muted); font-size: .85rem; line-height: 1.4; }
.quickconnect a { color: var(--red); }
@media (max-width: 640px){
  .cta-steps { grid-template-columns: 1fr; }
  .cta-glass { padding: 1.75rem 1.25rem; }
  .cta-title { font-size: 1.5rem; }
  .quickconnect { flex-direction: column; text-align: center; }
}

/* ==========================================================================
   Responsive / adaptive UI — one design, mobile- and desktop-native.
   Breakpoints: >=1280 desktop-xl, 768–1279 desktop, 481–767 tablet,
   <=480 phone.
   ========================================================================== */

:root {
  --tap: 48px;               /* comfortable touch target */
  --shell-narrow: min(460px, 100%); /* centered form column on any screen */
}

html { -webkit-text-size-adjust: 100%; }
body {
  min-height: 100vh; min-height: 100dvh; /* dynamic viewport for mobile browsers */
  -webkit-tap-highlight-color: transparent;
}
button, a, input, select, textarea { -webkit-touch-callout: none; }
button, a { touch-action: manipulation; }

/* --- Layout container cushions on desktop, go full-bleed on phones --- */
.container, .cta-band { width: min(1200px, 100%); padding-left: 1rem; padding-right: 1rem; }
.wheel-page .container { display: flex; flex-direction: column; align-items: center; }
.wheel-page .cta-band { width: min(1100px, 100%); }

/* --- Forms: thumb-friendly fields, generous spacing --- */
input, select, textarea { min-height: 44px; font-size: 1rem; }
input[type="checkbox"], input[type="radio"] { min-height: 20px; width: 20px; height: 20px; }
button.btn, .btn { min-height: var(--tap); display: inline-flex; align-items: center; justify-content: center; }
.row { gap: .9rem; }

/* Form shell: a single centred column that reads like a native app card. */
.connect-shell { width: var(--connect-shell, min(500px, 100%)); margin: 0 auto; padding: 1rem; }
.connect-shell .card { padding: 1.4rem; }
.connect-shell form { display: flex; flex-direction: column; gap: .95rem; }
.connect-shell label { font-size: .92rem; }

/* --- Admin tables: card-stack on phones, real tables on desktop --- */
table.data-table thead { display: table-header-group; }
.data-table td, .data-table th { padding: .6rem .55rem; }

/* --- Wheel: responsive canvas so it never exceeds the viewport --- */
.wheel-wrap { width: min(760px, 92vw); }
#wheel { touch-action: none; } /* wheel is display-only; avoid gesture clobber */

/* Projector / big display page: fill the screen, celebration scale. */
.display-page { padding: 0; }
.display-page .display { display: grid; grid-template-rows: auto 1fr; min-height: 100vh; align-items: center; }
.display-page .display-head { padding: 1.5rem 1rem 0; }
.display-page .winner-tiles { width: 100%; padding: 1rem 2rem 3rem; }
.display-page .winner-tile { min-width: 260px; padding: 1.5rem 2rem; }
.display-page .winner-tile-name { font-size: 1.7rem; }
.display-page .winner-tile-prize { font-size: 1.2rem; }

/* Modal: centred sheet; full-width with big touch targets on phones. */
.modal-card { width: min(420px, 92vw); }
.modal-card .winner-name { font-size: 2.2rem; }

/* ==========================================================================
   PHONE  (<= 480px)
   ========================================================================== */
@media (max-width: 480px) {
  body { padding-bottom: env(safe-area-inset-bottom); }
  .header-inner { height: auto; min-height: 52px; padding: .5rem 0; flex-wrap: wrap; }
  .admin-nav { width: 100%; gap: .35rem .6rem; padding: .25rem 0 .5rem; }
  .admin-nav a { font-size: .8rem; }

  .topnav { order: 3; width: 100%; justify-content: center; gap: .25rem; padding-top: .5rem; }
  .nav-btn { font-size: .75rem; padding: .35rem .5rem; }
  .logo-sub { display: none; }
  .nav-group .nav-btn[aria-haspopup="true"] { padding-right: 1.25rem; }
  .nav-menu { position: fixed; top: auto; bottom: 0; left: 0; right: 0; min-width: auto; border-radius: 12px 12px 0 0; box-shadow: 0 -8px 24px rgba(20,24,30,.15); max-height: 60vh; overflow-y: auto; }
  .nav-group { width: 100%; }
  .nav-group .nav-btn { width: 100%; text-align: left; border-radius: 0; border-bottom: 1px solid var(--border); }
  .nav-group:last-child .nav-btn { border-bottom: none; }
  .nav-toggle { display: flex; align-items: center; justify-content: center; }
  .nav-toggle { order: 2; }
  .topnav.open { display: flex; flex-direction: column; }

  h1 { font-size: 1.5rem; }
  .card { padding: 1rem; }

  /* wheel page: wheel fills width, controls beneath */
  .wheel-page { justify-content: stretch; }
  .wheel-wrap { width: 100%; }
  #wheel { width: 100%; height: auto; }
  .counterbar { margin: .5rem 0; }
  .spin-status { font-size: .85rem; }
  .cta-band { margin: 1.5rem auto; }

  /* admin tables -> stacked cards */
  .data-table thead { display: none; }
  .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
  .data-table .card { border: none; padding: 0; }
  table.data-table tr {
    border: 1px solid var(--silver); border-radius: 10px; margin: 0 0 .75rem;
    padding: .4rem .6rem;
  }
  table.data-table td {
    border: none; padding: .28rem .2rem; display: flex; justify-content: space-between; gap: .5rem;
  }
  table.data-table td::before {
    content: attr(data-label); color: var(--muted); font-size: .72rem;
    text-transform: uppercase; letter-spacing: .04em; white-space: nowrap;
  }
  table.data-table td.num { flex-direction: column; align-items: flex-start; }

  .grid { grid-template-columns: 1fr 1fr; }
  .row { grid-template-columns: 1fr; }

  /* display page: full-screen projector look with roomy touch cards */
  .display-page .winner-tile { min-width: 0; width: 100%; }
  .display-page .winner-tile-name { font-size: 1.4rem; }

  .modal-card { padding: 1.5rem 1.25rem; }
  .modal-card .winner-name { font-size: 1.8rem; }
}

/* ---- Tablet (481–767): two-across grids, stacked admin tables off (>=569) ---- */
@media (min-width: 481px) and (max-width: 767px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
  .wheel-wrap { width: 88%; margin: 0 auto; }
}

/* ---- Desktop (>= 768px) ---- */
@media (min-width: 768px) {
  .container, .cta-band { width: min(1200px, 94%); }
  .connect-shell { --sid-shell: min(480px, 100%); }
  .connect-shell form { gap: 1.1rem; }
  .card { padding: 1.5rem; }

  /* wheel: stacked layout — nav, then wheel, then CTA */
  .wheel-page .container { display: block; }
  .wheel-page #wheel-ui { width: min(760px, 100%); margin: 0 auto 2rem; }
  .wheel-page .cta-band { width: min(900px, 100%); margin: 0 auto; }
  .display-page .winner-tiles { gap: 1.5rem; }
}

/* ---- XL desktop (>=1200px) ---- */
@media (min-width: 1200px) {
  .display-page .winner-tile-name { font-size: 2rem; }
}