* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #0a0e1a;
  color: #e2e8f0;
  min-height: 100vh;
  overflow-x: hidden;
}

/* --- Screens --- */

.screen {
  display: none;
  width: 100vw;
  height: 100vh;
}

.screen.active {
  display: flex;
}

/* --- Buttons --- */

.btn-primary {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 14px 32px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 1px;
  transition: transform 0.15s, box-shadow 0.15s;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-large {
  width: 100%;
  padding: 16px;
  font-size: 18px;
}

/* --- Game Screen --- */

#gameScreen {
  flex-direction: column;
  background: radial-gradient(ellipse at 50% 30%, #1a1535 0%, #0a0e1a 60%);
}

/* --- Top Bar --- */

.top-bar {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: rgba(10, 14, 26, 0.8);
  border-bottom: 1px solid #1e2235;
}

.game-menu-container {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 48px;
  pointer-events: none;
}

.game-menu-container>* {
  pointer-events: auto;
}

.player-display {
  display: flex;
  align-items: center;
  gap: 8px;
}

.player-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: #fff;
}

.player-name {
  font-size: 14px;
  font-weight: 600;
  color: #cbd5e1;
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.balance-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2px;
  color: #64748b;
  display: block;
}

.balance-value {
  font-size: 28px;
  font-weight: 800;
  color: #fbbf24;
}

.round-label {
  font-size: 13px;
  font-weight: 600;
  color: #94a3b8;
  letter-spacing: 0.5px;
}

/* --- Rocks Area --- */

.rocks-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.rocks-container {
  display: flex;
  gap: 32px;
  align-items: flex-end;
}

.rock-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.rock {
  width: 120px;
  height: 130px;
  position: relative;
  cursor: default;
  transition: transform 0.3s;
}

