* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: radial-gradient(circle at 50% 35%, #231942 0%, #0e0a1a 100%);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Rounded", "Segoe UI", Roboto, sans-serif;
}

#app {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

#game-stage {
  position: relative;
  aspect-ratio: 750 / 1334;
  height: 100vh;
  max-height: 100dvh;
  max-width: 100vw;
  overflow: hidden;
  border-radius: 14px;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.72), 0 0 0 1px rgba(255, 255, 255, 0.12);
  background: #8fd8f0;
  touch-action: none;
}

@media (max-aspect-ratio: 750 / 1334) {
  #game-stage {
    width: 100vw;
    height: auto;
    border-radius: 0;
  }
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

.overlay {
  position: absolute;
  inset: 0;
  background: rgba(10, 7, 22, 0.74);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}

.overlay.hidden { display: none; }

/* Loading */
.loading-box {
  width: 82%;
  background: linear-gradient(180deg, #fffaf0 0%, #ffe6be 100%);
  border: 3px solid #d9822b;
  border-radius: 28px;
  padding: 28px 22px;
  text-align: center;
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.5), inset 0 2px 0 rgba(255, 255, 255, 0.9);
}

.loading-emblem {
  width: 68px;
  height: 68px;
  margin: 0 auto 12px;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, #fde047 0%, #f97316 55%, #dc2626 100%);
  border: 3px solid #fff;
  box-shadow: 0 8px 20px rgba(249, 115, 22, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 20px;
  font-weight: 900;
  letter-spacing: -0.5px;
  text-shadow: 0 2px 4px rgba(124, 45, 8, 0.5);
}

.loading-title {
  font-size: 19px;
  font-weight: 900;
  color: #7c2d08;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.badge-od {
  background: linear-gradient(135deg, #f43f5e 0%, #f59e0b 100%);
  color: #fff;
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 999px;
  letter-spacing: 0.8px;
  box-shadow: 0 2px 8px rgba(244, 63, 94, 0.35);
}

.loading-bar-bg {
  width: 100%;
  height: 14px;
  background: #e5c394;
  border-radius: 999px;
  overflow: hidden;
  border: 2px solid #c26d1f;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15);
}

#loading-bar-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #fbbf24 0%, #f97316 60%, #f43f5e 100%);
  transition: width 0.1s ease;
}

#loading-text {
  margin-top: 10px;
  font-size: 12.5px;
  font-weight: 700;
  color: #9e531d;
}

/* Smash Mode Banner — cleanly anchored above bottom dock */
#smash-banner {
  position: absolute;
  bottom: 12%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 16;
  width: 84%;
}
#smash-banner.hidden { display: none; }

.smash-banner-inner {
  background: linear-gradient(135deg, rgba(220, 38, 38, 0.95) 0%, rgba(234, 88, 12, 0.95) 100%);
  border: 2.5px solid rgba(255, 255, 255, 0.9);
  border-radius: 999px;
  padding: 8px 12px 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: #fff;
  font-size: 12.5px;
  font-weight: 900;
  letter-spacing: 0.5px;
  box-shadow: 0 10px 28px rgba(220, 38, 38, 0.5);
}

.smash-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #fde047;
  box-shadow: 0 0 8px #fde047;
  animation: pulseDot 0.9s infinite alternate;
}

@keyframes pulseDot {
  from { transform: scale(0.8); opacity: 0.7; }
  to { transform: scale(1.25); opacity: 1; }
}

#cancel-smash-btn {
  background: rgba(0, 0, 0, 0.3);
  border: 1.5px solid rgba(255, 255, 255, 0.85);
  color: #fff;
  font-size: 11.5px;
  font-weight: 800;
  padding: 4px 12px;
  border-radius: 999px;
  cursor: pointer;
}

/* Event / Fever Toast — safe mid-playfield glass pill, never covers held ball or TARGET */
#event-banner {
  position: absolute;
  top: 40%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 15;
  pointer-events: none;
  animation: bannerPop 0.32s cubic-bezier(0.22, 1.4, 0.36, 1);
}
#event-banner.hidden { display: none; }

