/* Web page: gamebox container */
.ct-gamebox {
  position: relative;
  min-height: 560px;
  width: 100%;
  aspect-ratio: 3 / 2;
  margin-bottom: 56px;
  background:
    radial-gradient(ellipse 80% 60% at 50% 90%, rgba(59, 130, 246, 0.1) 0%, transparent 50%),
    radial-gradient(ellipse 100% 100% at 50% 30%, rgba(34, 197, 94, 0.04) 0%, transparent 45%),
    radial-gradient(ellipse 100% 100% at 50% 50%, rgba(30, 58, 138, 0.15) 0%, transparent 65%),
    linear-gradient(180deg, #0c1222 0%, #1e293b 40%, #0f172a 70%, #0c1222 100%);
  border-radius: 20px;
  overflow: hidden;
  box-shadow:
    inset 0 0 150px rgba(0, 0, 0, 0.25),
    0 8px 32px rgba(0, 0, 0, 0.35),
    0 0 0 1px rgba(148, 163, 184, 0.1);
}

.ct-gamebox::before {
  content: "Character World";
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: #e7efff;
  background: rgba(34, 211, 238, 0.18);
  border: 1px solid rgba(34, 211, 238, 0.4);
  pointer-events: none;
  z-index: 3;
}

.ct-gamebox #ctgm-root-container-cb {
  position: absolute;
  inset: 0;
  z-index: 1;
}

:host, #ctgm-root-container-cb { all: initial; }

#ctgm-root-container-cb {
  position: fixed;
  inset: 0;
  z-index: 2147483647;
  pointer-events: none;
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

.ct-gamebox #ctgm-root-container-cb {
  position: absolute;
  z-index: 1;
}

#cs-stage {
  position: absolute;
  inset: 0;
  background: transparent;
}

/* Shooter + UI clickable */
.cs-interactive { pointer-events: auto; }

/* ---- Shoot area (bottom center) ---- */
#cs-shootarea {
  position: absolute;
  left: 50%;
  bottom: -200px;
  width: 400px;
  height: 400px;
  transform: translateX(-50%) rotate(0deg);
  border-radius: 999px;
  background: rgba(34, 34, 34, 0.2);
  box-shadow:
    0 2px 16px rgba(0, 0, 0, 0.15),
    inset 0 0 0 1px rgba(255, 255, 255, 0.65);
}

/* ---- Shooter (bottom center turret) ---- */
#cs-shooter {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 52px;
  height: 52px;
  transform: translate(-50%, -50%) rotate(0deg);
  border-radius: 999px;
  background: linear-gradient(145deg, #1e293b, #0f172a);
  box-shadow:
    0 4px 16px rgba(0, 0, 0, 0.4),
    inset 0 0 0 2px rgba(255, 255, 255, 0.15),
    0 0 20px rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Shooter barrel */
#cs-shooter::after {
  content: '';
  position: absolute;
  width: 3px;
  height: 80px;
  background: linear-gradient(to top, #3b82f6, #60a5fa);
  top: -80px;
  left: 50%;
  transform: translateX(-50%);
  border-radius: 2px;
  box-shadow: 0 0 8px rgba(59, 130, 246, 0.4);
}

#cs-shooter::before {
  content: '';
  position: absolute;
  top: -96px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-bottom: 14px solid #3b82f6;
  filter: drop-shadow(0 0 4px rgba(59, 130, 246, 0.5));
}

/* ---- Projectiles ---- */
.cs-balloon {
  position: absolute;
  width: 50px;
  height: 50px;
  border-radius: 999px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

/* ---- Status panel (top-right) ---- */
#cs-status {
  position: absolute;
  right: 12px;
  top: 12px;
  display: grid;
  gap: 6px;
  text-align: center;
  pointer-events: none;
}

#cs-level, #cs-score, #cs-timer {
  font-size: 13px;
  font-weight: 600;
  padding: 6px 14px;
  color: rgba(255, 255, 255, 0.9);
  background: rgba(15, 20, 35, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  letter-spacing: 0.3px;
}

#cs-timer {
  color: #f87171;
}

/* ---- Game over panel ---- */
#cs-gameover {
  position: absolute;
  left: 50%;
  bottom: 200px;
  transform: translateX(-50%);
  text-align: center;
  pointer-events: auto;
  background: rgba(15, 20, 35, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  padding: 28px 36px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}

