:root {
  --ink: #2b2250;
  --muted: #6b6390;
  --card: #ffffff;
  --sky-1: #7b5cff;
  --sky-2: #ff6fb5;
  --sky-3: #ffb547;
  --green: #2ecc71;
  --blue: #3fa7ff;
  --orange: #ff9a2e;
  --purple: #8e5cff;
  --pink: #ff5fa2;
  --red: #ff4d5e;
  --radius: 28px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

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

body {
  font-family: 'Fredoka', 'Comic Sans MS', system-ui, sans-serif;
  color: var(--ink);
  background: linear-gradient(160deg, var(--sky-1) 0%, var(--sky-2) 55%, var(--sky-3) 100%) fixed;
  background-color: var(--sky-1);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  overflow-x: hidden;
}

/* Floating background bubbles */
.blobs { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.blobs span {
  position: absolute; border-radius: 50%; opacity: .25; background: #fff;
  animation: float 14s ease-in-out infinite;
}
.blobs span:nth-child(1) { width: 220px; height: 220px; left: -60px; top: 8%; }
.blobs span:nth-child(2) { width: 140px; height: 140px; right: -30px; top: 30%; animation-delay: -4s; background: #ffe066; }
.blobs span:nth-child(3) { width: 260px; height: 260px; left: 40%; bottom: -120px; animation-delay: -8s; background: #8ef0c4; }
.blobs span:nth-child(4) { width: 90px; height: 90px; left: 12%; bottom: 18%; animation-delay: -2s; background: #9fd4ff; }
@keyframes float { 50% { transform: translateY(-30px) scale(1.06); } }

#app {
  position: relative; z-index: 1;
  max-width: 560px; margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px max(32px, env(safe-area-inset-bottom));
}

.top { display: flex; align-items: center; justify-content: center; position: relative; margin: 8px 0 18px; padding: 0 52px; }
.logo {
  margin: 0; font-size: clamp(1.5rem, 7.5vw, 3.2rem); white-space: nowrap; font-weight: 700; color: #fff;
  letter-spacing: 1px; text-shadow: 0 4px 0 rgba(43, 34, 80, .35);
}
.logo-face { display: inline-block; animation: peek 3s ease-in-out infinite; }
@keyframes peek { 0%, 70%, 100% { transform: rotate(0); } 80% { transform: rotate(-14deg); } 90% { transform: rotate(10deg); } }

.icon-btn {
  position: absolute; right: 0; top: 50%; transform: translateY(-50%);
  width: 48px; height: 48px; border-radius: 50%; border: 0; font-size: 1.4rem;
  background: rgba(255, 255, 255, .85); box-shadow: 0 4px 0 rgba(43, 34, 80, .25); cursor: pointer;
}
.icon-btn.left { right: auto; left: 0; }

.screen { display: flex; flex-direction: column; gap: 18px; animation: slide-in .35s ease-out; }
.screen[hidden] { display: none; }
@keyframes slide-in { from { opacity: 0; transform: translateY(16px) scale(.98); } }

.card {
  background: var(--card); border-radius: var(--radius); padding: 22px 20px;
  box-shadow: 0 8px 0 rgba(43, 34, 80, .18), 0 18px 40px rgba(43, 34, 80, .18);
}
.card.center { text-align: center; }
h2 { margin: 0 0 12px; font-size: 1.7rem; }
h3 { margin: 0 0 10px; font-size: 1.3rem; }
p { font-size: 1.15rem; line-height: 1.45; margin: 8px 0; }
.hint { color: var(--muted); font-size: 1rem; }
.msg { min-height: 1.4em; margin: 6px 0 0; color: var(--red); font-weight: 600; font-size: 1rem; }

/* Buttons: chunky and squishy */
.btn {
  font: inherit; font-weight: 700; border: 0; cursor: pointer; color: #fff;
  border-radius: 999px; padding: 14px 22px; font-size: 1.15rem;
  box-shadow: 0 6px 0 rgba(0, 0, 0, .22);
  transition: transform .08s, box-shadow .08s, filter .15s;
  user-select: none;
}
.btn:active:not(:disabled) { transform: translateY(5px); box-shadow: 0 1px 0 rgba(0, 0, 0, .22); }
.btn:disabled { filter: grayscale(.8) opacity(.6); cursor: not-allowed; }
.btn:focus-visible, .icon-btn:focus-visible, input:focus-visible, .vote-btn:focus-visible, .remove-btn:focus-visible {
  outline: 4px solid #ffe066; outline-offset: 3px;
}
.btn.big { font-size: 1.6rem; padding: 20px 24px; width: 100%; box-shadow: 0 8px 0 rgba(0, 0, 0, .22); }
.btn.big:active:not(:disabled) { transform: translateY(7px); }
.btn.small { font-size: 1.05rem; padding: 12px 18px; }
.btn.green { background: var(--green); }
.btn.blue { background: var(--blue); }
.btn.orange { background: var(--orange); }
.btn.purple { background: var(--purple); }
.btn.pink { background: var(--pink); }
.btn.red { background: var(--red); }
.btn.ghost { background: rgba(255, 255, 255, .85); color: var(--ink); align-self: center; }

/* Setup */
.add-form { display: flex; gap: 10px; }
.add-form input {
  flex: 1; min-width: 0; font: inherit; font-size: 1.25rem; padding: 12px 18px;
  border-radius: 999px; border: 3px solid #e4defc; background: #f7f5ff; color: var(--ink);
}
.add-form input:focus { border-color: var(--purple); outline: none; }
.shake { animation: shake .4s; }
@keyframes shake { 25% { transform: translateX(-8px); } 50% { transform: translateX(8px); } 75% { transform: translateX(-4px); } }

.player-list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 10px; }
.player-list li {
  display: flex; align-items: center; gap: 12px; padding: 8px 10px 8px 8px;
  border-radius: 999px; background: #f7f5ff; font-size: 1.25rem; font-weight: 600;
  animation: slide-in .25s ease-out;
}
.player-list .name { flex: 1; overflow-wrap: anywhere; }
.remove-btn {
  width: 40px; height: 40px; border-radius: 50%; border: 0; cursor: pointer; flex-shrink: 0;
  background: #ffe1e5; color: var(--red); font-size: 1.2rem; font-weight: 700;
}
.empty { color: var(--muted); text-align: center; padding: 10px; font-size: 1.1rem; }

.avatar {
  width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; font-weight: 700; font-size: 1.3rem; color: var(--ink);
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .12);
}
.avatar.huge { width: 120px; height: 120px; font-size: 3.6rem; margin: 6px auto 14px; animation: bounce 1.6s ease-in-out infinite; }
@keyframes bounce { 50% { transform: translateY(-8px); } }

/* Secret */
.secret-card { min-height: 280px; display: flex; flex-direction: column; justify-content: center; }
.big-emoji { font-size: 4.5rem; line-height: 1.1; margin-bottom: 8px; }
.thing { font-size: clamp(2rem, 9vw, 2.8rem); font-weight: 700; color: var(--purple); margin: 6px 0; }
.category-chip {
  display: inline-block; background: #fff1c2; color: #7a5300; font-weight: 700;
  padding: 6px 16px; border-radius: 999px; font-size: 1.1rem;
}
.imposter-word { font-size: clamp(2rem, 9vw, 2.8rem); font-weight: 700; color: var(--red); margin: 4px 0; }

/* Discuss */
.steps { text-align: left; font-size: 1.15rem; line-height: 1.5; padding-left: 1.4em; margin: 12px 0 0; }
.steps li { margin-bottom: 8px; }

/* Vote */
.vote-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; margin-top: 14px; }
.vote-btn {
  font: inherit; font-weight: 600; font-size: 1.15rem; color: var(--ink); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 14px 8px; border-radius: 22px; border: 4px solid transparent; background: #f7f5ff;
  transition: transform .12s, border-color .12s;
  overflow-wrap: anywhere;
}
.vote-btn .avatar { width: 60px; height: 60px; font-size: 1.8rem; }
.vote-btn[aria-pressed="true"] { border-color: var(--red); background: #ffe8eb; transform: scale(1.05); }

/* Result */
.drumroll .wobble { animation: wobble .25s linear infinite; }
@keyframes wobble { 50% { transform: rotate(-8deg) scale(1.05); } }
.pop { animation: pop .5s cubic-bezier(.3, 1.8, .5, 1); }
@keyframes pop { from { transform: scale(0); } }
.thing-reveal { margin-top: 16px; padding: 14px; border-radius: 20px; background: #f3efff; font-size: 1.05rem; color: var(--muted); }
#result-extra { display: flex; flex-direction: column; gap: 18px; }
#result-extra[hidden] { display: none; }

.scores-card { display: flex; flex-direction: column; }
.score-list { list-style: none; margin: 0 0 6px; padding: 0; display: grid; gap: 8px; text-align: left; }
.score-list li { display: flex; align-items: center; gap: 12px; font-size: 1.2rem; font-weight: 600; }
.score-list .avatar { width: 38px; height: 38px; font-size: 1.1rem; }
.score-list .name { flex: 1; overflow-wrap: anywhere; }
.score-list .pts { font-size: 1.35rem; min-width: 2ch; text-align: right; }
.plus { color: var(--green); font-weight: 700; font-size: 1rem; animation: pop .5s .3s both cubic-bezier(.3, 1.8, .5, 1); }

/* Home menu and accounts */
.menu { display: flex; flex-direction: column; gap: 16px; margin-top: 8px; }
.account-card { display: flex; flex-direction: column; gap: 12px; }
.account-status { margin: 0; font-weight: 600; }
.account-buttons { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.form-card { display: flex; flex-direction: column; gap: 8px; }
.form-card label { font-weight: 600; font-size: 1.05rem; margin-top: 6px; }
.form-card .btn.big { margin-top: 6px; }
.text-input {
  width: 100%; font: inherit; font-size: 1.2rem; padding: 12px 18px;
  border-radius: 999px; border: 3px solid #e4defc; background: #f7f5ff; color: var(--ink);
}
.text-input:focus { border-color: var(--purple); outline: none; }
.link-btn {
  font: inherit; font-weight: 700; color: var(--purple); background: none; border: 0;
  padding: 4px; cursor: pointer; text-decoration: underline;
}
.link-btn:focus-visible, .text-input:focus-visible { outline: 4px solid #ffe066; outline-offset: 3px; }

/* Online games */
.notice {
  margin: 0; padding: 12px 18px; border-radius: 20px; background: #fff7d6; color: #6b4e00;
  font-weight: 600; font-size: 1.05rem; text-align: center;
}
.card .notice { margin-bottom: 12px; }
.mode-btn { display: flex; flex-direction: column; gap: 4px; }
.mode-btn small { font-size: .95rem; font-weight: 600; opacity: .9; }
.code-input { text-transform: uppercase; letter-spacing: .4em; font-size: 1.8rem; text-align: center; font-weight: 700; }
#join-name-row { gap: 8px; }
.game-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.code-chip, .mode-chip {
  background: rgba(255, 255, 255, .9); border-radius: 999px; padding: 6px 16px; font-weight: 600;
  box-shadow: 0 4px 0 rgba(43, 34, 80, .2);
}
.code-chip strong { letter-spacing: .15em; color: var(--purple); }
.online-main { display: flex; flex-direction: column; gap: 18px; }
.big-code { font-size: clamp(3rem, 16vw, 4.5rem); font-weight: 700; letter-spacing: .2em; color: var(--purple); margin: 0 0 4px .2em; }
.my-word { font-size: 1.8rem; font-weight: 700; color: var(--purple); margin: 4px 0; overflow-wrap: anywhere; }
.wobble-slow { animation: wobble 1.2s ease-in-out infinite; display: inline-block; }
.word-form label { font-size: 1.15rem; }

.word-list, .vote-results { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 8px; text-align: left; }
.word-list li {
  display: flex; align-items: center; gap: 10px; padding: 6px 12px 6px 6px; border-radius: 999px;
  background: #f7f5ff; font-weight: 600;
}
.word-list li.me { background: #efe8ff; }
.word-list .avatar, .vote-row .avatar { width: 36px; height: 36px; font-size: 1.1rem; }
.word-list .name, .vote-row .name { flex-shrink: 0; max-width: 40%; overflow-wrap: anywhere; }
.word-list .word, .vote-row .word { flex: 1; text-align: right; color: var(--purple); font-weight: 700; overflow-wrap: anywhere; }

.vote-list { display: grid; gap: 10px; margin-top: 12px; }
.vote-row {
  font: inherit; font-size: 1.1rem; font-weight: 600; color: var(--ink); cursor: pointer;
  display: flex; align-items: center; gap: 10px; padding: 8px 14px 8px 8px; text-align: left;
  border-radius: 999px; border: 4px solid transparent; background: #f7f5ff;
  transition: transform .12s, border-color .12s;
}
.vote-row[aria-pressed="true"] { border-color: var(--red); background: #ffe8eb; transform: scale(1.02); }
.vote-row:disabled { opacity: .55; cursor: default; }
.vote-row:focus-visible { outline: 4px solid #ffe066; outline-offset: 3px; }

.vote-results li { display: flex; justify-content: space-between; gap: 10px; padding: 6px 4px; font-weight: 600; border-bottom: 2px dashed #ece8fb; }
.vote-results li.correct { color: #1d8a4c; }
.player-list .status { font-size: 1.2rem; }
.player-list .pts { font-weight: 700; min-width: 2ch; text-align: right; }
.host-tools { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.winners { display: flex; justify-content: center; gap: 18px; flex-wrap: wrap; margin: 10px 0 4px; }
.winner { display: flex; flex-direction: column; align-items: center; gap: 4px; font-weight: 700; font-size: 1.2rem; }
.winner-crown { font-size: 2.2rem; line-height: 1; animation: bounce 1.6s ease-in-out infinite; }
.avatar.big { width: 72px; height: 72px; font-size: 2rem; }
.winner-line { font-size: 1.35rem; font-weight: 700; color: var(--purple); }

/* "Are you sure?" box */
.ask-dialog {
  border: 0; border-radius: var(--radius); padding: 24px 20px; width: min(92vw, 400px);
  text-align: center; color: var(--ink); font-family: inherit;
  box-shadow: 0 8px 0 rgba(43, 34, 80, .18), 0 18px 40px rgba(43, 34, 80, .3);
}
.ask-dialog[open] { animation: pop .3s cubic-bezier(.3, 1.6, .5, 1); }
.ask-dialog::backdrop { background: rgba(43, 34, 80, .55); }
.ask-dialog p { font-size: 1.25rem; font-weight: 600; margin: 4px 0 20px; }
.ask-buttons { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.ask-buttons .btn { flex: 1; min-width: 130px; }
.ask-dialog .btn.ghost { background: #efeafc; }

/* Confetti */
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 10; overflow: hidden; }
#confetti span { position: absolute; top: -40px; font-size: 1.8rem; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