.event-banner-inner {
  background: linear-gradient(135deg, rgba(24, 14, 48, 0.88) 0%, rgba(56, 20, 84, 0.9) 100%);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 2.5px solid #fcd34d;
  border-radius: 999px;
  padding: 9px 22px;
  color: #fef08a;
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 0.9px;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45), 0 0 20px rgba(251, 191, 36, 0.35);
  white-space: nowrap;
}

@keyframes bannerPop {
  0% { transform: translate(-50%, 14px) scale(0.76); opacity: 0; }
  100% { transform: translate(-50%, 0) scale(1); opacity: 1; }
}

/* Roguelike Draft Modal — Premium Holographic Card UI */
.draft-panel {
  width: 92%;
  background: linear-gradient(180deg, #21153f 0%, #110924 100%);
  border: 2.5px solid rgba(251, 191, 36, 0.85);
  border-radius: 28px;
  padding: 22px 16px 18px;
  text-align: center;
  box-shadow: 0 0 48px rgba(245, 158, 11, 0.28), 0 24px 54px rgba(0, 0, 0, 0.72), inset 0 1px 0 rgba(255, 255, 255, 0.22);
  animation: cardModalIn 0.24s cubic-bezier(0.2, 1.3, 0.3, 1);
}

@keyframes cardModalIn {
  0% { transform: scale(0.86); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.draft-kicker {
  display: inline-block;
  background: linear-gradient(90deg, #f59e0b, #f43f5e);
  color: #fff;
  font-size: 11px;
  font-weight: 900;
  padding: 4px 13px;
  border-radius: 999px;
  letter-spacing: 1px;
  margin-bottom: 8px;
  box-shadow: 0 4px 12px rgba(244, 63, 94, 0.4);
}

.draft-title {
  font-size: 20px;
  font-weight: 900;
  color: #fff;
  margin-bottom: 16px;
  letter-spacing: 0.6px;
  text-shadow: 0 2px 12px rgba(251, 191, 36, 0.45);
}

.draft-cards {
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.draft-card {
  display: flex;
  align-items: center;
  gap: 13px;
  text-align: left;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.11) 0%, rgba(255, 255, 255, 0.04) 100%);
  border: 1.8px solid rgba(253, 224, 71, 0.38);
  border-radius: 18px;
  padding: 12px 14px;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 6px 16px rgba(0, 0, 0, 0.25);
  transition: transform 0.14s ease, border-color 0.14s ease, background 0.14s ease;
}

.draft-card:hover {
  transform: translateY(-2px) scale(1.015);
  border-color: #fde047;
  background: linear-gradient(135deg, rgba(250, 204, 21, 0.22) 0%, rgba(244, 63, 94, 0.14) 100%);
}

.draft-card:active { transform: scale(0.98); }

.draft-icon-wrap {
  width: 50px;
  height: 50px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 1.5px solid rgba(255, 255, 255, 0.32);
  box-shadow: inset 0 2px 6px rgba(255, 255, 255, 0.25), 0 4px 12px rgba(0, 0, 0, 0.3);
}

.draft-icon-wrap svg {
  width: 28px;
  height: 28px;
  display: block;
}

.draft-info { flex: 1; }
.draft-name { font-size: 15px; font-weight: 900; color: #fef08a; margin-bottom: 3px; letter-spacing: 0.3px; }
.draft-desc { font-size: 12px; line-height: 1.35; color: #e2e8f0; font-weight: 600; }

.draft-lvl {
  font-size: 11px;
  font-weight: 900;
  color: #7dd3fc;
  background: rgba(56, 189, 248, 0.18);
  border: 1px solid rgba(56, 189, 248, 0.4);
  padding: 4px 9px;
  border-radius: 999px;
}

/* Theme Modal */
.theme-panel {
  width: 92%;
  max-height: 86%;
  background: linear-gradient(180deg, #fffaf0 0%, #ffebd0 100%);
  border: 3.5px solid #c97324;
  border-radius: 26px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 46px rgba(0, 0, 0, 0.5);
}

.theme-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: linear-gradient(180deg, #e59a3a 0%, #c87620 100%);
  border-bottom: 3px solid #a05512;
}

.theme-title {
  font-size: 19px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 2px 0 #8a4208;
  letter-spacing: 1.2px;
}

.img-btn { background: none; border: none; cursor: pointer; padding: 0; display: flex; }
.img-btn img { width: 38px; height: 38px; display: block; }

.theme-grid {
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  overflow-y: auto;
}

.theme-card {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  cursor: pointer;
  border: 3px solid transparent;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
  aspect-ratio: 223 / 310;
  background: #eee;
  transition: transform 0.14s ease;
}
.theme-card:hover { transform: translateY(-2px); }
.theme-card.active { border-color: #22c55e; box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.35); }
.theme-card img.thumb { width: 100%; height: 100%; object-fit: cover; display: block; }
.theme-card .check-badge { position: absolute; right: 6px; bottom: 6px; width: 26px; height: 26px; display: none; }
.theme-card.active .check-badge { display: block; }

/* Settings Modal */
.settings-panel {
  width: 84%;
  background: linear-gradient(180deg, #fffaf0 0%, #ffe6be 100%);
  border: 3.5px solid #c97324;
  border-radius: 26px;
  overflow: hidden;
  box-shadow: 0 20px 46px rgba(0, 0, 0, 0.5);
}

.settings-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px 16px;
  background: linear-gradient(180deg, #e59a3a 0%, #c87620 100%);
  border-bottom: 3px solid #a05512;
}

.settings-close-btn {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: linear-gradient(180deg, #f87171 0%, #dc2626 100%);
  border: 2px solid #fff;
  border-radius: 50%;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.25);
}
.settings-close-btn img { width: 15px; height: 15px; }

.settings-body { padding: 18px 20px 22px; display: flex; flex-direction: column; gap: 13px; }

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.78);
  border: 2px solid #e3b882;
  border-radius: 16px;
  padding: 10px 14px;
}

.setting-left { display: flex; align-items: center; gap: 12px; }
.setting-icon { width: 36px; height: 36px; object-fit: contain; }
.setting-label { font-size: 16px; font-weight: 800; color: #7c3a0d; }
.toggle-btn { background: none; border: none; cursor: pointer; padding: 0; }
.toggle-btn img { height: 34px; width: auto; display: block; }

.action-btn {
  width: 100%;
  padding: 13px;
  border: 2.5px solid #fff;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffd447 0%, #f59e0b 100%);
  color: #6b2b06;
  font-size: 15.5px;
  font-weight: 900;
  letter-spacing: 0.6px;
  cursor: pointer;
  box-shadow: 0 5px 0 #b45309, 0 8px 18px rgba(0, 0, 0, 0.25);
}
.action-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 #b45309; }

.secondary-btn {
  background: linear-gradient(180deg, #60a5fa 0%, #2563eb 100%);
  color: #fff;
  box-shadow: 0 5px 0 #1d4ed8, 0 8px 18px rgba(0, 0, 0, 0.2);
}

.revive-btn {
  background: linear-gradient(180deg, #34d399 0%, #059669 100%);
  color: #fff;
  box-shadow: 0 5px 0 #047857, 0 8px 18px rgba(0, 0, 0, 0.25);
  margin-bottom: 10px;
}

/* Game Over Modal */
.gameover-panel {
  width: 84%;
  background: linear-gradient(180deg, #fffaf0 0%, #ffe6be 100%);
  border: 3.5px solid #c97324;
  border-radius: 28px;
  padding: 24px 20px;
  text-align: center;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.52);
}

.gameover-title {
  font-size: 25px;
  font-weight: 900;
  color: #dc2626;
  text-shadow: 0 2px 0 #fff;
  margin-bottom: 14px;
  letter-spacing: 0.8px;
}

.gameover-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.stat-card { background: rgba(255, 255, 255, 0.85); border: 2px solid #e3b882; border-radius: 14px; padding: 10px 6px; }
.stat-label { font-size: 11px; font-weight: 800; color: #a16207; margin-bottom: 2px; }
.stat-value { font-size: 21px; font-weight: 900; color: #7c2d08; }

.gameover-max-ball {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-bottom: 16px;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.6px;
  color: #9a4a12;
}

.max-ball-preview { position: relative; width: 72px; height: 72px; display: flex; align-items: center; justify-content: center; }
.max-ball-preview img:first-child { width: 100%; height: 100%; object-fit: contain; }
.max-ball-preview img:last-child { position: absolute; max-width: 62%; max-height: 44%; object-fit: contain; }
