/* ═══════════════════════════════════════════════════════════
   NumberSnipe — Mobile-First Stylesheet
   All design tokens, components, animations, utilities
═══════════════════════════════════════════════════════════ */

/* ── Design tokens ── */
:root {
  --bg:     #05050F;
  --card:   #0D0D2A;
  --cyan:   #00F5FF;
  --pink:   #FF006E;
  --gold:   #FFD700;
  --neon:   #39FF14;
  --purple: #BF5AF2;
  --border: rgba(0,245,255,0.15);
  --text:   #D0D8FF;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  overflow-x: hidden;
  /* Safe-area support for notched phones */
  padding-bottom: env(safe-area-inset-bottom);
}

/* ── Grid background ── */
.grid-bg {
  background-image:
    linear-gradient(rgba(0,245,255,0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,245,255,0.025) 1px, transparent 1px);
  background-size: 50px 50px;
}

/* ── Glow helpers ── */
.glow-cyan  { box-shadow: 0 0 24px rgba(0,245,255,.4), 0 0 50px rgba(0,245,255,.15); }
.glow-pink  { box-shadow: 0 0 24px rgba(255,0,110,.4), 0 0 50px rgba(255,0,110,.15); }
.glow-gold  { box-shadow: 0 0 24px rgba(255,215,0,.4), 0 0 50px rgba(255,215,0,.15); }
.text-glow-cyan { text-shadow: 0 0 14px rgba(0,245,255,.8), 0 0 30px rgba(0,245,255,.3); }
.text-glow-pink { text-shadow: 0 0 14px rgba(255,0,110,.8), 0 0 30px rgba(255,0,110,.3); }
.text-glow-gold { text-shadow: 0 0 14px rgba(255,215,0,.8), 0 0 30px rgba(255,215,0,.3); }

/* ══════════════════════════════════════════════════════════
   SCREENS
══════════════════════════════════════════════════════════ */
.screen {
  display: none;
  min-height: 100dvh;   /* dvh handles mobile browser chrome */
  flex-direction: column;
}
.screen.active { display: flex; }

/* ══════════════════════════════════════════════════════════
   CARDS  (mobile: tighter padding, larger on desktop)
══════════════════════════════════════════════════════════ */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
}
.card-glow { border-color: rgba(0,245,255,.35); }

@media (min-width: 480px) {
  .card { padding: 22px; border-radius: 18px; }
}
@media (min-width: 640px) {
  .card { padding: 24px; }
}

/* ══════════════════════════════════════════════════════════
   BUTTONS  (min 48 px touch target on all sizes)
══════════════════════════════════════════════════════════ */
.btn {
  font-family: 'Orbitron', monospace;
  font-weight: 700;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: box-shadow .25s, transform .25s, background .25s;
  text-transform: uppercase;
  letter-spacing: .1em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  min-height: 48px;
}
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none !important; }
.btn:active:not(:disabled) { transform: scale(.96); }