.rock-body {
  width: 100%;
  height: 100%;
  background: linear-gradient(145deg, #5a5a6e 0%, #3a3a4e 40%, #2a2a3e 100%);
  border-radius: 45% 50% 42% 55% / 50% 45% 55% 48%;
  box-shadow:
    inset -4px -6px 12px rgba(0, 0, 0, 0.5),
    inset 4px 4px 8px rgba(255, 255, 255, 0.05),
    0 8px 24px rgba(0, 0, 0, 0.4);
  transition: all 0.3s;
}

.rock .crack {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.3s;
}

.rock .gem {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 40px;
  height: 40px;
  transform: translate(-50%, -50%) scale(0);
  background: radial-gradient(circle, #a78bfa, #7c3aed);
  clip-path: polygon(50% 0%, 80% 30%, 100% 50%, 80% 70%, 50% 100%, 20% 70%, 0% 50%, 20% 30%);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.rock .debris {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* Rock states */

.rock.shaking {
  animation: shake 0.4s ease-in-out;
}

.rock.crushed .rock-body {
  opacity: 0.15;
  transform: scale(0.7);
  filter: blur(2px);
}

.rock.crushed .crack {
  opacity: 1;
}

.rock.crushed.has-gem .gem {
  transform: translate(-50%, -50%) scale(1);
  animation: gemPulse 1.5s ease-in-out infinite;
}

.rock.intact .rock-body {
  opacity: 1;
}

/* --- Animations --- */

@keyframes shake {

  0%,
  100% {
    transform: translate(0, 0) rotate(0deg);
  }

  10% {
    transform: translate(-8px, -2px) rotate(-3deg);
  }

  20% {
    transform: translate(6px, 3px) rotate(2deg);
  }

  30% {
    transform: translate(-6px, -1px) rotate(-2deg);
  }

  40% {
    transform: translate(8px, 2px) rotate(3deg);
  }

  50% {
    transform: translate(-4px, -3px) rotate(-1deg);
  }

  60% {
    transform: translate(4px, 1px) rotate(1deg);
  }

  70% {
    transform: translate(-3px, 2px) rotate(-1deg);
  }

  80% {
    transform: translate(3px, -1px) rotate(1deg);
  }

  90% {
    transform: translate(-1px, 1px) rotate(0deg);
  }
}

@keyframes gemPulse {

  0%,
  100% {
    filter: drop-shadow(0 0 8px rgba(167, 139, 250, 0.6));
  }

  50% {
    filter: drop-shadow(0 0 20px rgba(167, 139, 250, 0.9)) drop-shadow(0 0 40px rgba(124, 58, 237, 0.4));
  }
}

@keyframes crumble {
  0% {
    transform: translate(0, 0) rotate(0deg);
    opacity: 1;
  }

  100% {
    transform: translate(var(--dx), var(--dy)) rotate(var(--rot));
    opacity: 0;
  }
}

@keyframes winPop {
  0% {
    transform: scale(0);
    opacity: 0;
  }

  60% {
    transform: scale(1.15);
    opacity: 1;
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes smashPulse {

  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
  }

  50% {
    box-shadow: 0 0 0 8px rgba(239, 68, 68, 0);
  }
}

/* --- Result Overlay --- */

.result-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(4px);
}

.result-overlay.active {
  display: flex;
}

.result-box {
  text-align: center;
  background: #1a1e30;
  border: 1px solid #2a2f45;
  border-radius: 20px;
  padding: 40px;
  min-width: 300px;
  animation: winPop 0.4s ease-out;
}

.result-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 3px;
  color: #94a3b8;
  margin-bottom: 8px;
}

.result-title.win {
  color: #fbbf24;
}

.result-title.loss {
  color: #64748b;
}

.result-amount {
  font-size: 48px;
  font-weight: 900;
  color: #fbbf24;
  margin-bottom: 8px;
}

.result-amount.loss {
  color: #64748b;
  font-size: 36px;
}

.result-details {
  font-size: 13px;
  color: #64748b;
  margin-bottom: 24px;
  line-height: 1.8;
}

/* --- Controls --- */

.controls {
  padding: 16px 24px 12px;
  background: rgba(10, 14, 26, 0.9);
  border-top: 1px solid #1e2235;
  display: flex;
  gap: 16px;
  align-items: flex-end;
}

.bet-section {
  flex: 1;
}

.bet-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2px;
  color: #64748b;
  display: block;
  margin-bottom: 8px;
}

.bet-presets {
  display: flex;
  gap: 6px;
}

.bet-btn {
  background: #1e2235;
  border: 1px solid #2a2f45;
  border-radius: 8px;
  padding: 10px 16px;
  color: #94a3b8;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}

.bet-btn:hover {
  background: #252a40;
  border-color: #3a3f55;
}

.bet-btn.active {
  background: #6366f1;
  border-color: #6366f1;
  color: #fff;
}

.action-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

/* Boost toggle */

.boost-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.boost-toggle input {
  display: none;
}

.boost-slider {
  width: 36px;
  height: 20px;
  background: #2a2f45;
  border-radius: 10px;
  position: relative;
  transition: background 0.2s;
}

.boost-slider::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  background: #64748b;
  border-radius: 50%;
  transition: all 0.2s;
}

.boost-toggle input:checked+.boost-slider {
  background: #f59e0b;
}

.boost-toggle input:checked+.boost-slider::after {
  left: 19px;
  background: #fff;
}

.boost-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2px;
  color: #64748b;
  transition: color 0.2s;
}

.boost-toggle input:checked~.boost-label {
  color: #f59e0b;
}

/* Smash button */

.btn-smash {
  background: linear-gradient(135deg, #dc2626, #ef4444);
  color: #fff;
  border: none;
  border-radius: 14px;
  padding: 16px 48px;
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 3px;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
  animation: smashPulse 2s ease-in-out infinite;
}

.btn-smash:hover:not(:disabled) {
  transform: scale(1.04);
  box-shadow: 0 4px 24px rgba(239, 68, 68, 0.5);
}

.btn-smash:active:not(:disabled) {
  transform: scale(0.97);
}

.btn-smash:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  animation: none;
}

/* --- History --- */

.history {
  padding: 8px 24px 16px;
  background: rgba(10, 14, 26, 0.9);
}

.history-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2px;
  color: #475569;
  display: block;
  margin-bottom: 6px;
}

.history-list {
  display: flex;
  gap: 6px;
}

.history-item {
  background: #1e2235;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
  min-width: 60px;
  text-align: center;
}

.history-item.win {
  color: #4ade80;
  border: 1px solid #166534;
}

.history-item.loss {
  color: #64748b;
  border: 1px solid #2a2f45;
}

/* Error toast */

.error-toast {
  position: fixed;
  bottom: 120px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #7f1d1d;
  color: #fca5a5;
  padding: 12px 24px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s;
  z-index: 200;
  max-width: 90%;
  text-align: center;
}

.error-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Debris particles */

.debris-particle {
  position: absolute;
  width: 8px;
  height: 8px;
  background: #4a4a5e;
  border-radius: 2px;
  animation: crumble 0.6s ease-out forwards;
}