*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --gold: #ffd700;
  --gold-dark: #b8860b;
  --bg-dark: #05050f;
  --bg-mid: #0d0d24;
  --text: #e8e8f0;
  --panel-bg: rgba(10, 10, 30, 0.95);
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg-dark);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  user-select: none;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}

#game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#top-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  text-align: center;
  padding: 16px;
  pointer-events: none;
  z-index: 10;
}

#title {
  font-family: 'Cinzel', serif;
  font-weight: 900;
  font-size: clamp(18px, 3.5vw, 42px);
  letter-spacing: 0.12em;
  background: linear-gradient(180deg, #fff5c0 0%, #ffd700 40%, #b8860b 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: none;
  filter: drop-shadow(0 2px 8px rgba(255, 215, 0, 0.5));
}

#free-spins-indicator {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  padding: 6px 20px;
  background: linear-gradient(135deg, rgba(255,215,0,0.3), rgba(184,134,11,0.3));
  border: 1px solid var(--gold);
  border-radius: 20px;
  animation: fsPulse 1.5s ease-in-out infinite;
}

#fs-label {
  font-family: 'Cinzel', serif;
  font-weight: 700;
  font-size: 14px;
  color: var(--gold);
  letter-spacing: 0.1em;
}

#fs-count {
  font-family: 'Cinzel', serif;
  font-weight: 900;
  font-size: 22px;
  color: #fff;
}

@keyframes fsPulse {
  0%, 100% { box-shadow: 0 0 10px rgba(255,215,0,0.3); }
  50% { box-shadow: 0 0 25px rgba(255,215,0,0.6); }
}

#bottom-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(10px, 2vw, 32px);
  padding: 12px clamp(8px, 2vw, 32px) max(12px, env(safe-area-inset-bottom));
  background: linear-gradient(transparent, rgba(0,0,0,0.9));
  z-index: 10;
  flex-wrap: wrap;
}

.info-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 80px;
}

.info-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  opacity: 0.7;
  text-transform: uppercase;
}

.info-value {
  font-size: clamp(16px, 2vw, 22px);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.info-value.gold {
  color: var(--gold);
}

.bet-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.bet-controls button {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.3);
  background: rgba(255,255,255,0.1);
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  line-height: 1;
}

.bet-controls button:hover {
  background: rgba(255,255,255,0.2);
}

#btn-spin {
  width: clamp(80px, 12vw, 120px);
  height: clamp(80px, 12vw, 120px);
  border-radius: 50%;
  border: 3px solid var(--gold);
  background: linear-gradient(180deg, #ffd700 0%, #b8860b 100%);
  color: var(--bg-dark);
  font-family: 'Cinzel', serif;
  font-weight: 900;
  font-size: clamp(14px, 2vw, 20px);
  letter-spacing: 0.1em;
  cursor: pointer;
  box-shadow: 0 4px 30px rgba(255,215,0,0.4), inset 0 -2px 8px rgba(0,0,0,0.2);
  transition: transform 0.1s, box-shadow 0.2s;
  position: relative;
  flex-shrink: 0;
}

#btn-spin:hover:not(:disabled) {
  transform: scale(1.06);
  box-shadow: 0 6px 40px rgba(255,215,0,0.6), inset 0 -2px 8px rgba(0,0,0,0.2);
}

#btn-spin:active:not(:disabled) {
  transform: scale(0.97);
}

#btn-spin:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  filter: saturate(0.5);
}

#btn-config {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.25);
  background: rgba(255,255,255,0.08);
  color: #ccc;
  font-size: 20px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

#btn-config:hover {
  background: rgba(255,215,0,0.15);
  color: var(--gold);
}

/* Win overlay */
#win-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  pointer-events: none;
}

#win-amount {
  font-family: 'Cinzel', serif;
  font-weight: 900;
  font-size: clamp(40px, 8vw, 80px);
  color: #fff;
  text-shadow: 0 0 20px var(--gold), 0 0 60px rgba(255,215,0,0.5);
  animation: winPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes winPop {
  0% { transform: scale(0); opacity: 0; }
  60% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* Config modal */
#config-modal {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
}

#config-inner {
  width: min(90%, 600px);
  max-height: 85vh;
  background: var(--panel-bg);
  border: 1px solid rgba(255,215,0,0.25);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#config-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

#config-header h2 {
  font-family: 'Cinzel', serif;
  font-size: 18px;
  color: var(--gold);
}

#btn-close-config {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.1);
  color: #ccc;
  font-size: 16px;
  cursor: pointer;
}

#config-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

#config-quick h3 {
  font-size: 14px;
  margin-bottom: 12px;
  opacity: 0.7;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.quick-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.quick-row label {
  width: 200px;
  font-size: 13px;
  flex-shrink: 0;
}

.quick-row input[type="range"] {
  flex: 1;
  accent-color: var(--gold);
  height: 6px;
}

.quick-row span {
  width: 60px;
  text-align: right;
  font-size: 13px;
  font-weight: 600;
  color: var(--gold);
}

.quick-row select {
  flex: 1;
  padding: 6px 10px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 6px;
  color: #fff;
  font-size: 13px;
}

#config-advanced {
  margin-top: 16px;
}

#config-advanced summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--gold);
  opacity: 0.8;
}

#prob-json {
  width: 100%;
  height: 260px;
  margin-top: 10px;
  padding: 12px;
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 12px;
  line-height: 1.5;
  background: rgba(0,0,0,0.4);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  color: #d0d0d0;
  resize: vertical;
  tab-size: 2;
}

#config-footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 12px 20px;
  border-top: 1px solid rgba(255,255,255,0.1);
}

#config-footer button {
  padding: 8px 20px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: background 0.15s;
}

#btn-reset-config {
  background: rgba(255,255,255,0.1);
  color: #ccc;
}

#btn-reset-config:hover {
  background: rgba(255,255,255,0.18);
}

#btn-apply-config {
  background: linear-gradient(180deg, var(--gold), var(--gold-dark));
  color: var(--bg-dark);
}

#btn-apply-config:hover {
  filter: brightness(1.1);
}

.hidden {
  display: none !important;
}

@media (max-width: 600px) {
  #bottom-bar {
    gap: 8px;
    padding: 8px 8px 12px;
  }
  .info-cell {
    min-width: 60px;
  }
}
