:root {
  --bg-top: #2c1240;
  --bg-bot: #4a1450;
  --berry: #ff4d97;
  --berry-deep: #c81e6e;
  --grape: #7b51ff;
  --mint: #36e0c0;
  --gold: #ffd24a;
  --ink: #2a0e3a;
  --card: rgba(255, 255, 255, 0.08);
  --card-line: rgba(255, 255, 255, 0.16);
  --text: #fff7fc;
  --muted: #d7b9e6;
  --shadow: 0 18px 40px rgba(20, 0, 30, 0.5);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }

body {
  font-family: "Nunito", system-ui, sans-serif;
  color: var(--text);
  background:
    radial-gradient(120% 90% at 15% 0%, #5a1e6a 0%, transparent 55%),
    radial-gradient(120% 90% at 90% 100%, #b3246e 0%, transparent 50%),
    linear-gradient(160deg, var(--bg-top), var(--bg-bot));
  background-attachment: fixed;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

#app {
  height: 100dvh;
  max-width: 560px;
  margin: 0 auto;
  position: relative;
  padding: env(safe-area-inset-top) 16px env(safe-area-inset-bottom);
}

/* ---------- screens ---------- */
.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  padding: max(24px, env(safe-area-inset-top)) 18px 24px;
  animation: fade .35s ease;
}
.screen.active { display: flex; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; } }
.hidden { display: none !important; }

