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

:root {
  --pink: #ff6eb4;
  --pink-dark: #e0458f;
  --yellow: #ffd93d;
  --orange: #ff9f43;
  --blue: #54a0ff;
  --green: #6bcb77;
  --purple: #a66cff;
  --board-bg: rgba(30, 80, 160, 0.75);
  --board-border: rgba(255, 255, 255, 0.4);
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  background: #1a1a2e;
  touch-action: manipulation;
  user-select: none;
}

.screen {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
}

.screen.active {
  display: flex;
}

/* ===== Splash Screen ===== */
#splash-screen {
  background: #87ceeb;
}

.splash-bg {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.splash-poster {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
}

.splash-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: linear-gradient(
    to top,
    rgba(0, 0, 0, 0.55) 0%,
    rgba(0, 0, 0, 0.1) 40%,
    transparent 70%
  );
  padding-bottom: max(40px, env(safe-area-inset-bottom));
}

.splash-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 0 24px 24px;
  width: 100%;
  max-width: 420px;
}

.mascot-wave {
  font-size: 48px;
  animation: wave 1.5s ease-in-out infinite;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.3));
}

@keyframes wave {
  0%, 100% { transform: rotate(0deg) scale(1); }
  25% { transform: rotate(-10deg) scale(1.05); }
  75% { transform: rotate(10deg) scale(1.05); }
}

.btn-play {
  background: linear-gradient(180deg, #ff85c8 0%, var(--pink) 50%, var(--pink-dark) 100%);
  border: 3px solid #fff;
  border-radius: 50px;
  padding: 16px 56px;
  cursor: pointer;
  box-shadow:
    0 6px 0 #b8337a,
    0 8px 20px rgba(255, 60, 150, 0.5);
  transition: transform 0.1s, box-shadow 0.1s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.btn-play:active {
  transform: translateY(4px);
  box-shadow:
    0 2px 0 #b8337a,
    0 4px 10px rgba(255, 60, 150, 0.4);
}

.btn-play-text {
  font-size: 22px;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 2px 4px rgba(0,0,0,0.2);
  letter-spacing: 2px;
}

.btn-play-sub {
  font-size: 11px;
  font-weight: 700;
  color: rgba(255,255,255,0.85);
  letter-spacing: 3px;
}

.btn-small {
  padding: 12px 40px;
}

.btn-secondary {
  background: linear-gradient(180deg, #aaa 0%, #888 100%);
  border: 3px solid #fff;
  border-radius: 50px;
  padding: 12px 32px;
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 0 #666;
}

.splash-hint {
  color: rgba(255,255,255,0.9);
  font-size: 13px;
  text-align: center;
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

/* ===== Game Screen ===== */
#game-screen {
  background: linear-gradient(180deg, #87ceeb 0%, #b8e0f5 40%, #90c695 100%);
}

.game-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 20%, rgba(255,255,255,0.4) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 10%, rgba(255,200,100,0.3) 0%, transparent 40%);
  pointer-events: none;
}

.game-header {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  padding-top: max(12px, env(safe-area-inset-top));
  gap: 8px;
}

.btn-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.8);
  background: rgba(255,255,255,0.3);
  font-size: 22px;
  cursor: pointer;
  backdrop-filter: blur(4px);
  flex-shrink: 0;
}

.btn-icon:active {
  transform: scale(0.92);
}

.stat-box {
  background: rgba(255,255,255,0.25);
  border: 2px solid rgba(255,255,255,0.6);
  border-radius: 12px;
  padding: 6px 14px;
  text-align: center;
  backdrop-filter: blur(4px);
  min-width: 64px;
}

.stat-label {
  display: block;
  font-size: 10px;
  color: rgba(255,255,255,0.9);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.stat-value {
  display: block;
  font-size: 20px;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.score-box .stat-value {
  color: var(--yellow);
}

.goal-bar {
  position: relative;
  z-index: 2;
  margin: 0 16px 8px;
  background: rgba(0,0,0,0.25);
  border-radius: 20px;
  padding: 8px 16px;
  color: #fff;
  font-size: 13px;
  backdrop-filter: blur(4px);
}

.goal-bar strong {
  color: var(--yellow);
}

.goal-progress {
  margin-top: 6px;
  height: 8px;
  background: rgba(255,255,255,0.2);
  border-radius: 4px;
  overflow: hidden;
}

.goal-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--green), var(--yellow));
  border-radius: 4px;
  transition: width 0.4s ease;
}

.game-board-wrap {
  position: relative;
  z-index: 2;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px 24px;
  min-height: 0;
}

.game-board {
  display: grid;
  gap: 3px;
  padding: 8px;
  background: var(--board-bg);
  border: 3px solid var(--board-border);
  border-radius: 16px;
  box-shadow:
    0 8px 32px rgba(0,0,0,0.3),
    inset 0 0 20px rgba(255,255,255,0.1);
  width: min(92vw, 380px);
  aspect-ratio: 1;
}

.cell {
  position: relative;
  border-radius: 8px;
  background: rgba(255,255,255,0.08);
  cursor: pointer;
  overflow: hidden;
}

.cell.selected {
  box-shadow: inset 0 0 0 3px var(--yellow);
  z-index: 2;
}

.candy {
  position: absolute;
  inset: 2px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, opacity 0.2s ease;
  pointer-events: none;
}

.candy svg {
  width: 85%;
  height: 85%;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.25));
}

.candy.special-rainbow {
  animation: rainbow-glow 1.2s ease-in-out infinite;
}

.candy.special-striped-h,
.candy.special-striped-v {
  box-shadow: 0 0 8px rgba(255,255,255,0.8);
}

@keyframes rainbow-glow {
  0%, 100% { filter: drop-shadow(0 0 6px #ff6eb4); }
  33% { filter: drop-shadow(0 0 8px #ffd93d); }
  66% { filter: drop-shadow(0 0 8px #54a0ff); }
}

.candy.pop {
  animation: pop 0.35s ease forwards;
}

.candy.swap {
  z-index: 5;
}

@keyframes pop {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.8; }
  100% { transform: scale(0); opacity: 0; }
}

.candy.fall {
  transition: transform 0.25s cubic-bezier(0.34, 1.3, 0.64, 1);
}

.combo-display {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  font-size: 36px;
  font-weight: 900;
  color: var(--yellow);
  text-shadow:
    0 0 10px var(--orange),
    0 3px 6px rgba(0,0,0,0.4);
  pointer-events: none;
  z-index: 100;
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.combo-display.show {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
}

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  backdrop-filter: blur(4px);
}

.modal-overlay.hidden {
  display: none;
}

.modal {
  background: linear-gradient(180deg, #fff5fa 0%, #ffe0f0 100%);
  border: 4px solid #fff;
  border-radius: 24px;
  padding: 32px 28px;
  text-align: center;
  max-width: 320px;
  width: 85%;
  box-shadow: 0 12px 40px rgba(0,0,0,0.3);
  animation: modal-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modal-in {
  from { transform: scale(0.7); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-icon {
  font-size: 56px;
  margin-bottom: 12px;
}

.modal h2 {
  color: var(--pink-dark);
  font-size: 24px;
  margin-bottom: 8px;
}

.modal p {
  color: #666;
  font-size: 15px;
  margin-bottom: 24px;
}

.modal-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}

.modal-buttons .hidden {
  display: none;
}
