/* =============================================
   SPINWIN SLOTS — Casino Royale Edition
   Deep Purple + Gold | Full Screen | No Scroll
   ============================================= */

:root {
  --purple-deep:   #0d0014;
  --purple-mid:    #1a0030;
  --purple-bright: #6a00b8;
  --purple-glow:   #9b30ff;
  --gold:          #ffd700;
  --gold-light:    #ffe566;
  --gold-dark:     #b8960c;
  --text-primary:  #f5e6ff;
  --text-muted:    #7a5a99;

  --top-bar-h:    clamp(54px, 8vh, 80px);
  --bottom-bar-h: clamp(55px, 8vh, 75px);
  --slot-gap:     clamp(5px, 1vw, 12px);
  --radius:       14px;

  --font-display: 'Cinzel', serif;
  --font-ui:      'Rajdhani', sans-serif;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--purple-deep);
}

/* ── Particle canvas ── */
#particles {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

/* ── Flash overlay ── */
#flash-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
  opacity: 0;
  background: radial-gradient(ellipse at center, rgba(255,215,0,0.45) 0%, transparent 70%);
  transition: opacity 0.08s ease;
}
#flash-overlay.active { opacity: 1; }

/* ── App shell ── */
#app {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Top bar ── */
#top-bar {
  height: var(--top-bar-h);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(12px, 3vw, 36px);
  background: linear-gradient(180deg, rgba(13,0,20,0.98) 0%, rgba(13,0,20,0.6) 100%);
  border-bottom: 1px solid rgba(255,215,0,0.15);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  font-size: clamp(1.2rem, 3vw, 2rem);
  color: var(--gold);
  filter: drop-shadow(0 0 8px rgba(255,215,0,0.7));
  animation: crown-pulse 3s ease-in-out infinite;
}

.brand-title {
  font-family: var(--font-display);
  font-size: clamp(1rem, 2.5vw, 1.8rem);
  font-weight: 900;
  color: var(--text-primary);
  letter-spacing: 0.05em;
  line-height: 1;
}

.brand-title em {
  font-style: normal;
  color: var(--gold);
  text-shadow: 0 0 18px rgba(255,215,0,0.6);
}

/* ── Chips ── */
.balance-chip,
.stat-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,215,0,0.07);
  border: 1px solid rgba(255,215,0,0.25);
  border-radius: 50px;
  padding: 6px 16px;
}

.stat-chip { justify-self: start; }

.chip-label {
  font-family: var(--font-ui);
  font-size: clamp(0.55rem, 1.3vw, 0.7rem);
  font-weight: 700;
  letter-spacing: 0.2em;
  color: var(--text-muted);
  text-transform: uppercase;
}

.chip-value {
  font-family: var(--font-display);
  font-size: clamp(1rem, 2.5vw, 1.5rem);
  font-weight: 700;
  color: var(--gold);
  text-shadow: 0 0 12px rgba(255,215,0,0.5);
  min-width: 3ch;
  text-align: center;
  transition: transform 0.15s ease, color 0.2s ease;
}

.chip-value.bump {
  transform: scale(1.25);
  color: var(--gold-light);
}

.chip-value.gold { color: var(--gold); }

.chip-unit {
  font-family: var(--font-ui);
  font-size: clamp(0.5rem, 1.2vw, 0.65rem);
  color: var(--text-muted);
  letter-spacing: 0.1em;
}

/* ── Game area ── */
#game-area {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: clamp(2px, 0.5vh, 6px) clamp(8px, 2vw, 20px);
  gap: 2px;
}

/* ── Slot grid ── */
#slot-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: var(--slot-gap);
  width: min(
    100%,
    calc((100vh - var(--top-bar-h) - var(--bottom-bar-h) - 60px) * 5 / 3)
  );
  aspect-ratio: 5 / 3;
  max-width: 100%;
  max-height: calc(100vh - var(--top-bar-h) - var(--bottom-bar-h) - 60px);
}

/* ── Individual slot ── */
.slot {
  background: radial-gradient(ellipse at 30% 30%, rgba(106,0,184,0.35) 0%, rgba(13,0,20,0.95) 100%);
  border: 2px solid rgba(255,215,0,0.18);
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  will-change: transform;
}

.slot::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.05) 0%, transparent 50%);
  pointer-events: none;
  border-radius: inherit;
}

.slot img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: calc(var(--radius) - 2px);
}

.slot.spinning {
  border-color: rgba(155,48,255,0.6);
  box-shadow: 0 0 20px rgba(155,48,255,0.35), inset 0 0 20px rgba(106,0,184,0.2);
  animation: slot-spin 0.45s cubic-bezier(0.23, 1, 0.32, 1) forwards;
}

.slot.winner {
  border-color: var(--gold);
  box-shadow:
    0 0 0 2px var(--gold),
    0 0 24px rgba(255,215,0,0.6),
    0 0 48px rgba(255,215,0,0.25),
    inset 0 0 16px rgba(255,215,0,0.1);
  animation: winner-throb 0.6s ease-in-out infinite alternate;
}

@keyframes slot-spin {
  0%   { transform: rotateY(0deg) scaleY(1); }
  25%  { transform: rotateY(90deg) scaleY(0.92); }
  75%  { transform: rotateY(270deg) scaleY(0.92); }
  100% { transform: rotateY(360deg) scaleY(1); }
}

