/* 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-cc {
  position: absolute;
  inset: 0;
  z-index: 1;
}

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

#ctgm-root-container-cc {
  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-cc {
  position: absolute;
  z-index: 1;
}

/* Non-blocking canvas */
#cs-stage {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: transparent;
}

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

/* Each GIF sprite */
.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;
}

/* Snake head styles */
.snake-head {
  will-change: left, top;
}

/* Snake body styles for consistent animation */
.snake-body {
  image-rendering: auto;
  image-rendering: crisp-edges;
  image-rendering: -webkit-optimize-contrast;
  animation-play-state: running;
  animation-duration: 1s;
  animation-iteration-count: infinite;
  animation-timing-function: linear;
  will-change: left, top;
  border-radius: 7.2px;
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.85) inset,
    0 4.8px 10.8px rgba(255,0,0,0.25);
  filter: saturate(1.15) contrast(1.05);
}

/* Snake body corner target badge */
.snake-body::after {
  content: "";
  position: absolute;
  right: -3.6px;
  top: -3.6px;
  width: 8.4px;
  height: 8.4px;
  border-radius: 50%;
  border: 1.2px solid #fff;
  box-shadow:
    0 0 0 1.2px rgba(255,0,0,0.9),
    0 1.2px 3.6px rgba(0,0,0,0.25);
  background: radial-gradient(circle at 50% 50%, rgba(255,0,0,0.9) 0 2px, transparent 3px);
  pointer-events: none;
}

/* Shooter area */
#cs-shootarea {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 300px;
  height: 250px;
  transform: translate(-50%, -50%) rotate(0deg);
  background: rgba(15, 20, 30, 0.25);
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.15),
    inset 0 0 0 1px rgba(255, 255, 255, 0.15);
  border-radius: 24px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* ---- 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%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 280px;
  min-height: 200px;
  text-align: center;
  pointer-events: auto;
  background: rgba(15, 20, 35, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  padding: 20px 36px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
  z-index: 2147483640;
}

#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);
}

/* ---- Tips display ---- */
#cs-addchartips {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: calc(50% - 20px);
  width: 240px;
  text-align: center;
  color: rgba(255, 255, 255, 0.85);
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  display: none;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  background: rgba(15, 20, 35, 0.8);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  user-select: none;
}

/* ---- 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 {
  top: calc(50% + 25px);
  padding: 10px 10px;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.3);
  z-index: 2147483641;
}

#cs-restart {
  top: calc(50% + 65px);
  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;
  z-index: 2147483641;
}

#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);
  top: calc(50% + 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;
}

/* 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;
}
