/* Words with Family — really vibrant, bold, saturated, family-game feel.
   Big touch targets, readable on iPhone Safari. No hover-only actions. */
:root {
  --pink: #ff2e88;
  --orange: #ff7a1a;
  --yellow: #ffc400;
  --green: #00c853;
  --teal: #00b8a9;
  --blue: #2979ff;
  --purple: #7c4dff;
  --ink: #1a1033;
  --card: #ffffff;
  --bg1: #ff2e88;
  --bg2: #7c4dff;
  --bg3: #2979ff;
  --danger: #e53935;
  --tile: #fff3b0;
  --tile-edge: #e0a800;
  --radius: 16px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: linear-gradient(160deg, var(--bg1) 0%, var(--bg2) 45%, var(--bg3) 100%);
  background-attachment: fixed;
  min-height: 100vh;
  min-height: 100dvh;
  font-size: 17px;
  line-height: 1.4;
}
h1, h2, h3 { margin: 0 0 8px; line-height: 1.15; }
p { margin: 0 0 10px; }
button, select, input {
  font: inherit;
  color: inherit;
}
button {
  min-height: 48px;
  min-width: 48px;
  padding: 12px 18px;
  border: 0;
  border-radius: 999px;
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
}
button:disabled { opacity: .45; cursor: not-allowed; }
input, select {
  min-height: 48px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 3px solid #e8e0ff;
  background: #fff;
  width: 100%;
}
input:focus, select:focus, button:focus-visible { outline: 4px solid var(--yellow); outline-offset: 2px; }