@keyframes winner-throb {
  from { box-shadow: 0 0 0 2px var(--gold), 0 0 20px rgba(255,215,0,0.5), inset 0 0 10px rgba(255,215,0,0.08); }
  to   { box-shadow: 0 0 0 3px var(--gold-light), 0 0 40px rgba(255,215,0,0.75), inset 0 0 20px rgba(255,215,0,0.15); }
}

@keyframes crown-pulse {
  0%, 100% { filter: drop-shadow(0 0 6px rgba(255,215,0,0.6)); }
  50%       { filter: drop-shadow(0 0 18px rgba(255,215,0,0.95)); }
}

/* ── Win row label ── */
#win-row-label {
  font-family: var(--font-ui);
  font-size: clamp(0.75rem, 1.8vw, 1rem);
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold);
  text-shadow: 0 0 12px rgba(255,215,0,0.6);
  min-height: 1.4em;
  text-align: center;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

#win-row-label.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ── Bottom bar ── */
#bottom-bar {
  height: var(--bottom-bar-h);
  flex-shrink: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 clamp(12px, 3vw, 36px);
  background: linear-gradient(0deg, rgba(13,0,20,0.98) 0%, rgba(13,0,20,0.6) 100%);
  border-top: 1px solid rgba(255,215,0,0.15);
}

/* WIN chip — absolute left */
#bottom-bar .stat-chip {
  position: absolute;
  left: clamp(12px, 3vw, 36px);
}

/* Result — absolute right */
#result {
  position: absolute;
  right: clamp(12px, 3vw, 36px);
  font-family: var(--font-ui);
  font-size: clamp(0.7rem, 1.8vw, 1rem);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-align: right;
  color: var(--text-muted);
  max-width: 200px;
  opacity: 0;
  transform: translateX(6px);
  transition: opacity 0.3s ease, transform 0.3s ease, color 0.3s ease;
}

#result.visible        { opacity: 1; transform: translateX(0); }
#result.win            { color: var(--gold);  text-shadow: 0 0 12px rgba(255,215,0,0.5); }
#result.lose           { color: var(--text-muted); }
#result.gameover       { color: #ff4477;      text-shadow: 0 0 12px rgba(255,68,119,0.5); }

/* ── Spin button — matches slot-grid width ── */
#spinBtn {
  /* Same width constraint as #slot-grid */
  width: min(
    100%,
    calc((100vh - var(--top-bar-h) - var(--bottom-bar-h) - 60px) * 5 / 3)
  );
  max-width: 100%;
  padding: clamp(4px, 0.7vh, 8px) 0;

  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;

  background: linear-gradient(145deg, #7a00cc 0%, #4a0080 60%, #2a0050 100%);
  border: 2px solid rgba(255,215,0,0.5);
  border-radius: 60px;
  cursor: pointer;
  color: var(--gold);
  font-family: var(--font-display);
  letter-spacing: 0.12em;
  outline: none;
  position: relative;
  overflow: hidden;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  box-shadow:
    0 0 30px rgba(106,0,184,0.5),
    0 4px 20px rgba(0,0,0,0.5),
    inset 0 1px 0 rgba(255,255,255,0.1);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

#spinBtn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,215,0,0.12) 0%, transparent 60%);
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

#spinBtn:hover:not(:disabled)::before { opacity: 1; }

#spinBtn:hover:not(:disabled) {
  transform: translateY(-3px) scale(1.03);
  border-color: var(--gold);
  box-shadow:
    0 0 50px rgba(106,0,184,0.7),
    0 0 20px rgba(255,215,0,0.35),
    0 8px 30px rgba(0,0,0,0.6),
    inset 0 1px 0 rgba(255,255,255,0.15);
}

#spinBtn:active:not(:disabled) {
  transform: translateY(0) scale(0.97);
  box-shadow: 0 0 20px rgba(106,0,184,0.4);
}

#spinBtn:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 4px;
}

#spinBtn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-glyph {
  font-size: clamp(1rem, 2.5vw, 1.4rem);
  line-height: 1;
  transition: transform 0.5s ease;
}

#spinBtn:hover:not(:disabled) .btn-glyph { transform: rotate(180deg); }

.btn-text {
  font-size: clamp(1rem, 2.5vw, 1.5rem);
  font-weight: 900;
  line-height: 1;
}

.btn-hint {
  font-family: var(--font-ui);
  font-size: clamp(0.5rem, 1.2vw, 0.65rem);
  color: rgba(255,215,0,0.45);
  letter-spacing: 0.1em;
  font-weight: 400;
}

/* ── Footer credit ── */
#footer-credit {
  position: fixed;
  bottom: 8px;
  right: 12px;
  font-family: var(--font-ui);
  font-size: 0.6rem;
  color: rgba(122,90,153,0.35);
  z-index: 2;
  white-space: nowrap;
  pointer-events: none;
}

#footer-credit a {
  color: rgba(255,215,0,0.3);
  text-decoration: none;
  pointer-events: all;
  transition: color 0.2s ease;
}

#footer-credit a:hover { color: var(--gold); }

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  .slot.spinning, .slot.winner, .brand-icon { animation: none; }
  .slot.winner { box-shadow: 0 0 0 3px var(--gold); }
  #spinBtn, #result, #win-row-label { transition: none; }
  .chip-value { transition: none; }
}