/* Colours */
.btn-cyan  { background: linear-gradient(135deg,#00F5FF,#0088FF); color: #000; }
.btn-pink  { background: linear-gradient(135deg,#FF006E,#FF4500); color: #fff; }
.btn-neon  { background: linear-gradient(135deg,#39FF14,#00CC00); color: #000; }
.btn-gold  { background: linear-gradient(135deg,#FFD700,#FFA500); color: #000; }
.btn-ghost { background: transparent; color: var(--cyan); border: 2px solid rgba(0,245,255,.4); }

/* Hover (pointer devices only — no hover flicker on touch) */
@media (hover: hover) {
  .btn-cyan:not(:disabled):hover  { box-shadow: 0 0 28px rgba(0,245,255,.7); transform: translateY(-2px); }
  .btn-pink:not(:disabled):hover  { box-shadow: 0 0 28px rgba(255,0,110,.7); transform: translateY(-2px); }
  .btn-neon:not(:disabled):hover  { box-shadow: 0 0 28px rgba(57,255,20,.7); transform: translateY(-2px); }
  .btn-gold:not(:disabled):hover  { box-shadow: 0 0 28px rgba(255,215,0,.7); transform: translateY(-2px); }
  .btn-ghost:not(:disabled):hover { background: rgba(0,245,255,.08); border-color: var(--cyan); box-shadow: 0 0 18px rgba(0,245,255,.3); }
}

/* Sizes */
.btn-sm { padding: 10px 16px; font-size: 10px; min-height: 40px; }
.btn-md { padding: 12px 22px; font-size: 12px; }
.btn-lg { padding: 14px 28px; font-size: 13px; }
.btn-xl { padding: 16px 36px; font-size: 14px; }
.btn-full { width: 100%; }

@media (min-width: 480px) {
  .btn-lg { padding: 15px 32px; font-size: 15px; }
  .btn-xl { padding: 18px 40px; font-size: 16px; }
}

/* ══════════════════════════════════════════════════════════
   INPUTS  (16 px minimum to prevent iOS auto-zoom)
══════════════════════════════════════════════════════════ */
.inp {
  background: rgba(0,0,0,.45);
  border: 1.5px solid rgba(0,245,255,.2);
  border-radius: 10px;
  color: var(--text);
  padding: 12px 14px;
  width: 100%;
  font-family: 'DM Sans', sans-serif;
  font-size: 16px;      /* prevents iOS zoom on focus */
  outline: none;
  transition: border-color .25s, box-shadow .25s;
  -webkit-appearance: none;
}
.inp:focus       { border-color: var(--cyan); box-shadow: 0 0 14px rgba(0,245,255,.25); }
.inp::placeholder { color: rgba(180,190,255,.3); }
.inp-center { text-align: center; }
.inp-orb    { font-family: 'Orbitron', monospace; font-size: 20px; letter-spacing: .15em; }

@media (min-width: 480px) {
  .inp-orb { font-size: 22px; }
}

/* ── Slider ── */
.slider {
  -webkit-appearance: none;
  width: 100%; height: 8px;
  border-radius: 4px; outline: none;
  background: linear-gradient(to right, var(--cyan), var(--pink));
  cursor: pointer;
  touch-action: manipulation;
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 34px; height: 34px;       /* bigger for touch */
  border-radius: 50%;
  background: var(--gold);
  cursor: pointer;
  box-shadow: 0 0 16px rgba(255,215,0,.7);
  transition: transform .2s;
}
@media (hover: hover) {
  .slider::-webkit-slider-thumb:hover { transform: scale(1.3); }
}
.slider::-moz-range-thumb {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--gold); cursor: pointer; border: none;
  box-shadow: 0 0 16px rgba(255,215,0,.7);
}

/* ══════════════════════════════════════════════════════════
   BIG NUMBER DISPLAY
══════════════════════════════════════════════════════════ */
.big-num {
  font-family: 'Orbitron', monospace;
  font-size: clamp(52px, 14vw, 96px);
  font-weight: 900;
  background: linear-gradient(135deg, var(--cyan), var(--pink));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
  display: block;
}
.big-num-gold {
  font-family: 'Orbitron', monospace;
  font-size: clamp(52px, 14vw, 96px);
  font-weight: 900;
  background: linear-gradient(135deg, #FFD700, #FF8C00);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
}

/* ══════════════════════════════════════════════════════════
   AVATAR
══════════════════════════════════════════════════════════ */
.avatar {
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Orbitron', monospace;
  font-weight: 900;
  flex-shrink: 0;
}

/* ══════════════════════════════════════════════════════════
   MODAL  (sheet-style on mobile, centred box on desktop)
══════════════════════════════════════════════════════════ */
.modal-bg {
  position: fixed; inset: 0;
  background: rgba(0,0,8,.88);
  backdrop-filter: blur(10px);
  z-index: 500;
  display: flex;
  align-items: flex-end;    /* sheet anchors to bottom on mobile */
  justify-content: center;
  padding: 0;
}
.modal-bg.hide { display: none; }
.modal-box {
  background: #0A0A22;
  border: 1.5px solid rgba(0,245,255,.25);
  border-radius: 24px 24px 0 0;
  padding: 28px 20px 32px;
  padding-bottom: max(32px, env(safe-area-inset-bottom));
  width: 100%;
  max-height: 92dvh;
  overflow-y: auto;
  animation: modalSlideUp .35s cubic-bezier(.36,.07,.19,.97) forwards;
}

@media (min-width: 540px) {
  .modal-bg { align-items: center; padding: 16px; }
  .modal-box {
    border-radius: 24px;
    padding: 36px;
    max-width: 440px;
    animation: bounceIn .45s cubic-bezier(.36,.07,.19,.97) forwards;
  }
}

/* ══════════════════════════════════════════════════════════
   TOAST  (bottom-centre on mobile, top-right on desktop)
══════════════════════════════════════════════════════════ */
#toast {
  position: fixed;
  bottom: 24px; left: 50%;
  z-index: 9999;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px; font-weight: 600;
  padding: 12px 20px;
  border-radius: 10px;
  background: #0D0D2A;
  border: 1.5px solid rgba(0,245,255,.3);
  color: var(--cyan);
  transform: translateX(-50%) translateY(120px);
  transition: transform .35s cubic-bezier(.34,1.56,.64,1);
  max-width: calc(100vw - 32px);
  text-align: center;
  pointer-events: none;
  bottom: max(24px, env(safe-area-inset-bottom));
}
#toast.show { transform: translateX(-50%) translateY(0); }
#toast.error   { border-color: rgba(255,0,110,.4);  color: var(--pink); }
#toast.success { border-color: rgba(57,255,20,.4);  color: var(--neon); }

@media (min-width: 640px) {
  #toast {
    bottom: auto; left: auto;
    top: 20px; right: 20px;
    transform: translateX(140%);
    max-width: 300px;
    text-align: left;
  }
  #toast.show { transform: translateX(0); }
}

/* ── Particle canvas ── */
#particles { position: fixed; inset: 0; pointer-events: none; z-index: 0; }

/* ══════════════════════════════════════════════════════════
   ANIMATIONS
══════════════════════════════════════════════════════════ */
@keyframes float     { 0%,100% { transform:translateY(0) }      50% { transform:translateY(-12px) } }
@keyframes spinSlow  { to { transform: rotate(360deg); } }
@keyframes slideUp   { from { opacity:0; transform:translateY(24px) } to { opacity:1; transform:translateY(0) } }
@keyframes fadeIn    { from { opacity:0 } to { opacity:1 } }
@keyframes bounceIn  { 0% { transform:scale(.2); opacity:0 } 50% { transform:scale(1.08); opacity:1 } 75% { transform:scale(.96) } 100% { transform:scale(1); opacity:1 } }
@keyframes modalSlideUp { from { transform:translateY(100%) } to { transform:translateY(0) } }
@keyframes pulseGlow { 0%,100% { box-shadow:0 0 10px rgba(0,245,255,.2) } 50% { box-shadow:0 0 30px rgba(0,245,255,.7), 0 0 60px rgba(0,245,255,.2) } }
@keyframes borderPulse { 0%,100% { border-color:rgba(0,245,255,.2) } 50% { border-color:rgba(0,245,255,.8) } }
@keyframes scanLine  { 0% { transform:translateY(-100%) } 100% { transform:translateY(100vh) } }
@keyframes coinFly   { 0% { transform:translateY(0) scale(1) rotate(0deg); opacity:1 } 100% { transform:translateY(-100px) scale(.4) rotate(360deg); opacity:0 } }
@keyframes resultPop { 0% { transform:scale(.5) rotate(-10deg); opacity:0 } 60% { transform:scale(1.15) rotate(3deg); opacity:1 } 100% { transform:scale(1) rotate(0) } }
@keyframes shake     { 0%,100% { transform:translateX(0) } 20% { transform:translateX(-8px) } 40% { transform:translateX(8px) } 60% { transform:translateX(-5px) } 80% { transform:translateX(5px) } }
@keyframes ripple    { 0% { transform:scale(.5); opacity:.8 } 100% { transform:scale(2.5); opacity:0 } }
@keyframes historySlide { from { opacity:0; transform:translateX(-16px) } to { opacity:1; transform:translateX(0) } }
@keyframes dot       { 0%,80%,100% { opacity:.2 } 40% { opacity:1 } }

.anim-float         { animation: float 3s ease-in-out infinite; }
.anim-float-d1      { animation: float 3.5s ease-in-out infinite .5s; }
.anim-float-d2      { animation: float 4s ease-in-out infinite 1s; }
.anim-spin          { animation: spinSlow 8s linear infinite; }
.anim-spin-rev      { animation: spinSlow 6s linear infinite reverse; }
.anim-slide-up      { animation: slideUp .5s ease forwards; }
.anim-bounce-in     { animation: bounceIn .5s ease forwards; }
.anim-pulse-glow    { animation: pulseGlow 2.5s ease-in-out infinite; }
.anim-border-pulse  { animation: borderPulse 2s ease-in-out infinite; }
.anim-shake         { animation: shake .4s ease; }

/* ── Scrollbar ── */
::-webkit-scrollbar          { width: 4px; }
::-webkit-scrollbar-track    { background: #0D0D2A; }
::-webkit-scrollbar-thumb    { background: rgba(0,245,255,.3); border-radius: 3px; }

/* ══════════════════════════════════════════════════════════
   REUSABLE COMPONENTS
══════════════════════════════════════════════════════════ */

/* Range badge / pill */
.range-pill {
  display: inline-flex; align-items: center;
  background: linear-gradient(135deg,rgba(0,245,255,.1),rgba(255,0,110,.1));
  border: 1px solid rgba(0,245,255,.25);
  border-radius: 100px;
  padding: 4px 12px;
  font-family: 'Orbitron', monospace;
  font-size: 12px;
  color: var(--cyan);
  white-space: nowrap;
}

/* Result icon pop */
.result-icon {
  font-size: 64px;
  animation: resultPop .5s cubic-bezier(.36,.07,.19,.97) forwards;
}

/* Ripple */
.ripple-effect {
  position: absolute; border-radius: 50%;
  border: 2px solid var(--cyan);
  width: 60px; height: 60px;
  pointer-events: none;
  animation: ripple 1s ease-out forwards;
}

/* Coin fly */
.coin-fly {
  position: fixed; pointer-events: none; z-index: 9998;
  font-size: 28px;
  animation: coinFly 1.4s ease-out forwards;
}

/* Loading dots */
.dots span                   { animation: dot 1.4s infinite both; }
.dots span:nth-child(2)      { animation-delay: .2s; }
.dots span:nth-child(3)      { animation-delay: .4s; }

/* Scan-line overlay */
.scan-overlay { position: relative; }
.scan-overlay::after {
  content: '';
  position: absolute; top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(to bottom, transparent, rgba(0,245,255,.08), transparent);
  animation: scanLine 4s linear infinite;
  pointer-events: none;
  border-radius: inherit;
}

/* Guess history row */
.history-item { animation: historySlide .3s ease forwards; }

/* Player ready state */
.player-ready { border-color: rgba(57,255,20,.4) !important; }
.player-ready .ready-dot { background: var(--neon) !important; box-shadow: 0 0 8px var(--neon); }

/* Hot/cold bar */
.heatbar { height: 6px; border-radius: 3px; transition: width .6s ease; }

/* Back button */
.back-btn {
  display: inline-flex; align-items: center; gap: 6px;
  color: rgba(180,190,255,.5); font-size: 13px;
  margin-bottom: 18px; cursor: pointer; transition: color .2s;
  background: none; border: none;
  font-family: 'DM Sans', sans-serif;
  -webkit-tap-highlight-color: transparent;
  min-height: 44px;
  padding: 4px 0;
}
.back-btn:hover { color: var(--cyan); }

/* Field label */
.field-label {
  display: block;
  font-family: 'Orbitron', monospace;
  font-size: 10px;
  letter-spacing: .12em;
  opacity: .5;
  margin-bottom: 8px;
}

/* ══════════════════════════════════════════════════════════
   SCREEN-SPECIFIC OVERRIDES
══════════════════════════════════════════════════════════ */

/* Home screen text scaling */
#s-home h1 { font-size: clamp(36px, 9vw, 72px); }

/* Game topbar — wrap on tiny screens */
#game-topbar {
  flex-wrap: wrap;
  gap: 6px;
  min-height: 52px;
}

/* Scoreboard / history scroll */
#g-history { max-height: 44vh; overflow-y: auto; -webkit-overflow-scrolling: touch; }

/* Lobby player list scroll */
#lob-players { overflow-y: auto; -webkit-overflow-scrolling: touch; }

/* Pick/guess input container scroll */
.flex-1.overflow-y-auto { -webkit-overflow-scrolling: touch; }

/* Config warning banner */
.config-banner {
  position: fixed; bottom: max(16px, env(safe-area-inset-bottom)); left: 50%;
  transform: translateX(-50%);
  background: #1a0a2a;
  border: 1px solid rgba(255,0,110,.4);
  border-radius: 10px;
  padding: 12px 18px;
  text-align: center; font-size: 13px; z-index: 100;
  width: calc(100% - 32px); max-width: 340px;
}