#app { max-width: 640px; margin: 0 auto; padding: 12px 12px 40px; }
.screen { display: none; }
.screen.active { display: block; animation: pop .25s ease; }
@keyframes pop { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: 0 8px 24px rgba(26, 16, 51, .28);
  border: 3px solid rgba(255, 255, 255, .65);
}
.hero { text-align: center; color: #fff; padding: 18px 8px 6px; text-shadow: 0 2px 10px rgba(0,0,0,.35); }
.hero h1 { font-size: 44px; font-weight: 900; letter-spacing: -1px; margin-bottom: 2px; }
.hero h1 .w1 { color: var(--yellow); }
.hero h1 .w2 { color: #7CFC9A; }
.hero h1 .w3 { color: #8ecbff; }
.hero p { font-size: 18px; font-weight: 700; opacity: .98; }
.tagline { font-size: 15px; font-weight: 600; }

label { display: block; font-weight: 800; margin: 12px 0 6px; }
.hint { font-size: 14px; color: #5b5470; font-weight: 600; }
.error { background: #ffe1e1; color: #8f1111; border: 3px solid #ff8a8a; border-radius: 12px; padding: 10px 12px; font-weight: 700; margin: 10px 0; }
.error:empty { display: none; }
.status-line { font-weight: 800; font-size: 15px; }
.status-line.ok { color: var(--green); }
.status-line.bad { color: var(--danger); }
.status-line.wait { color: var(--purple); }

.btn-primary { background: var(--yellow); color: var(--ink); width: 100%; font-size: 19px; box-shadow: 0 4px 0 #c79a00; }
.btn-primary:active { transform: translateY(2px); box-shadow: 0 2px 0 #c79a00; }
.btn-green { background: var(--green); color: #fff; box-shadow: 0 4px 0 #009624; }
.btn-blue { background: var(--blue); color: #fff; box-shadow: 0 4px 0 #004ecb; }
.btn-purple { background: var(--purple); color: #fff; box-shadow: 0 4px 0 #4a1fd0; }
.btn-pink { background: var(--pink); color: #fff; box-shadow: 0 4px 0 #b3005c; }
.btn-orange { background: var(--orange); color: #fff; box-shadow: 0 4px 0 #c25e00; }
.btn-ghost { background: #efeaff; color: var(--ink); box-shadow: 0 4px 0 #c9b8ff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-small { min-height: 44px; padding: 8px 14px; font-size: 15px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row > * { flex: 1 1 auto; }
.row .grow { flex: 1 1 100%; }
.divider { text-align: center; font-weight: 900; color: #fff; margin: 14px 0 4px; text-shadow: 0 2px 8px rgba(0,0,0,.35); }

.topbar {
  display: flex; gap: 8px; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 20;
  background: rgba(26, 16, 51, .92); color: #fff;
  border-radius: 999px; padding: 6px 8px 6px 14px; margin-bottom: 12px;
  box-shadow: 0 6px 18px rgba(0,0,0,.3);
}
.topbar .brand { font-weight: 900; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .brand small { display: block; font-size: 12px; font-weight: 700; opacity: .85; }
.icon-btn {
  min-width: 44px; min-height: 44px; border-radius: 50%;
  background: #fff; color: var(--ink); padding: 8px; font-size: 18px; line-height: 1;
  flex: 0 0 auto;
}
.icon-btn[aria-pressed="true"] { background: var(--yellow); }
.icon-btn.muted { background: #ffb3c6; }

.code-big {
  font-size: 34px; font-weight: 900; letter-spacing: 6px; text-align: center;
  background: var(--ink); color: var(--yellow); border-radius: 12px; padding: 10px;
}
.code-big a { color: var(--yellow); }
.player-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.player-list li {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  background: #f4f0ff; border-radius: 12px; padding: 10px 12px; font-weight: 700;
}
.player-list li.me { border: 3px solid var(--pink); background: #ffe4f0; }
.player-list li .score { margin-left: auto; font-weight: 900; font-size: 20px; color: var(--purple); }
.badge {
  display: inline-block; font-size: 12px; font-weight: 900; padding: 3px 8px;
  border-radius: 999px; background: var(--yellow); color: var(--ink); text-transform: uppercase;
}
.badge.host { background: var(--pink); color: #fff; }
.badge.turn { background: var(--green); color: #fff; }
.badge.brb { background: var(--orange); color: #fff; }
.badge.off { background: #d7d2e8; color: #5b5470; }
.badge.voice { background: var(--teal); color: #fff; }
.badge.voice.off { background: #d7d2e8; color: #5b5470; }
.voice-dot { width: 12px; height: 12px; border-radius: 50%; background: #cfc8e8; display: inline-block; }
.voice-dot.speaking { background: var(--green); box-shadow: 0 0 0 4px rgba(0,200,83,.3); }
.voice-dot.on { background: var(--teal); }

/* --- Board --- */
.board-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.board {
  display: grid; grid-template-columns: repeat(15, 1fr);
  gap: 2px; background: var(--ink); border: 3px solid var(--ink);
  border-radius: 10px; padding: 2px; min-width: 340px;
}
.cell {
  aspect-ratio: 1; border: 0; border-radius: 4px; padding: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 900; line-height: 1; color: #fff;
  min-width: 0; min-height: 0; position: relative;
  background: #e8f6ff;
}
.cell .mult { font-size: 8px; letter-spacing: -.2px; }
.cell.tw { background: #e53935; }
.cell.dw { background: #ff8f00; }
.cell.tl { background: #1565c0; }
.cell.dl { background: #26a6d8; }
.cell.center { background: #ff2e88; font-size: 14px; }
.cell.plain { background: #fdf6e3; }
.cell.selected { outline: 3px solid var(--yellow); outline-offset: -3px; }
.cell.fresh-hint { outline: 3px dashed var(--green); outline-offset: -3px; }
.cell .tile { position: absolute; inset: 1px; }
.tile {
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center;
  background: linear-gradient(180deg, #fff8c9, #ffe27a);
  border: 2px solid var(--tile-edge); border-radius: 8px;
  font-weight: 900; color: var(--ink);
  box-shadow: 0 2px 0 rgba(0,0,0,.25);
  min-width: 44px; min-height: 44px;
}
.tile .letter { font-size: 24px; line-height: 1; }
.tile .value { font-size: 11px; font-weight: 800; color: #7a5b00; align-self: flex-end; margin-right: 4px; }
.cell .tile .letter { font-size: clamp(13px, 3.4vw, 22px); }
.cell .tile .value { font-size: 8px; margin-right: 2px; }
.cell .tile.placed { background: linear-gradient(180deg, #d8ffd8, #8ef0a0); border-color: #1e9e4a; }
.cell .tile.fresh { background: linear-gradient(180deg, #ffe9f4, #ffb3d9); border-color: var(--pink); }
.tile.selected { outline: 4px solid var(--pink); transform: translateY(-4px); }
.tile.swap-pick { outline: 4px solid var(--orange); transform: translateY(-4px); }

.rack {
  display: flex; gap: 6px; justify-content: center; flex-wrap: wrap;
  background: #2b1a5e; border-radius: 14px; padding: 10px 8px; margin: 10px 0;
}
.rack .tile { width: 46px; height: 52px; flex: 0 0 auto; }
.rack-empty { color: #fff; font-weight: 700; padding: 8px; text-align: center; }

.timer {
  text-align: center; font-size: 34px; font-weight: 900; border-radius: 14px;
  padding: 6px 10px; background: var(--ink); color: #fff; margin: 8px 0;
}
.timer.warning { background: var(--danger); color: #fff; animation: blink 1s steps(2) infinite; }
.timer.paused { background: var(--orange); }
@keyframes blink { 50% { opacity: .55; } }
.timer small { display: block; font-size: 13px; font-weight: 700; opacity: .9; }

.turn-banner {
  text-align: center; font-weight: 900; font-size: 18px; border-radius: 12px;
  padding: 10px; margin-bottom: 10px;
}
.turn-banner.your-turn { background: var(--green); color: #fff; }
.turn-banner.other-turn { background: #efeaff; color: var(--ink); }

.action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.action-grid button { width: 100%; }

.log, .chat-log {
  list-style: none; margin: 0; padding: 0; max-height: 180px; overflow-y: auto;
  display: grid; gap: 6px; font-size: 15px;
}
.log li { background: #f4f0ff; border-radius: 8px; padding: 6px 10px; }
.chat-log li { background: #e8f6ff; border-radius: 8px; padding: 6px 10px; }
.chat-log li b { color: var(--purple); }
.chat-log li.me b { color: var(--pink); }
.chat-form { display: flex; gap: 8px; margin-top: 10px; }
.chat-form input { flex: 1; }
.chat-form button { flex: 0 0 auto; }

table.scores { width: 100%; border-collapse: collapse; font-size: 17px; }
table.scores th, table.scores td { padding: 10px 6px; border-bottom: 2px solid #efeaff; text-align: left; }
table.scores td.num, table.scores th.num { text-align: right; font-weight: 900; }
table.scores tr.winner td { background: #fff3b0; font-weight: 900; }
.trophy { font-size: 44px; text-align: center; }

.share-box { word-break: break-all; background: #f4f0ff; border-radius: 10px; padding: 10px; font-weight: 700; }
.footer-note { text-align: center; color: #fff; font-weight: 700; font-size: 14px; opacity: .9; text-shadow: 0 1px 6px rgba(0,0,0,.4); }
.hidden { display: none !important; }
@media (max-width: 380px) {
  .hero h1 { font-size: 36px; }
  .rack .tile { width: 40px; height: 48px; }
  .tile .letter { font-size: 20px; }
}
