:root {
  --navy: #0A1A4F;
  --deep: #071238;
  --blue: #1D4ED8;
  --sky: #38BDF8;
  --ice: #E0F2FE;
  --card: rgba(255, 255, 255, 0.08);
  --card-strong: rgba(255, 255, 255, 0.14);
  --line: rgba(255, 255, 255, 0.16);
  --text: #FFFFFF;
  --muted: #A9BCE8;
  --crush: #FF4D8D;
  --cruche: #FFC93C;
  --veto: #B794F6;
  --ok: #7CF29A;
  --radius: 18px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { margin: 0; height: 100%; }

body {
  background: radial-gradient(120% 80% at 50% 0%, #2557E8 0%, var(--navy) 55%, var(--deep) 100%) fixed;
  background-color: var(--deep);
  color: var(--text);
  font-family: Inter, system-ui, sans-serif;
  display: flex;
  justify-content: center;
  overflow: hidden;
}

.bubbles { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 0; }
.bubbles i {
  position: absolute; bottom: -80px; border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, rgba(255,255,255,.35), rgba(56,189,248,.08));
  animation: rise linear infinite;
}
.bubbles i:nth-child(1) { left: 8%; width: 46px; height: 46px; animation-duration: 17s; }
.bubbles i:nth-child(2) { left: 26%; width: 20px; height: 20px; animation-duration: 12s; animation-delay: 3s; }
.bubbles i:nth-child(3) { left: 48%; width: 64px; height: 64px; animation-duration: 22s; animation-delay: 6s; }
.bubbles i:nth-child(4) { left: 67%; width: 28px; height: 28px; animation-duration: 14s; animation-delay: 1s; }
.bubbles i:nth-child(5) { left: 82%; width: 38px; height: 38px; animation-duration: 19s; animation-delay: 8s; }
.bubbles i:nth-child(6) { left: 92%; width: 16px; height: 16px; animation-duration: 11s; animation-delay: 4s; }
@keyframes rise { to { transform: translateY(-115vh) translateX(20px); opacity: 0; } }

.phone {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: calc(100dvh * 9 / 16);
  min-width: min(100%, 340px);
  height: 100dvh;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
}

h1, h2, h3, .display { font-family: Fredoka, Inter, sans-serif; margin: 0; letter-spacing: .2px; }

.logo { text-align: center; margin-top: 6vh; }
.logo h1 { font-size: clamp(42px, 13vw, 58px); line-height: .95; font-weight: 700; }
.logo h1 .c1 { color: var(--cruche); }
.logo h1 .c2 { color: var(--crush); }
.logo h1 small { display: block; font-size: .42em; color: var(--muted); font-weight: 500; margin: 4px 0; }
.logo p { color: var(--muted); margin: 14px 0 0; font-size: 15px; }
.logo .jug { font-size: 64px; display: inline-block; animation: wobble 3s ease-in-out infinite; }
@keyframes wobble { 0%,100% { transform: rotate(-8deg); } 50% { transform: rotate(8deg); } }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  backdrop-filter: blur(10px);
}

.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; gap: 10px; align-items: center; }
.grow { flex: 1; }
.spacer { flex: 1; }
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

label { font-size: 13px; color: var(--muted); font-weight: 600; }

input {
  width: 100%;
  font: 600 18px Fredoka, Inter, sans-serif;
  color: var(--text);
  background: rgba(7, 18, 56, .6);
  border: 2px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  outline: none;
  transition: border-color .15s;
}
input:focus { border-color: var(--sky); }
input::placeholder { color: rgba(169, 188, 232, .6); }
input.code-input { text-transform: uppercase; letter-spacing: 8px; text-align: center; font-size: 24px; }