#cs-gameover .cs-g-title.success {
  font-size: 22px;
  font-weight: 700;
  color: #4ade80;
  margin: 0 0 10px;
  text-shadow: 0 0 20px rgba(74, 222, 128, 0.3);
}

#cs-gameover .cs-g-title.fail {
  font-size: 22px;
  font-weight: 700;
  color: #f87171;
  margin: 0 0 10px;
  text-shadow: 0 0 20px rgba(248, 113, 113, 0.3);
}

#cs-gameover .cs-g-score,
#cs-gameover .cs-g-rate,
#cs-gameover .cs-g-time {
  font-size: 15px;
  color: rgba(255, 255, 255, 0.75);
  margin: 6px 0;
  font-weight: 500;
}

/* ---- Start Over (Level 1) link - web only ---- */
#cs-gameover .cs-reset-level1 {
  display: inline-block;
  margin-top: 14px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.9);
  text-decoration: none;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}

#cs-gameover .cs-reset-level1:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.4);
  transform: translateY(-1px);
}

#cs-gameover .cs-reset-level1:active {
  transform: translateY(0);
}

/* ---- Action buttons (Restart, Add Characters) ---- */
#cs-restart, #cs-addchar {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: 220px;
  text-align: center;
  color: #fff;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  display: none;
  border: none;
  cursor: pointer;
  border-radius: 12px;
  user-select: none;
  letter-spacing: 0.3px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

#cs-restart:hover, #cs-addchar:hover {
  transform: translateX(-50%) translateY(-1px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

#cs-restart:active, #cs-addchar:active {
  transform: translateX(-50%) translateY(0);
}

#cs-addchar {
  bottom: 100px;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.3);
}

#cs-restart {
  bottom: 60px;
  width: 160px;
  padding: 8px 16px;
  font-size: 13px;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.3);
  color: #fff;
}

#cs-restart:hover {
  background: linear-gradient(135deg, #818cf8, #6366f1);
  box-shadow: 0 6px 20px rgba(79, 70, 229, 0.4);
}

/* ---- Close button - hidden on web ---- */
#cs-close {
  display: none;
}

/* ---- +score popup ---- */
#cs-addscore {
  position: absolute;
  left: calc(50% + 200px);
  bottom: 100px;
  font-size: 22px;
  color: #4ade80;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  text-shadow: 0 0 10px rgba(74, 222, 128, 0.4);
}

/* ---- Confetti container ---- */
#cs-confetti {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* Characters (GIFs) */
.cs-gif {
  position: absolute;
  width: 100px;
  height: 100px;
  transform-origin: center center;
  will-change: transform;
  pointer-events: none;
  -webkit-user-drag: none;
  user-select: none;
  touch-action: none;
}

/* Character picker modal */
#ct-char-picker-overlay {
  position: fixed;
  inset: 0;
  z-index: 2147483648;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
}

#ct-char-picker-modal {
  background: rgba(15, 20, 35, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  padding: 24px;
  max-width: 550px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}

#ct-char-picker-modal h3 {
  color: #fff;
  margin: 0 0 12px;
  font-size: 18px;
}

#ct-char-picker-modal p {
  color: rgba(255, 255, 255, 0.8);
  margin: 8px 0;
  font-size: 14px;
}

#ct-current-characters,
#ct-select-characters {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin: 12px 0;
}

#ct-current-characters > div,
#ct-select-characters > div {
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  border-radius: 8px;
  border: 2px solid transparent;
  transition: all 0.2s ease;
}

#ct-select-characters > div:hover {
  border-color: #2196F3;
  transform: scale(1.05);
}

#ct-select-characters > div.selected {
  border: 3px solid #4CAF50;
  background-color: rgba(76, 175, 80, 0.2);
}

#ct-current-characters img,
#ct-select-characters img {
  width: 100%;
  max-width: 70px;
  height: auto;
  display: block;
  border-radius: 6px;
}

#ct-select-characters img {
  max-width: 80px;
}

#ct-addchars-btn {
  display: block;
  width: 100%;
  margin-top: 16px;
  padding: 12px;
  text-align: center;
  font-weight: bold;
  font-size: 14px;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.2s;
}

#ct-addchars-btn:disabled {
  background: gray;
  cursor: not-allowed;
  pointer-events: none;
}

#ct-addchars-btn:not(:disabled) {
  background: #22c55e;
  color: white;
  cursor: pointer;
}
