:root {
  --bg: #f0f4ff;
  --card: #ffffff;
  --primary: #6c5ce7;
  --primary-dark: #5a4bd1;
  --secondary: #a29bfe;
  --accent: #fd79a8;
  --success: #00b894;
  --danger: #e17055;
  --text: #2d3436;
  --text-light: #636e72;
  --radius: 16px;
  --shadow: 0 8px 32px rgba(108, 92, 231, 0.15);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Screens */
.screen {
  display: none;
  min-height: 100vh;
  flex-direction: column;
}

.screen.active {
  display: flex;
}

/* Hero */
.hero {
  text-align: center;
  padding: 2rem 1rem 1rem;
  position: relative;
}

.hero h1 {
  font-size: 2.2rem;
  color: var(--primary);
  margin-bottom: 0.5rem;
}

.hero p {
  color: var(--text-light);
  font-size: 1.1rem;
}

/* Grid */
.character-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1.5rem;
  padding: 1.5rem;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
}

.character-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  border: 3px solid transparent;
}

.character-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 40px rgba(108, 92, 231, 0.25);
  border-color: var(--secondary);
}

.character-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  background: #fafafa;
  padding: 0.5rem;
}

.character-card .card-body {
  padding: 1rem;
  text-align: center;
}

.character-card h3 {
  font-size: 1rem;
  color: var(--text);
}

.character-card .meta {
  font-size: 0.8rem;
  color: var(--text-light);
  margin-top: 0.25rem;
}

.character-card .placeholder-img {
  width: 100%;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #dfe6e9, #b2bec3);
  font-size: 3rem;
}

/* Game header */
.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: var(--card);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.game-header h2 {
  font-size: 1.1rem;
  color: var(--primary);
}

.progress {
  background: var(--secondary);
  color: white;
  padding: 0.3rem 0.8rem;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
}

.starter-preview,
.starter-label,
.starter-image,
.btn-start,
.game-area.playing .starter-preview,
.canvas-container.is-hidden,
.game-hint.is-hidden {
  display: none;
}

/* removed preview panel — starter is now canvas background */

/* Game area */
.game-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  position: relative;
}

.canvas-container {
  position: relative;
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  max-width: 95vw;
  max-height: 70vh;
}

.starter-bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  z-index: 0;
}

#gameCanvas {
  display: block;
  position: relative;
  z-index: 1;
  max-width: 100%;
  max-height: 70vh;
  background: transparent;
}

#gameCanvas.no-starter {
  background: #ffffff;
}

.overlay-image {
  z-index: 2;
}

.overlay-image {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
  transition: opacity 1s ease;
  pointer-events: none;
}

.overlay-image.visible {
  opacity: 1;
}

.game-hint {
  text-align: center;
  padding: 0.75rem;
  color: var(--text-light);
  font-size: 1rem;
}

.game-hint strong {
  color: var(--primary);
  font-size: 1.2rem;
}

/* Success */
.success-panel {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(4px);
  z-index: 10;
  animation: fadeIn 0.5s ease;
}

.success-content {
  text-align: center;
  animation: bounceIn 0.6s ease;
}

.success-emoji {
  font-size: 4rem;
  display: block;
}

.success-content h3 {
  font-size: 2rem;
  color: var(--success);
  margin: 0.5rem 0;
}

.success-content p {
  color: var(--text-light);
  margin-bottom: 1rem;
}

/* Buttons */
.btn {
  border: none;
  padding: 0.6rem 1.2rem;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-back {
  background: transparent;
  color: var(--primary);
  font-weight: 600;
}

.btn-back:hover {
  background: rgba(108, 92, 231, 0.1);
}

/* Dot shake animation */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

.shake {
  animation: shake 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes bounceIn {
  0% { transform: scale(0.5); opacity: 0; }
  70% { transform: scale(1.05); }
  100% { transform: scale(1); opacity: 1; }
}

.empty-msg {
  text-align: center;
  color: var(--text-light);
  padding: 2rem;
  font-size: 1.1rem;
}

.hidden {
  display: none !important;
}

/* Responsive */
@media (max-width: 600px) {
  .hero h1 {
    font-size: 1.6rem;
  }

  .character-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 1rem;
    padding: 1rem;
  }
}
