/* ===== Four in a Heart — cute pink theme, all icons are SVG (no emoji) ===== */

:root {
  --heart: #ff4d6d;
  --heart-soft: #ffd6e0;
  --star: #7c5cff;
  --star-soft: #e2dbff;
  --ink: #4a2c3a;
  --ink-soft: #9a7b88;
  --board: #ff8fb0;
  --board-deep: #ff6f9c;
  --card: #ffffff;
  --bg1: #ffe3ef;
  --bg2: #f3e6ff;
  --shadow: 0 18px 40px rgba(214, 51, 108, 0.18);
  --radius: 22px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 700px at 15% -10%, var(--bg1), transparent 60%),
    radial-gradient(1000px 700px at 100% 0%, var(--bg2), transparent 55%),
    linear-gradient(160deg, #fff2f7, #f6edff);
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  padding: 24px 16px 8px;
}

.app {
  width: 100%;
  max-width: 460px;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- Screens ---------- */
.screen { display: none; width: 100%; animation: pop 0.35s ease; }
.screen.active { display: block; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 30px 26px;
  text-align: center;
}

@keyframes pop {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}

/* ---------- Typography ---------- */
.title { font-size: 1.7rem; margin: 6px 0 4px; letter-spacing: -0.02em; }
.subtitle { color: var(--ink-soft); margin: 0 0 22px; font-size: 0.98rem; }
.hint { color: var(--ink-soft); font-size: 0.82rem; margin: 16px 0 0; }
.status { min-height: 1.2em; margin: 14px 0 0; font-size: 0.9rem; color: var(--heart); font-weight: 600; }

.brand {
  width: 68px; height: 62px; margin: 0 auto 8px;
  animation: beat 1.6s ease-in-out infinite;
}
@keyframes beat {
  0%, 100% { transform: scale(1); }
  15% { transform: scale(1.12); }
  30% { transform: scale(1); }
}

/* ---------- Fields ---------- */
.field { display: block; text-align: left; margin: 0 auto 8px; }
.field span { display: block; font-size: 0.8rem; color: var(--ink-soft); margin: 0 0 6px 4px; }
.field input {
  width: 100%;
  padding: 13px 16px;
  border: 2px solid var(--heart-soft);
  border-radius: 14px;
  font-size: 1.05rem;
  color: var(--ink);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.field input:focus { border-color: var(--heart); box-shadow: 0 0 0 4px rgba(255, 77, 109, 0.15); }
#join-input { text-transform: uppercase; letter-spacing: 0.12em; text-align: center; font-weight: 700; }

/* ---------- Buttons ---------- */
.btn {
  border: none;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  padding: 13px 20px;
  border-radius: 14px;
  transition: transform 0.12s, box-shadow 0.2s, background 0.2s;
}
.btn:active { transform: scale(0.96); }
.btn-primary {
  background: linear-gradient(135deg, var(--heart), #ff7aa0);
  color: #fff;
  box-shadow: 0 10px 22px rgba(255, 77, 109, 0.35);
}
.btn-primary:hover { box-shadow: 0 12px 26px rgba(255, 77, 109, 0.45); }
.btn-ghost { background: var(--heart-soft); color: var(--heart); }
.btn-ghost:hover { background: #ffc4d4; }
.btn-row { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
.btn-back { margin-top: 14px; }

/* ---------- Code box ---------- */
.code-box {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  background: var(--heart-soft);
  border-radius: 16px;
  padding: 16px 18px;
  margin: 6px 0 4px;
}
.code {
  font-size: 2rem; font-weight: 800; letter-spacing: 0.18em;
  color: var(--heart);
}
.btn-copy {
  width: 42px; height: 42px; padding: 0;
  display: grid; place-items: center;
  background: #fff; color: var(--heart);
  box-shadow: 0 4px 10px rgba(255, 77, 109, 0.2);
}
.copy-feedback { min-height: 1em; color: var(--heart); font-weight: 600; font-size: 0.85rem; margin: 4px 0 0; }

/* ---------- Waiting dots ---------- */
.waiting { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 22px 0 4px; color: var(--ink-soft); }
.waiting-text { margin-left: 8px; font-size: 0.9rem; }
.dot {
  width: 9px; height: 9px; border-radius: 50%; background: var(--heart);
  animation: blink 1.2s infinite ease-in-out;
}
.dot:nth-child(2) { animation-delay: 0.2s; }
.dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

/* ---------- Scoreboard ---------- */
.scoreboard {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  margin-bottom: 12px;
}
.player {
  display: flex; align-items: center; gap: 8px;
  background: #fff; padding: 8px 14px; border-radius: 999px;
  box-shadow: var(--shadow); font-weight: 700;
  transition: transform 0.2s, box-shadow 0.2s;
}
.player.active-turn { transform: translateY(-2px) scale(1.04); box-shadow: 0 12px 26px rgba(255, 77, 109, 0.3); }
.pname { max-width: 8ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vs { color: var(--ink-soft); font-weight: 700; }
.pill { width: 24px; height: 24px; display: inline-block; }

.turn-banner {
  text-align: center; font-weight: 700; color: var(--heart);
  margin: 0 0 14px; min-height: 1.3em; font-size: 1.05rem;
}

/* ---------- Board ---------- */
.board {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: clamp(4px, 1.6vw, 9px);
  background: linear-gradient(160deg, var(--board), var(--board-deep));
  padding: clamp(8px, 2.4vw, 14px);
  border-radius: 20px;
  box-shadow: var(--shadow), inset 0 2px 6px rgba(255, 255, 255, 0.4);
  width: 100%;
  max-width: 440px;
  margin: 0 auto;
}
.cell {
  aspect-ratio: 1 / 1;
  background: #fff;
  border-radius: 50%;
  box-shadow: inset 0 3px 6px rgba(214, 51, 108, 0.18);
  display: grid; place-items: center;
  cursor: pointer;
  position: relative;
}
.cell.col-hover { box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.9), inset 0 3px 6px rgba(214, 51, 108, 0.18); }
.cell svg { width: 78%; height: 78%; }
.cell .token { animation: drop 0.4s cubic-bezier(0.34, 1.3, 0.7, 1); }
@keyframes drop {
  from { transform: translateY(-340px); }
  to   { transform: translateY(0); }
}
.cell.win svg { animation: winpulse 0.8s ease-in-out infinite; filter: drop-shadow(0 0 6px rgba(255,255,255,0.9)); }
@keyframes winpulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.18); }
}
.board.locked .cell { cursor: default; }

.game-actions { display: flex; justify-content: center; margin-top: 18px; }
.btn-heart {
  background: #fff; color: var(--heart);
  box-shadow: var(--shadow);
  display: inline-flex; align-items: center; gap: 8px;
}
.btn-heart svg { width: 18px; height: 18px; }

/* ---------- Win overlay ---------- */
.overlay {
  position: fixed; inset: 0;
  background: rgba(74, 44, 58, 0.45);
  backdrop-filter: blur(3px);
  display: none; align-items: center; justify-content: center;
  padding: 20px; z-index: 50;
}
.overlay.show { display: flex; animation: pop 0.3s ease; }
.win-card { max-width: 380px; position: relative; overflow: hidden; }
.win-title { font-size: 1.6rem; margin: 4px 0 10px; }
.win-message { color: var(--ink-soft); font-size: 1.05rem; line-height: 1.5; margin: 0 0 22px; }
.win-burst { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }

/* Floating hearts (send-a-heart + win burst) */
#heart-rain { position: fixed; inset: 0; pointer-events: none; z-index: 40; overflow: hidden; }
.float-heart { position: absolute; width: 28px; height: 26px; animation: floatUp 2.4s ease-in forwards; }
@keyframes floatUp {
  0%   { transform: translateY(0) scale(0.6) rotate(0deg); opacity: 0; }
  15%  { opacity: 1; }
  100% { transform: translateY(-90vh) scale(1.1) rotate(20deg); opacity: 0; }
}

.footer { color: var(--ink-soft); font-size: 0.78rem; margin: 20px 0 6px; text-align: center; }

@media (max-width: 380px) {
  .card { padding: 24px 18px; }
  .code { font-size: 1.6rem; }
}
