:root {
  --bg-cream: #fff5ec;
  --bg-peach: #ffe4d1;
  --wood-light: #f4c095;
  --wood-dark: #c98a5b;
  --pink: #ff6b9d;
  --pink-dark: #e0487b;
  --brown-text: #5c3a21;
  --card-bg: #ffffff;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: radial-gradient(circle at top, var(--bg-cream) 0%, var(--bg-peach) 100%);
  color: var(--brown-text);
  font-family: "Fredoka", "Quicksand", "Nunito", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.app-wrap {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  gap: 6px;
}

/* Top HUD */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-shrink: 0;
}

.score-card, .next-card {
  background: var(--card-bg);
  border: 3px solid var(--wood-light);
  border-radius: 16px;
  padding: 4px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 82px;
  height: 64px;
  box-shadow: 0 4px 0 rgba(201, 138, 91, 0.25);
}

.lbl {
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--wood-dark);
}

#score-val {
  font-size: 1.35rem;
  font-weight: 900;
  color: var(--pink-dark);
}

.theme-switcher {
  display: flex;
  background: rgba(255, 255, 255, 0.75);
  border: 2px solid var(--wood-light);
  border-radius: 14px;
  padding: 3px;
  gap: 3px;
}

.theme-btn {
  background: transparent;
  border: none;
  padding: 6px 8px;
  border-radius: 10px;
  font-size: 0.76rem;
  font-weight: 800;
  color: var(--brown-text);
  cursor: pointer;
  transition: transform 0.12s, background 0.15s;
}

.theme-btn.active {
  background: var(--pink);
  color: #fff;
  box-shadow: 0 2px 6px rgba(255, 107, 157, 0.4);
}

/* Sub Action Bar */
.sub-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  flex-shrink: 0;
}

.best-pill {
  font-size: 0.8rem;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.8);
  padding: 5px 11px;
  border-radius: 20px;
  border: 2px solid var(--wood-light);
}

.tool-btns {
  display: flex;
  gap: 5px;
}

.pill-btn {
  background: #fff;
  border: 2px solid var(--wood-light);
  color: var(--brown-text);
  padding: 5px 10px;
  border-radius: 18px;
  font-size: 0.76rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 2px 0 rgba(201, 138, 91, 0.25);
}

.pill-btn:active {
  transform: translateY(2px);
}

/* Physics Stage */
.stage-wrap {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  border-radius: 18px;
}

.combo-toast {
  position: absolute;
  top: 18%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--pink);
  color: #fff;
  font-weight: 900;
  font-size: 1.05rem;
  padding: 6px 18px;
  border-radius: 24px;
  box-shadow: 0 4px 14px rgba(255, 107, 157, 0.5);
  pointer-events: none;
  animation: popBounce 0.35s cubic-bezier(0.3, 1.5, 0.6, 1);
}

@keyframes popBounce {
  0% { transform: translateX(-50%) scale(0.4); opacity: 0; }
  100% { transform: translateX(-50%) scale(1); opacity: 1; }
}

/* Evolution Footer */
.evo-bar {
  background: rgba(255, 255, 255, 0.88);
  border: 2px solid var(--wood-light);
  border-radius: 14px;
  padding: 5px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.evo-title {
  font-size: 0.65rem;
  font-weight: 900;
  color: var(--wood-dark);
  white-space: nowrap;
}

.evo-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 1;
  overflow-x: auto;
  gap: 3px;
}

.evo-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  border: 2px solid rgba(255,255,255,0.9);
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
  flex-shrink: 0;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(92, 58, 33, 0.55);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}

.modal-card {
  background: #fff9f5;
  border: 4px solid var(--wood-light);
  border-radius: 24px;
  width: 100%;
  max-width: 400px;
  overflow: hidden;
  box-shadow: 0 12px 30px rgba(92, 58, 33, 0.25);
}

.modal-header {
  background: var(--bg-peach);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2px solid var(--wood-light);
}

.modal-header h2 {
  font-size: 1.05rem;
  color: var(--brown-text);
}

.close-btn {
  background: #fff;
  border: 2px solid var(--wood-light);
  border-radius: 50%;
  width: 30px;
  height: 30px;
  font-weight: 900;
  cursor: pointer;
}

.modal-body {
  padding: 16px;
}

.gameover-banner {
  background: #fff;
  border: 2px dashed var(--pink);
  border-radius: 16px;
  padding: 12px;
  text-align: center;
  margin-bottom: 12px;
}

.go-big {
  font-weight: 900;
  font-size: 1.15rem;
  color: var(--pink-dark);
}

.go-score {
  font-size: 0.95rem;
  margin: 4px 0 10px;
}

.save-row {
  display: flex;
  gap: 6px;
}

.save-row input {
  flex: 1;
  border: 2px solid var(--wood-light);
  border-radius: 12px;
  padding: 8px 10px;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--brown-text);
}

.btn-kawaii {
  background: var(--pink);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 8px 14px;
  font-weight: 800;
  cursor: pointer;
}

.btn-kawaii-lg {
  width: 100%;
  background: var(--pink);
  color: #fff;
  border: none;
  border-radius: 16px;
  padding: 12px;
  font-size: 1rem;
  font-weight: 900;
  cursor: pointer;
  margin-top: 10px;
  box-shadow: 0 4px 0 var(--pink-dark);
}

.scores-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 210px;
  overflow-y: auto;
}

.score-row {
  background: #fff;
  border: 2px solid var(--bg-peach);
  border-radius: 12px;
  padding: 7px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
  font-weight: 700;
}

.hidden {
  display: none !important;
}
