/* Word Swap: Lewis edition. Mobile first, scales up for the big screen. */

:root {
  --ink: #1d1135;
  --muted: #6b5d86;
  --card: #ffffff;
  --yellow: #ffd23f;
  --pink: #ff4d8d;
  --teal: #19d3c5;
  --purple: #7b2ff7;
  --green: #2ecc71;
  --red: #ff5a5f;
  --radius: 26px;
  --shadow: 0 8px 0 rgba(29, 17, 53, 0.18), 0 18px 40px rgba(29, 17, 53, 0.18);
  --font: "Fredoka", "Baloo 2", ui-rounded, "SF Pro Rounded", "Nunito", "Varela Round",
    "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

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

body {
  font-family: var(--font);
  color: var(--ink);
  background: linear-gradient(135deg, #7b2ff7 0%, #f107a3 45%, #ff9a3c 100%) fixed;
  min-height: 100vh;
  min-height: 100dvh;
  padding: max(12px, env(safe-area-inset-top)) 14px max(24px, env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
  font-size: 18px;
  line-height: 1.35;
}

#confetti {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 50;
}

.brand { text-align: center; margin: 4px 0 14px; color: #fff; }
.logo {
  margin: 0;
  font-size: clamp(2.2rem, 10vw, 3.4rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1;
  text-shadow: 0 5px 0 rgba(29, 17, 53, 0.35);
  transform: rotate(-2deg);
}
.logo-a { color: #fff; }
.logo-b { color: var(--yellow); display: inline-block; transform: rotate(4deg); }
.subtitle {
  margin: 6px 0 0;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 0.85rem;
  opacity: 0.92;
}
.brand.small .logo { font-size: 1.8rem; }
.brand.small .subtitle { font-size: 0.7rem; }

main { max-width: 560px; margin: 0 auto; display: grid; gap: 16px; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 18px;
  animation: pop 0.35s cubic-bezier(0.2, 1.4, 0.4, 1);
}
.card h2 { margin: 0 0 12px; font-size: 1.45rem; }
.card h3 { margin: 14px 0 8px; font-size: 1.1rem; color: var(--muted); }
.card p { margin: 6px 0; }
.muted { color: var(--muted); }
.center { text-align: center; }

@keyframes pop {
  from { transform: scale(0.94); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

label { display: block; font-weight: 700; margin: 10px 0 6px; }

input[type="text"], select {
  width: 100%;
  font: inherit;
  font-size: 1.25rem;
  padding: 14px 16px;
  border-radius: 18px;
  border: 3px solid #e4dcf3;
  background: #faf8ff;
  color: var(--ink);
  outline: none;
}
input[type="text"]:focus, select:focus { border-color: var(--purple); background: #fff; }
input.code-input { text-transform: uppercase; letter-spacing: 0.3em; font-weight: 800; text-align: center; }

.btn {
  display: block;
  width: 100%;
  font: inherit;
  font-weight: 800;
  font-size: 1.3rem;
  padding: 16px 18px;
  margin-top: 12px;
  border: 0;
  border-radius: 20px;
  cursor: pointer;
  color: var(--ink);
  background: var(--yellow);
  box-shadow: 0 6px 0 #d9a800;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #d9a800; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.pink { background: var(--pink); color: #fff; box-shadow: 0 6px 0 #c1205f; }
.btn.pink:active { box-shadow: 0 2px 0 #c1205f; }
.btn.teal { background: var(--teal); box-shadow: 0 6px 0 #0e9e93; }
.btn.teal:active { box-shadow: 0 2px 0 #0e9e93; }
.btn.ghost { background: #efe9fb; box-shadow: 0 6px 0 #d4c8ee; color: var(--muted); font-size: 1rem; padding: 12px; }
.btn.ghost:active { box-shadow: 0 2px 0 #d4c8ee; }

.or { text-align: center; color: #fff; font-weight: 800; letter-spacing: 0.2em; }

.room-code {
  font-size: clamp(2.6rem, 14vw, 4rem);
  font-weight: 900;
  letter-spacing: 0.2em;
  text-align: center;
  color: var(--purple);
  margin: 4px 0;
}

.players { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.player {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  background: #f1ebff;
  font-weight: 700;
}
.player.me { background: var(--yellow); }
.player.off { opacity: 0.4; filter: grayscale(1); }
.player.done { background: #c9f7e3; }
.player .tag { font-size: 0.75rem; background: var(--purple); color: #fff; padding: 2px 8px; border-radius: 999px; }

.settings { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; }
.settings label { margin: 6px 0 4px; font-size: 0.95rem; }
.settings select { font-size: 1rem; padding: 10px 12px; }
.toggle { display: flex; align-items: center; gap: 10px; font-weight: 700; grid-column: 1 / -1; margin-top: 8px; }
.toggle input { width: 26px; height: 26px; accent-color: var(--purple); }

.status-row { display: flex; justify-content: space-between; align-items: center; color: #fff; font-weight: 800; }
.timer {
  min-width: 64px;
  text-align: center;
  background: #fff;
  color: var(--ink);
  border-radius: 999px;
  padding: 6px 14px;
  box-shadow: 0 4px 0 rgba(29, 17, 53, 0.2);
  font-variant-numeric: tabular-nums;
}
.timer.hurry { background: var(--red); color: #fff; animation: pulse 0.6s infinite alternate; }
@keyframes pulse { to { transform: scale(1.08); } }

.sentence {
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.6;
  text-align: center;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 6px;
}
.word { padding: 2px 6px; border-radius: 12px; }
.word.target {
  background: var(--yellow);
  box-shadow: 0 4px 0 #d9a800;
  animation: wiggle 1.2s ease-in-out infinite;
}
.word.new { background: var(--teal); box-shadow: 0 4px 0 #0e9e93; }
.word.old { text-decoration: line-through; text-decoration-thickness: 3px; background: #ffe0e1; }
@keyframes wiggle { 0%, 100% { transform: rotate(-3deg); } 50% { transform: rotate(3deg); } }

button.word-btn {
  font: inherit;
  font-size: 1.45rem;
  font-weight: 800;
  padding: 10px 14px;
  border-radius: 16px;
  border: 0;
  background: #f1ebff;
  color: var(--ink);
  box-shadow: 0 5px 0 #d4c8ee;
  cursor: pointer;
}
button.word-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 #d4c8ee; }
button.word-btn.picked { background: var(--pink); color: #fff; box-shadow: 0 5px 0 #c1205f; }
button.word-btn:disabled:not(.picked) { opacity: 0.5; cursor: default; }
.punct { font-size: 1.6rem; font-weight: 800; align-self: center; margin-left: -6px; }

.big-emoji { font-size: 3rem; text-align: center; margin: 4px 0; }
.label-pill {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding: 4px 10px;
  border-radius: 999px;
  background: #efe9fb;
  color: var(--muted);
  margin-bottom: 6px;
}

.guess-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.guess-list li { display: flex; justify-content: space-between; gap: 10px; padding: 10px 14px; border-radius: 14px; background: #f7f3ff; font-weight: 700; }
.guess-list li.right { background: #c9f7e3; }
.guess-list li.wrong { background: #ffe0e1; }

.scores { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.scores li {
  display: grid;
  grid-template-columns: 34px 1fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 16px;
  background: #f7f3ff;
  font-weight: 800;
}
.scores li.me { background: #fff2bf; }
.scores li.off { opacity: 0.5; }
.scores .rank { color: var(--muted); }
.scores .delta { color: var(--green); font-size: 0.95rem; }
.scores .pts { font-variant-numeric: tabular-nums; }

.podium { display: flex; align-items: flex-end; justify-content: center; gap: 10px; margin: 16px 0 8px; }
.step { flex: 1; max-width: 150px; text-align: center; font-weight: 800; }
.step .block { border-radius: 18px 18px 8px 8px; color: #fff; font-size: 2rem; display: flex; align-items: center; justify-content: center; box-shadow: 0 6px 0 rgba(29, 17, 53, 0.2); }
.step .who { margin-bottom: 6px; overflow-wrap: anywhere; }
.step .pts { font-size: 0.9rem; color: var(--muted); }
.step.p1 .block { height: 150px; background: linear-gradient(#ffd23f, #ffb000); color: var(--ink); }
.step.p2 .block { height: 110px; background: linear-gradient(#c0c7d6, #95a0b8); }
.step.p3 .block { height: 80px; background: linear-gradient(#e0a26c, #b8743c); }
.winner-name { text-align: center; font-size: 2rem; font-weight: 900; color: var(--purple); margin: 0; overflow-wrap: anywhere; }

.lol-btn { font-size: 1.6rem; }
.lol-count { text-align: center; font-weight: 800; color: var(--pink); font-size: 1.2rem; }

.notice { background: var(--yellow); border-radius: 18px; padding: 12px 16px; font-weight: 800; text-align: center; box-shadow: var(--shadow); }

.toast {
  position: fixed;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  transform: translate(-50%, 200%);
  opacity: 0;
  visibility: hidden;
  background: var(--ink);
  color: #fff;
  padding: 12px 18px;
  border-radius: 16px;
  font-weight: 700;
  max-width: 90vw;
  transition: transform 0.25s ease, opacity 0.25s ease, visibility 0.25s;
  z-index: 60;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; visibility: visible; }

.footer-actions { display: flex; gap: 10px; }
.footer-actions .btn { margin-top: 0; }

/* Big screen: viewer only, sized for a telly across the room. */
body.tv { font-size: clamp(18px, 1.6vw, 34px); padding: 2vh 3vw; }
body.tv main { max-width: 1400px; }
body.tv .brand .logo { font-size: clamp(3rem, 6vw, 7rem); }
body.tv .card { padding: 3vh 3vw; }
body.tv .card h2 { font-size: 2.2em; }
body.tv .room-code { font-size: clamp(4rem, 12vw, 12rem); }
body.tv .sentence { font-size: clamp(2rem, 4.2vw, 5rem); gap: 0.3em 0.3em; }
body.tv .punct { font-size: inherit; margin-left: -0.3em; }
body.tv .player { font-size: 1.4em; padding: 0.4em 0.9em; }
body.tv .scores li, body.tv .guess-list li { font-size: 1.4em; }
body.tv .step { max-width: 320px; font-size: 1.5em; }
body.tv .step.p1 .block { height: 32vh; }
body.tv .step.p2 .block { height: 24vh; }
body.tv .step.p3 .block { height: 17vh; }
body.tv .winner-name { font-size: 4em; }
body.tv .status-row { font-size: 1.6em; }
body.tv .join-hint { font-size: 1.6em; text-align: center; }
body.tv .tv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 3vw; align-items: start; }

@media (min-width: 900px) {
  body:not(.tv) main { max-width: 640px; }
}

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