button {
  font: 600 17px Fredoka, Inter, sans-serif;
  border: 0;
  border-radius: 14px;
  padding: 14px 18px;
  color: var(--deep);
  background: var(--ice);
  cursor: pointer;
  transition: transform .08s, filter .15s, opacity .15s;
  box-shadow: 0 4px 0 rgba(0, 0, 0, .25);
}
button:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0, 0, 0, .25); }
button:disabled { opacity: .4; pointer-events: none; }
button.primary { background: linear-gradient(180deg, #5CCBFF, var(--sky)); }
button.crush { background: var(--crush); color: #fff; }
button.cruche { background: var(--cruche); }
button.veto { background: var(--veto); }
button.ok { background: var(--ok); }
button.ghost { background: transparent; color: var(--muted); box-shadow: none; border: 1px solid var(--line); }
button.big { padding: 18px; font-size: 20px; width: 100%; }
button.icon { padding: 14px; min-width: 54px; }

.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }

/* Top bar */
.topbar { display: flex; align-items: center; gap: 10px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--card-strong); border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 12px; font: 600 14px Fredoka, sans-serif;
}
.pill.code { letter-spacing: 3px; }

/* Lobby */
.big-code {
  font: 700 64px Fredoka, sans-serif; letter-spacing: 12px; text-align: center;
  color: var(--cruche); text-shadow: 0 6px 0 rgba(0,0,0,.25);
}
.players { display: flex; flex-wrap: wrap; gap: 8px; }
.player {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 12px 8px 8px; border-radius: 999px;
  background: var(--card-strong); font: 600 15px Fredoka, sans-serif;
}
.player.off { opacity: .4; }
.player.turn { outline: 2px solid var(--sky); animation: pulse 1.2s ease-in-out infinite; }
.avatar {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  color: var(--deep); font: 700 14px Fredoka, sans-serif; flex: none;
}
.player .badges { font-size: 12px; color: var(--muted); }
@keyframes pulse { 50% { outline-color: transparent; } }

/* Tokens */
.tokens { display: flex; gap: 8px; }
.token {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 4px; border-radius: 14px; background: var(--card); border: 1px solid var(--line);
  font: 600 12px Fredoka, sans-serif; color: var(--muted);
}
.token b { font-size: 20px; color: var(--text); }
.token.cruche b { color: var(--cruche); }
.token.crush b { color: var(--crush); }
.token.veto b { color: var(--veto); }
.token.empty { opacity: .35; }

/* Sentence */
.sentence {
  min-height: 160px;
  display: flex; flex-wrap: wrap; align-content: flex-start; gap: 8px;
  font: 600 24px/1.25 Fredoka, sans-serif;
}
.sentence.big { font-size: 28px; }
.word {
  display: inline-block; padding: 4px 10px; border-radius: 10px;
  background: rgba(255,255,255,.06); border-bottom: 3px solid var(--c, var(--sky));
  animation: pop .25s ease-out;
}
.word.swapped { background: rgba(255, 201, 60, .18); }
.word.pickable { cursor: pointer; }
.word.picked { background: var(--cruche); color: var(--deep); }
.caret { width: 3px; height: 30px; background: var(--sky); align-self: center; animation: blink 1s steps(2) infinite; }
.empty-sentence { color: var(--muted); font: 500 18px Fredoka, sans-serif; }
@keyframes pop { from { transform: scale(.4); opacity: 0; } }
@keyframes blink { 50% { opacity: 0; } }

.status { text-align: center; font: 600 20px Fredoka, sans-serif; }
.status .who { color: var(--c, var(--sky)); }
.status.mine { color: var(--sky); animation: bounce 1s ease-in-out infinite; }
@keyframes bounce { 50% { transform: translateY(-3px); } }

.crown { display: inline-block; }

/* Wheel */
.wheel-wrap { position: relative; width: min(82vw, 320px); aspect-ratio: 1; margin: 6px auto; }
.wheel-wrap .pointer {
  position: absolute; top: -10px; left: 50%; transform: translateX(-50%); z-index: 2;
  width: 0; height: 0; border-left: 16px solid transparent; border-right: 16px solid transparent;
  border-top: 30px solid var(--cruche); filter: drop-shadow(0 3px 0 rgba(0,0,0,.35));
}
.wheel { width: 100%; height: 100%; border-radius: 50%; box-shadow: 0 0 0 6px var(--ice), 0 12px 40px rgba(0,0,0,.4); }
.wheel svg { width: 100%; height: 100%; display: block; }
.wheel-wrap .hub { position: absolute; inset: 41%; z-index: 2; box-shadow: 0 4px 12px rgba(0,0,0,.35); border-radius: 50%; background: var(--ice); display: grid; place-items: center; font-size: 22px; }

.target-banner {
  text-align: center; padding: 18px; border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(255,77,141,.25), rgba(56,189,248,.2));
  border: 1px solid var(--line);
}
.target-banner h2 { font-size: 30px; }
.target-banner h2 span { color: var(--c); }

.edit-diff { font: 600 18px Fredoka, sans-serif; text-align: center; }
.edit-diff s { color: var(--muted); }
.edit-diff b { color: var(--cruche); }

