:root {
  --bg-gradient: linear-gradient(to right, #5f3c82, #de6aa7); 
  --card-bg: #ffffff;
  --accent-pink: #de6aa7;
  --secondary-grey: #6c757d;
  --text-main: #1f2937;
  --text-muted: #6b7280;
  --border-light: #f3f4f6;
  --success-green: #10b981;
}

body {
  margin: 0;
  padding: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--text-main);
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
}

.main-card {
  background: var(--card-bg);
  width: 98%;
  max-width: 1100px;
  margin: 1.5rem 0;
  padding: 2rem;
  border-radius: 1.5rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: relative;
}

header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  border-bottom: 2px solid var(--border-light);
  padding-bottom: 1.5rem;
}

.brand h1 { 
  margin: 0; 
  font-size: 1.5rem; 
  font-weight: 800; 
  letter-spacing: -1px; 
  color: var(--text-main); 
}

.brand p {
  margin: 0.1rem 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.controls {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap; 
}

button, .file-label {
  border: none; 
  color: white; 
  padding: 0.7rem 1.2rem; 
  border-radius: 0.6rem;
  cursor: pointer; 
  font-weight: 700; 
  font-size: 0.8rem;
  display: flex;
  align-items: center; 
  gap: 0.5rem; 
  transition: all 0.2s ease;
  line-height: 1.2;
}

.btn-pink { background: var(--accent-pink); }
.btn-pink:hover { background: #5f3c82; transform: translateY(-1px); }

.btn-grey { background: var(--secondary-grey); }

.btn-outline { background: transparent; border: 2px solid var(--accent-pink); color: var(--accent-pink); }
.btn-outline:hover { background: var(--accent-pink); color: white; }

select {
  background: #f9fafb;
  color: var(--text-main);
  border: 1px solid #e5e7eb;
  padding: 0.5rem;
  border-radius: 0.6rem;
  font-weight: 600;
  outline: none;
}

#gallery-panel {
  display: none;
  background: #f9fafb;
  border-radius: 1.2rem;
  padding: 1.2rem;
  border: 1px solid var(--border-light);
  margin-bottom: 1rem;
}
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 1rem;
  max-height: 250px;
  overflow-y: auto;
  padding: 0.5rem;
}
.gallery-item {
  cursor: pointer;
  border-radius: 0.5rem;
  overflow: hidden;
  aspect-ratio: 1;
  border: 3px solid transparent;
}
.gallery-item:hover {
  border-color: var(--accent-pink);
  transform: scale(1.05);
}
.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#game-area {
  position: relative;
  width: 100%;
  background: #fdfdfd;
  border-radius: 1rem;
  overflow: auto;
  border: 1px solid var(--border-light);
}

canvas {
  display: block;
  margin: 0 auto;
  cursor: grab;
}
canvas:active { cursor: grabbing; }

.win-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(10px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.3s ease-out;
}
.win-modal-content {
  background: white;
  padding: 2.5rem;
  border-radius: 2rem;
  text-align: center;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  max-width: 400px;
  width: 90%;
  transform: scale(0.9);
  animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { transform: scale(0.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.win-icon {
  background: var(--success-green);
  color: white;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.5rem;
}

.progress-indicator {
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--text-muted);
  text-align: center;
  letter-spacing: 1px;
  margin-bottom: 0.5rem;
}

footer {
  padding: 1.5rem;
  color: rgba(255,255,255,0.7);
  font-size: 0.75rem;
  text-align: center;
}
footer a {
  color: inherit;
  text-decoration: none;
  margin: 0 3px;
}
