:root {
  --bg: #f2f5f3;
  --card: #ffffff;
  --ink: #12211b;
  --muted: #5d6f67;
  --line: #d9e2dd;
  --brand: #0b3d2e;
  --accent: #37003c;      /* PL purple */
  --hit: #12a150;
  --miss: #d93a3a;
  --tile: #e8eeea;
  --gold: #e9b10d;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1512; --card: #16211c; --ink: #e8f0ec; --muted: #9bb0a6;
    --line: #26352e; --tile: #22312a; --brand: #0b3d2e;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}
.top {
  background: linear-gradient(135deg, var(--brand), var(--accent));
  color: #fff; text-align: center; padding: 18px 16px 14px;
}
.top h1 { margin: 0; font-size: 26px; letter-spacing: .5px; }
.top h1 span { color: #00ff85; }
.top p { margin: 2px 0 0; opacity: .85; font-size: 14px; }
main { max-width: 560px; margin: 0 auto; padding: 16px; }
h2 { margin: 0 0 8px; font-size: 20px; }
h3 { margin: 22px 0 8px; font-size: 15px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin-bottom: 14px; }
.note { color: var(--muted); font-size: 13px; }
.center { text-align: center; }

input {
  width: 100%; font: inherit; padding: 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink);
}
button {
  font: inherit; font-weight: 600; border: 0; border-radius: 10px; padding: 12px 16px;
  background: var(--accent); color: #fff; cursor: pointer;
}
button:disabled { opacity: .45; cursor: default; }
button.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); width: 100%; margin-top: 16px; }
form { display: flex; gap: 8px; }

/* status bar */
.status-bar { display: flex; justify-content: space-between; align-items: end; margin-bottom: 14px; }
.label { font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.pips { display: flex; gap: 5px; margin-top: 5px; flex-wrap: wrap; }
.pip { width: 18px; height: 18px; border-radius: 50%; background: var(--hit); }
.pip.used { background: var(--line); }
.worth { text-align: right; }
.big { font-size: 30px; font-weight: 800; line-height: 1; }

/* the name */
.board { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 18px; margin: 10px 0 18px; }
.word { display: flex; gap: 4px; }
.tile {
  width: 30px; height: 40px; border-radius: 6px; background: var(--tile);
  display: grid; place-items: center; font-weight: 800; font-size: 20px;
  border-bottom: 3px solid var(--line);
}
.tile.on { background: var(--card); border-bottom-color: var(--hit); }
.tile.sym { background: transparent; border: 0; width: 12px; }
.tile.flip { animation: flip .35s ease; }
@keyframes flip { from { transform: rotateX(90deg); } to { transform: none; } }
@media (max-width: 400px) { .tile { width: 24px; height: 34px; font-size: 17px; } .word { gap: 3px; } }

/* keyboard */
.keyboard { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.krow { display: flex; justify-content: center; gap: 5px; }
.key { flex: 1; max-width: 44px; padding: 13px 0; background: var(--tile); color: var(--ink); border-radius: 8px; }
.key.hit { background: var(--hit); color: #fff; }
.key.miss { background: var(--miss); color: #fff; opacity: .7; }
.name-form input { flex: 1; }

/* clues */
.clues { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.clues li { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; min-height: 58px; }
.clues li.locked { background: transparent; border-style: dashed; color: var(--muted); }
.clues li.new { animation: pop .4s ease; border-color: var(--hit); }
@keyframes pop { from { transform: scale(.92); opacity: 0; } to { transform: none; opacity: 1; } }
.clue-label { font-size: 14px; color: var(--muted); }
.clue-value { font-weight: 700; font-size: 18px; }

/* result */
.result { text-align: center; }
.result .name { font-size: 24px; font-weight: 800; margin: 4px 0; }
.result .clubs { color: var(--muted); font-size: 14px; }
.result button { margin-top: 12px; }

/* group */
.group-today { list-style: none; padding: 0; margin: 0; }
.group-today li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.grid { font-size: 12px; letter-spacing: 1px; }
.pts { font-weight: 700; min-width: 54px; text-align: right; }

/* league */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 8px 6px; text-align: center; border-bottom: 1px solid var(--line); }
th { font-size: 12px; color: var(--muted); font-weight: 600; }
.l { text-align: left; }
tr.me td { font-weight: 700; background: color-mix(in srgb, var(--hit) 12%, transparent); }
.sub { display: block; font-size: 11px; color: var(--muted); font-weight: 400; }
.rules { padding-left: 18px; margin: 0; }
.rules li { margin: 4px 0; }

/* tabs + toast */
.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: var(--card);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.tabs button { flex: 1; background: transparent; color: var(--muted); border-radius: 0; padding: 16px; }
.tabs button.active { color: var(--ink); box-shadow: inset 0 3px 0 var(--accent); }
.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); max-width: 90%;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px;
}
.key:disabled { opacity: 1; cursor: default; }
.key.miss:disabled { opacity: .6; }

/* new-clue pop-up */
.pop { position: fixed; inset: 0; background: rgb(0 0 0 / .45); display: grid; place-items: center; padding: 16px; z-index: 10; animation: fade .2s ease; }
.pop[hidden] { display: none; }
.pop-card { background: var(--card); border-radius: 18px; padding: 22px 20px 18px; width: 100%; max-width: 340px; text-align: center; animation: pop .3s ease; }
.pop-head { font-weight: 700; font-size: 19px; margin-bottom: 16px; }
.pop-new { font-size: 22px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--hit); font-weight: 800; }
#pop-label { font-size: 24px; font-weight: 600; margin-top: 8px; color: var(--ink); }
.pop-value { font-size: 26px; font-weight: 800; margin: 4px 0 12px; }
.pop-card button { width: 100%; margin-top: 14px; }
@keyframes fade { from { opacity: 0; } }

/* share */
.share { display: grid; gap: 8px; margin-top: 12px; }
.btn.wa { background: #1fa855; color: #fff; text-decoration: none; display: block; text-align: center; }
.btn.ghost, .share button.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); margin-top: 0; }
.btn { display: block; padding: 12px 16px; border-radius: 10px; font-weight: 600; }
.photo { width: 150px; height: 150px; border-radius: 50%; object-fit: cover; object-position: center 20%; margin: 12px auto 4px; display: block; border: 4px solid var(--hit); background: var(--tile); }
.photo.none { display: grid; place-items: center; font-size: 56px; }
.credit { display: block; font-size: 11px; color: var(--muted); text-decoration: none; max-width: 300px; margin: 0 auto; overflow-wrap: anywhere; }
.pop-card .note { font-size: 15px; }
.day-badge { text-align: center; font-weight: 700; font-size: 15px; padding: 9px 12px; border-radius: 10px; background: var(--accent); color: #fff; margin-bottom: 4px; }
.fact { text-align: left; background: var(--bg); border-radius: 10px; padding: 10px 12px; margin: 12px 0 4px; font-size: 15px; line-height: 1.45; }
.link-row { display: flex; gap: 8px; }
.link-row input { flex: 1; min-width: 0; font-size: 13px; }
.today-head, .league-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.today-head h3 { margin: 22px 0 8px; }
.today-head select { margin-top: 14px; }
select { font: inherit; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--ink); max-width: 100%; }
.big-pick { font-size: 19px; font-weight: 700; }
#wa-invite { margin-top: 10px; }
#leave-league { margin-top: 10px; }
#rename-form { margin-top: 10px; }
#rename-form input { flex: 1; min-width: 0; }
.stack { flex-direction: column; align-items: stretch; }
.field-label { font-size: 13px; color: var(--muted); margin-top: 4px; }