/* ---------- branding ---------- */
.brand { text-align: center; margin-top: 6vh; }
.logo {
  font-family: "Baloo 2", cursive;
  font-weight: 800;
  font-size: clamp(2.6rem, 12vw, 4rem);
  line-height: .95;
  margin: 0;
  letter-spacing: -1px;
  background: linear-gradient(180deg, #fff 10%, var(--gold) 60%, var(--berry) 110%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 6px 0 rgba(200, 30, 110, .35));
}
.logo span { display: block; font-size: .62em;
  background: linear-gradient(180deg, var(--mint), #2ea7ff);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 4px 0 rgba(0, 80, 120, .3)); }
.tagline { color: var(--muted); font-weight: 700; letter-spacing: .04em;
  margin-top: 10px; font-size: .85rem; }

.who { font-family: "Baloo 2", cursive; font-weight: 700;
  font-size: 1.5rem; margin: 7vh 0 18px; }

/* ---------- profile cards ---------- */
.profile-list { display: flex; flex-direction: column; gap: 14px; width: 100%; max-width: 380px; }
.profile-card {
  display: flex; align-items: center; gap: 16px;
  padding: 16px 18px; border-radius: 22px;
  background: var(--card); border: 1px solid var(--card-line);
  backdrop-filter: blur(6px);
  box-shadow: var(--shadow);
  cursor: pointer; transition: transform .12s ease, background .2s;
}
.profile-card:active { transform: scale(.97); }
.profile-card:hover { background: rgba(255,255,255,.13); }
.profile-card .pa { font-size: 2.2rem; filter: drop-shadow(0 3px 4px rgba(0,0,0,.3)); }
.profile-card .pinfo { flex: 1; }
.profile-card .pname { font-family: "Baloo 2", cursive; font-weight: 700; font-size: 1.25rem; }
.profile-card .pmeta { color: var(--muted); font-size: .82rem; font-weight: 700; }
.profile-card .pdel { opacity: .55; font-size: 1.1rem; padding: 6px; background: none;
  border: none; color: var(--text); cursor: pointer; }
.profile-card .pdel:active { opacity: 1; }

.add-card {
  justify-content: center; gap: 10px; border-style: dashed;
  background: transparent; color: var(--muted); font-weight: 800;
  font-family: "Baloo 2", cursive; font-size: 1.05rem;
}
.add-card .plus { font-size: 1.6rem; line-height: 1; }

.offline-note { color: var(--gold); font-weight: 800; font-size: .8rem;
  margin-top: 20px; text-align: center; }

/* ---------- new profile ---------- */
.back-btn { position: absolute; top: max(20px, env(safe-area-inset-top)); left: 16px;
  background: none; border: none; color: var(--muted); font-weight: 800;
  font-size: 1.1rem; cursor: pointer; }
.avatar-pick { display: grid; grid-template-columns: repeat(5, 1fr);
  gap: 10px; width: 100%; max-width: 360px; margin-bottom: 22px; }
.avatar-pick button {
  font-size: 1.8rem; aspect-ratio: 1; border-radius: 16px;
  background: var(--card); border: 2px solid transparent; cursor: pointer;
  transition: transform .1s, border-color .15s, background .15s;
}
.avatar-pick button:active { transform: scale(.9); }
.avatar-pick button.sel { border-color: var(--gold); background: rgba(255,210,74,.18); }
.name-input {
  width: 100%; max-width: 360px; padding: 15px 18px; font-size: 1.1rem;
  font-family: "Baloo 2", cursive; font-weight: 600;
  border-radius: 16px; border: 1px solid var(--card-line);
  background: rgba(0,0,0,.22); color: var(--text); outline: none; margin-bottom: 18px;
}
.name-input::placeholder { color: rgba(215,185,230,.6); }

.btn-primary {
  font-family: "Baloo 2", cursive; font-weight: 800; font-size: 1.2rem;
  color: #4a0c2e; padding: 15px 34px; border: none; border-radius: 50px;
  background: linear-gradient(180deg, #ffe07a, var(--gold));
  box-shadow: 0 8px 0 var(--berry-deep), 0 14px 24px rgba(200,30,110,.45);
  cursor: pointer; transition: transform .08s, box-shadow .08s;
}
.btn-primary:active { transform: translateY(5px); box-shadow: 0 3px 0 var(--berry-deep); }

/* ---------- game HUD ---------- */
#screen-game { padding-top: max(14px, env(safe-area-inset-top)); }
.hud {
  display: flex; align-items: stretch; gap: 10px; width: 100%;
  margin-bottom: 14px;
}
.icon-btn {
  width: 44px; border-radius: 16px; border: 1px solid var(--card-line);
  background: var(--card); color: var(--text); font-size: 1.6rem;
  font-family: "Baloo 2"; cursor: pointer;
}
.icon-btn:active { transform: scale(.93); }
.hud-block {
  background: var(--card); border: 1px solid var(--card-line);
  border-radius: 16px; padding: 8px 14px; min-width: 62px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.hud-block.grow { flex: 1; align-items: stretch; }
.hud-label { font-size: .65rem; font-weight: 800; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted); }
.hud-label em { font-style: normal; color: var(--mint); }
.hud-value { font-family: "Baloo 2", cursive; font-weight: 800; font-size: 1.4rem; line-height: 1.1; }
.grow .hud-value { font-size: 1.5rem; }
.progress { height: 7px; border-radius: 6px; background: rgba(0,0,0,.3); margin-top: 5px; overflow: hidden; }
.progress-fill { height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--mint), var(--gold));
  border-radius: 6px; transition: width .35s ease; }

/* ---------- board ---------- */
.board-wrap { position: relative; width: 100%; flex: 1;
  display: flex; align-items: center; justify-content: center; }
#board {
  width: min(92vw, 480px); height: min(92vw, 480px);
  border-radius: 26px;
  background:
    repeating-linear-gradient(45deg, rgba(255,255,255,.04) 0 12px, transparent 12px 24px),
    rgba(0,0,0,.22);
  border: 1px solid var(--card-line);
  box-shadow: inset 0 2px 14px rgba(0,0,0,.4), var(--shadow);
  touch-action: none;
}
.combo-pop {
  position: absolute; font-family: "Baloo 2", cursive; font-weight: 800;
  font-size: 2rem; color: var(--gold); pointer-events: none;
  text-shadow: 0 3px 0 var(--berry-deep), 0 0 18px rgba(255,210,74,.6);
  opacity: 0;
}
.combo-pop.go { animation: combo 1s ease forwards; }
@keyframes combo {
  0% { opacity: 0; transform: translateY(10px) scale(.6); }
  25% { opacity: 1; transform: translateY(-6px) scale(1.15); }
  100% { opacity: 0; transform: translateY(-50px) scale(1); }
}

/* ---------- game footer ---------- */
.game-foot { display: flex; align-items: center; justify-content: space-between;
  width: 100%; margin-top: 14px; gap: 10px; }
.foot-left { display: inline-flex; align-items: center; gap: 10px; min-width: 0; }
.foot-right { display: inline-flex; align-items: center; gap: 8px; }
.player-chip { display: inline-flex; align-items: center; gap: 8px;
  font-weight: 800; color: var(--muted); font-size: .95rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.streak-chip { font-weight: 800; font-size: .95rem; color: var(--gold);
  white-space: nowrap; }
.mini-btn { background: var(--card); border: 1px solid var(--card-line);
  color: var(--text); font-weight: 800; font-family: "Nunito";
  padding: 9px 14px; border-radius: 14px; cursor: pointer; }
#sound-btn { padding: 9px 12px; font-size: 1.05rem; }
.mini-btn:active { transform: scale(.95); }

/* ---------- overlay ---------- */
.overlay { position: absolute; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  background: rgba(15,2,25,.72); backdrop-filter: blur(8px); animation: fade .3s ease; }
.overlay-card {
  text-align: center; width: min(86vw, 360px); padding: 30px 26px;
  border-radius: 28px; background: linear-gradient(180deg, rgba(255,255,255,.14), rgba(255,255,255,.06));
  border: 1px solid var(--card-line); box-shadow: var(--shadow);
}
.overlay-emoji { font-size: 3.4rem; animation: pop .5s ease; }
@keyframes pop { 0% { transform: scale(0); } 70% { transform: scale(1.25); } 100% { transform: scale(1); } }
.overlay-card h2 { font-family: "Baloo 2", cursive; font-weight: 800; font-size: 1.9rem; margin: 6px 0 4px; }
.overlay-card p { color: var(--muted); font-weight: 700; margin: 0 0 16px; }
.overlay-stats { display: flex; justify-content: center; gap: 22px; margin-bottom: 22px; }
.overlay-stats div { display: flex; flex-direction: column; }
.overlay-stats b { font-family: "Baloo 2"; font-size: 1.5rem; }
.overlay-stats small { color: var(--muted); font-weight: 800; font-size: .7rem;
  text-transform: uppercase; letter-spacing: .06em; }
