/* Maze Paint — High Polish Stylesheet */
:root {
  --bg-color: #FAF6ED;
  --text-main: #584B5B;
  --text-sub: #8D7E90;
  --pill-bg: #ADA3B3;
  --card-bg: #FFFFFF;
  --btn-primary-bg: #FFB300;
  --btn-primary-shadow: #D98200;
  --btn-primary-text: #FFFFFF;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  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-color: var(--bg-color);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Rounded", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text-main);
}

#game-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  max-width: 520px;
  margin: 0 auto;
  position: relative;
}

/* Header & HUD */
#top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: calc(var(--safe-top) + 12px) 20px 8px 20px;
  z-index: 10;
}

.icon-btn {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  flex-shrink: 0;
  border-radius: 50%;
  background: #FFFFFF;
  border: none;
  color: #6C5D6E;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.icon-btn:active {
  transform: scale(0.92);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

.icon-btn svg {
  display: block;
}

#level-header {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 0 10px;
}

.pill-badge {
  display: inline-block;
  padding: 3px 14px;
  border-radius: 12px;
  background-color: var(--pill-bg);
  color: #FFFFFF;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  margin-bottom: 4px;
  transition: background-color 0.3s ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

#level-number {
  font-size: clamp(22px, 5.5vw, 28px);
  font-weight: 900;
  color: #554457;
  letter-spacing: -0.5px;
  line-height: 1.1;
}

.top-spacer {
  width: 44px;
  height: 44px;
  min-width: 44px;
  flex-shrink: 0;
  pointer-events: none;
}

/* Canvas Stage */
#stage {
  flex: 1;
  width: 100%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
}

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

/* Modal Overlays */
.modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(35, 27, 40, 0.48);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
  animation: fadeIn 0.25s ease-out;
}

.modal-backdrop[hidden] {
  display: none !important;
}

.modal-card {
  width: 100%;
  max-width: 340px;
  background: #FFFFFF;
  border-radius: 28px;
  padding: 32px 24px 28px 24px;
  text-align: center;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.18), 0 2px 6px rgba(0, 0, 0, 0.06);
  animation: popIn 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.win-sparkles {
  font-size: 36px;
  margin-bottom: 4px;
  animation: pulseSparkle 1.2s ease-in-out infinite alternate;
}

.trophy-icon {
  font-size: 48px;
  margin-bottom: 8px;
}

.modal-title {
  font-size: 24px;
  font-weight: 900;
  color: #3E3242;
  letter-spacing: -0.3px;
  margin-bottom: 6px;
}

.modal-subtitle {
  font-size: 15px;
  font-weight: 700;
  color: #8C7C91;
  margin-bottom: 24px;
}

.modal-copy {
  font-size: 15px;
  font-weight: 600;
  color: #6C5D70;
  line-height: 1.4;
  margin-bottom: 24px;
}

.primary-btn {
  width: 100%;
  padding: 16px 20px;
  border-radius: 22px;
  border: none;
  background: linear-gradient(180deg, #FFB700 0%, #FF9500 100%);
  color: #FFFFFF;
  font-size: 17px;
  font-weight: 900;
  letter-spacing: 0.6px;
  box-shadow: 0 6px 0 #D97700, 0 10px 20px rgba(255, 149, 0, 0.35);
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
  margin-bottom: 12px;
}

.primary-btn:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #D97700, 0 4px 10px rgba(255, 149, 0, 0.25);
}

.secondary-btn {
  width: 100%;
  padding: 13px 20px;
  border-radius: 20px;
  border: 2px solid #E2DBE5;
  background: #FBF9FC;
  color: #6C5B70;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: background-color 0.12s ease, transform 0.08s ease;
}

.secondary-btn:active {
  transform: scale(0.97);
  background-color: #F0ECF2;
}

.secondary-btn[hidden] {
  display: none !important;
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes popIn {
  from {
    opacity: 0;
    transform: scale(0.75) translateY(20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes pulseSparkle {
  from { transform: scale(1) rotate(-5deg); }
  to { transform: scale(1.18) rotate(5deg); }
}

/* Tablet Optimizations */
@media (min-width: 600px) {
  #game-container {
    max-width: 480px;
  }
  .modal-card {
    max-width: 360px;
    padding: 36px 28px 32px 28px;
  }
}