.feed { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.feed div { animation: pop .3s ease-out; }
.feed .crush { color: var(--crush); }
.feed .cruche { color: var(--cruche); }
.feed .veto { color: var(--veto); }
.feed .target { color: var(--sky); }

.rules { font-size: 14px; color: var(--muted); line-height: 1.5; }
.rules b { color: var(--text); }
.rules p { margin: 0 0 8px; }

.toast {
  position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translate(-50%, 140%); opacity: 0; visibility: hidden;
  background: var(--crush); color: #fff; font: 600 15px Fredoka, sans-serif;
  padding: 12px 18px; border-radius: 14px; transition: transform .25s, opacity .25s, visibility .25s; z-index: 10; max-width: 90vw; text-align: center;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; visibility: visible; }

.conn { position: fixed; top: 0; left: 0; right: 0; text-align: center; font-size: 12px; padding: 4px; background: var(--crush); z-index: 20; }

.scoreboard { width: 100%; border-collapse: collapse; font: 500 15px Fredoka, sans-serif; }
.scoreboard td { padding: 6px 4px; border-top: 1px solid var(--line); }
.scoreboard td.num { text-align: right; color: var(--muted); }

/* AI players */
.bot-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.bot-pick {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left;
  background: var(--card-strong); color: var(--text); border: 1px solid var(--line);
  border-left: 4px solid var(--c); padding: 10px 12px; box-shadow: none;
}
.bot-pick .bot-emoji { font-size: 22px; }
.bot-pick b { font-size: 16px; }
.bot-pick small { font: 500 12px Inter, sans-serif; color: var(--muted); line-height: 1.3; }
.chip-x {
  margin-left: 2px; padding: 0 6px; font-size: 18px; line-height: 1; background: transparent;
  color: var(--muted); box-shadow: none; border-radius: 50%;
}
.dots i { font-style: normal; animation: blink 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: .2s; }
.dots i:nth-child(3) { animation-delay: .4s; }
.bot-line {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius);
  background: var(--card-strong); border: 1px solid var(--line); border-left: 4px solid var(--c);
  animation: pop .3s ease-out;
}
.bot-line p { margin: 0; font: 500 16px/1.35 Fredoka, sans-serif; }
.feed .bot { color: var(--ice); }

/* Avatars, photos, turn order */
.avatar { overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-pick {
  flex: none; width: 54px; height: 54px; border-radius: 50%; overflow: hidden; cursor: pointer;
  border: 2px dashed var(--line); display: grid; place-items: center; background: rgba(7, 18, 56, .6);
}
.photo-pick img { width: 100%; height: 100%; object-fit: cover; }
.photo-empty { display: flex; flex-direction: column; align-items: center; font-size: 18px; line-height: 1; }
.photo-empty small { font-size: 9px; color: var(--muted); margin-top: 2px; }

.now-playing { display: flex; align-items: center; justify-content: center; gap: 12px; }
.now-playing .avatar { box-shadow: 0 0 0 3px var(--c), 0 0 22px var(--c); animation: bounce 1.4s ease-in-out infinite; }
.now-playing .status { text-align: left; }
.now-playing .who { color: var(--c); }
.now-playing.mine .status { color: var(--sky); }

.order {
  display: flex; align-items: center; gap: 4px; overflow-x: auto; padding: 6px 2px;
  scrollbar-width: none;
}
.order::-webkit-scrollbar { display: none; }
.order-item { display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 50px; opacity: .65; }
.order-item span { font: 600 11px Fredoka, sans-serif; color: var(--muted); white-space: nowrap; }
.order-item.now { opacity: 1; }
.order-item.now .avatar { box-shadow: 0 0 0 2px var(--sky); }
.order-item.now span { color: var(--sky); }
.order-item:nth-child(3) { opacity: .9; }
.order-arrow { color: var(--muted); font-size: 20px; margin-bottom: 14px; }

.target-face { display: flex; justify-content: center; margin-bottom: 6px; }
.target-face .avatar { box-shadow: 0 0 0 4px var(--crush), 0 0 30px rgba(255, 77, 141, .6); }

/* Sabotage votes */
.word.accusable { cursor: pointer; }
.word.sabotaged { background: rgba(255, 77, 141, .22); text-decoration: line-through wavy var(--crush); }
.word.accused { outline: 2px solid var(--crush); animation: pulse 1s ease-in-out infinite; }
.word .flag { font-style: normal; font-size: .6em; margin-left: 3px; vertical-align: super; }
button.flag-btn { background: #FFE4EE; color: #A0123F; }
.vote-card {
  padding: 14px; border-radius: var(--radius); background: rgba(255, 77, 141, .14);
  border: 1px solid rgba(255, 77, 141, .5); display: flex; flex-direction: column; gap: 10px; animation: pop .25s ease-out;
}
.vote-card p { margin: 0; font-size: 14px; line-height: 1.4; }
.ballots { display: flex; flex-wrap: wrap; gap: 6px; }
.ballot { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px 3px 3px; border-radius: 999px; background: var(--card-strong); font: 700 13px Fredoka, sans-serif; }
.ballot.yes { background: rgba(255, 77, 141, .35); }
.ballot.no { background: rgba(124, 242, 154, .3); }

.phone > * { flex-shrink: 0; }
.row > button.grow { flex: 1 1 0; padding: 12px 8px; font-size: 15px; }
