/* ============================================================
   Design tokens — Rakeen Security Suite palette
   ============================================================ */
:root {
  --bg: #000000;
  --bg-radial: #0b1120;
  --surface: #161d36;       /* brand navy — modal card surface */
  --border: #2a3358;
  --border-soft: #1a2036;

  --text: #f5f6f8;
  --text-muted: #8b93ab;
  --text-faint: #545c78;

  --accent: #2f529f;        /* brand blue — pointer, focus, highlights */
  --accent-soft: #6884c2;

  --brand-black: #000000;
  --brand-white: #ffffff;

  --font-display: 'Space Grotesk', ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-body: 'Inter', ui-sans-serif, system-ui, -apple-system, sans-serif;

  --radius-lg: 20px;
  --radius-sm: 8px;

  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.65);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

/* ============================================================
   Reset & base
   ============================================================ */
* { box-sizing: border-box; }
html, body {
  height: 100%;
  margin: 0;
}
body {
  background: radial-gradient(120% 120% at 50% 0%, var(--bg-radial) 0%, var(--bg) 55%);
  color: var(--text);
  font-family: var(--font-body);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--font-display); margin: 0; }
p { margin: 0; }
button { font-family: inherit; }

::selection { background: var(--accent); color: var(--brand-white); }

:focus-visible {
  outline: 2px solid var(--accent-soft);
  outline-offset: 2px;
  border-radius: 6px;
}

/* faint ambient grid — signature background texture */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(var(--border-soft) 1px, transparent 1px),
    linear-gradient(90deg, var(--border-soft) 1px, transparent 1px);
  background-size: 48px 48px;
  opacity: 0.4;
  mask-image: radial-gradient(80% 60% at 50% 35%, black 0%, transparent 75%);
}

/* ============================================================
   Stage layout
   ============================================================ */
.stage {
  position: relative;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  z-index: 5;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.brand-mark {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: var(--brand-white);
}
.brand-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 16px;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions {
  display: flex;
  gap: 8px;
}

.icon-btn {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: color 0.15s var(--ease-out), border-color 0.15s var(--ease-out), transform 0.15s var(--ease-out);
}
.icon-btn:hover { color: var(--text); border-color: var(--accent); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn.is-active { color: var(--accent-soft); border-color: var(--accent); }

/* ============================================================
   Main / wheel
   ============================================================ */
.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  min-height: 0;
  padding: 0 24px 24px;
}

.wheel-wrap {
  position: relative;
  width: min(66vh, 64vw, 640px);
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
}

.wheel-glow {
  position: absolute;
  inset: -6%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(47, 82, 159, 0.28) 0%, transparent 70%);
  pointer-events: none;
  animation: breathe 4s ease-in-out infinite;
}
@keyframes breathe {
  0%, 100% { opacity: 0.55; transform: scale(1); }
  50% { opacity: 0.9; transform: scale(1.04); }
}

#wheelCanvas {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  box-shadow: var(--shadow-lg), 0 0 0 6px var(--surface), 0 0 0 7px var(--border);
}

.pointer {
  position: absolute;
  top: -2px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  z-index: 4;
  border-left: 16px solid transparent;
  border-right: 16px solid transparent;
  border-top: 26px solid var(--accent);
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.5));
}
.pointer::after {
  content: '';
  position: absolute;
  top: -26px;
  left: -6px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
}

.spin-hub {
  position: relative;
  z-index: 3;
  width: 22%;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  border: 3px solid var(--accent);
  cursor: pointer;
  background: var(--brand-black);
  color: var(--brand-white);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(13px, 1.6vw, 18px);
  letter-spacing: 0.06em;
  box-shadow: 0 8px 24px rgba(47, 82, 159, 0.45), inset 0 0 0 1px rgba(255, 255, 255, 0.06);
  transition: transform 0.15s var(--ease-out), box-shadow 0.15s var(--ease-out), border-color 0.15s var(--ease-out);
  animation: pulse-invite 2.4s ease-in-out infinite;
}
.spin-hub:hover { transform: scale(1.05); border-color: var(--accent-soft); }
.spin-hub:active { transform: scale(0.96); }
.spin-hub:disabled {
  cursor: default;
  animation: none;
  filter: saturate(0.5) brightness(0.8);
  transform: none;
}
@keyframes pulse-invite {
  0%, 100% { box-shadow: 0 8px 24px rgba(47, 82, 159, 0.45), inset 0 0 0 1px rgba(255,255,255,0.06); }
  50% { box-shadow: 0 8px 34px rgba(47, 82, 159, 0.8), inset 0 0 0 1px rgba(255,255,255,0.1); }
}

/* ============================================================
   Winner modal
   ============================================================ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  z-index: 30;
  opacity: 1;
  transition: opacity 0.25s var(--ease-out);
}
.modal-backdrop.hidden {
  opacity: 0;
  pointer-events: none;
}
.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 44px;
  text-align: center;
  max-width: 90vw;
  width: 420px;
  box-shadow: var(--shadow-lg);
  transform: scale(0.85) translateY(10px);
  transition: transform 0.35s var(--ease-out);
}
.modal-backdrop:not(.hidden) .modal-card { transform: scale(1) translateY(0); }
.modal-icon { font-size: 40px; margin-bottom: 6px; }
.modal-eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.modal-prize {
  font-size: clamp(24px, 5vw, 34px);
  line-height: 1.2;
  margin-bottom: 26px;
  word-break: break-word;
  background: linear-gradient(135deg, var(--text) 30%, var(--accent-soft) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.modal-backdrop.is-non-win .modal-prize {
  background: none;
  -webkit-text-fill-color: currentColor;
  color: var(--text-muted);
}

.btn-primary {
  background: var(--accent);
  color: var(--brand-white);
  padding: 12px 28px;
  font-size: 14px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 600;
  transition: transform 0.12s var(--ease-out), filter 0.12s var(--ease-out);
}
.btn-primary:hover { filter: brightness(1.15); }
.btn-primary:active { transform: scale(0.97); }

.confetti-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 25;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 720px) {
  .brand-name { font-size: 14px; }
  .wheel-wrap { width: min(70vh, 88vw, 640px); }
  .topbar { padding: 14px 16px; }
}

/* ============================================================
   Reduced motion
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  .wheel-glow, .spin-hub { animation: none; }
  * { transition-duration: 0.01ms !important; }
}
