*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #eef4ff;
  --surface: #ffffff;
  --primary: #2563eb;
  --board: #2563eb;
  --hole: #eef4ff;
  --red: #ef4444;
  --yellow: #f5c518;
  --text: #1a1a2e;
  --text-light: #6b7280;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  min-height: 100vh;
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

#app {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 20px 16px 32px;
}

.screen { display: none; }
.screen.active { display: block; }

/* ── Mode Select ── */
.logo { text-align: center; padding-top: 24px; margin-bottom: 8px; }
.logo-icon { font-size: 48px; line-height: 1; letter-spacing: 4px; }
.logo h1 { font-size: 38px; font-weight: 800; color: var(--primary); margin-top: 4px; }
.subtitle { text-align: center; color: var(--text-light); font-size: 17px; margin-bottom: 28px; }

.mode-grid { display: flex; flex-direction: column; gap: 14px; }
.mode-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--surface);
  border: 3px solid transparent;
  border-radius: 18px;
  padding: 18px 20px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: transform 0.12s, box-shadow 0.12s;
  box-shadow: 0 2px 10px rgba(37, 99, 235, 0.08);
}
.mode-card:hover { transform: translateY(-3px); box-shadow: 0 8px 22px rgba(37, 99, 235, 0.16); }
.mode-card:active { transform: scale(0.98); }
.two-player-card { border-color: #93c5fd; }
.easy-card { border-color: #6ee7b7; }
.hard-card { border-color: #fca5a5; }
.mode-emoji { font-size: 40px; line-height: 1; }
.mode-name { font-size: 20px; font-weight: 700; }
.mode-details { font-size: 14px; color: var(--text-light); margin-top: 2px; }

/* ── Top bar ── */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.icon-btn {
  flex-shrink: 0;
  width: 44px; height: 44px;
  border: none; border-radius: 12px;
  background: var(--surface); color: var(--text);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}
.icon-btn:active { transform: scale(0.94); }
.icon-btn svg { width: 22px; height: 22px; }

.scoreboard { flex: 1; display: flex; justify-content: center; gap: 10px; }
.score-box {
  background: var(--surface);
  border-radius: 12px;
  padding: 6px 14px;
  text-align: center;
  min-width: 60px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}
.score-mark { font-size: 18px; line-height: 1; }
.score-val { font-size: 20px; font-weight: 800; margin-top: 2px; }
.score-red .score-val { color: var(--red); }
.score-yellow .score-val { color: #d4a200; }

.turn-badge {
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  padding: 10px;
  margin-bottom: 14px;
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

/* ── Board ── */
#board-wrap { max-width: 460px; margin: 0 auto; }

#drop-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  padding: 0 10px;
  margin-bottom: 4px;
}
.drop-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: min(28px, 5.5vw);
  height: 32px;
  color: var(--text-light);
  opacity: 0;
  transition: opacity 0.12s, transform 0.12s;
}
.drop-btn.show { opacity: 0.85; }
.drop-btn:active { transform: translateY(3px); }

#board {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  background: var(--board);
  border-radius: 18px;
  padding: 10px;
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.25);
}
.slot {
  aspect-ratio: 1;
  background: var(--hole);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.15);
}
.disc {
  width: 86%;
  height: 86%;
  border-radius: 50%;
  position: absolute;
}
.disc.red { background: radial-gradient(circle at 35% 30%, #ff7676, var(--red)); }
.disc.yellow { background: radial-gradient(circle at 35% 30%, #ffe27a, var(--yellow)); }
.disc.drop { animation: dropIn 0.35s cubic-bezier(0.5, 0, 0.7, 1.4); }
@keyframes dropIn {
  0% { transform: translateY(-420px); }
  100% { transform: translateY(0); }
}
.slot.win .disc {
  animation: winpulse 0.6s ease infinite alternate;
}
@keyframes winpulse {
  from { transform: scale(1); }
  to { transform: scale(1.12); box-shadow: 0 0 18px rgba(255,255,255,0.95); }
}

/* ── Win overlay ── */
#win-screen {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  align-items: center;
  justify-content: center;
  z-index: 100;
}
#win-screen.show { display: flex; }
.win-content {
  background: var(--surface);
  border-radius: 24px;
  padding: 36px 32px;
  text-align: center;
  max-width: 340px;
  width: 88%;
  animation: popUp 0.3s ease;
}
@keyframes popUp {
  0% { transform: scale(0.5); }
  70% { transform: scale(1.08); }
  100% { transform: scale(1); }
}
.win-emoji { font-size: 64px; line-height: 1; }
.win-content h2 { font-size: 28px; margin: 14px 0 24px; }
.primary-btn, .secondary-btn {
  display: block;
  width: 100%;
  border: none;
  border-radius: 14px;
  padding: 14px;
  font-size: 17px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  margin-top: 10px;
}
.primary-btn { background: var(--primary); color: white; }
.primary-btn:active { transform: scale(0.97); }
.secondary-btn { background: #e5e7eb; color: var(--text); }
.secondary-btn:active { transform: scale(0.97); }
