/* Colors as tokens so dark mode (shared/theme.js) only has to swap values. */
:root {
    --bg: #fbfaf6;
    --card: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
    --border: #e7e2d4;
    --honey: #f5cf2a;
    --honey-text: #1f1a05;
    --honey-soft: #fdf1b8;
    --cell: #e8e6e0;
    --cell-press: #d3d0c7;
    --cell-text: #1f2937;
    --bad: #b7b4ab;
    --wrong: #c8363c;
    --btn-bg: #111827;
    --btn-text: #ffffff;
    --shadow: rgba(0, 0, 0, .08);
    --ui: system-ui, -apple-system, "Segoe UI", sans-serif;
}
:root[data-theme="dark"] {
    --bg: #141412; --card: #1d1c19; --text: #eceae4; --muted: #a29f95; --border: #34322b;
    --honey: #e3bc1c; --honey-text: #1a1503; --honey-soft: #3a3214;
    --cell: #2f2e2a; --cell-press: #45433d; --cell-text: #eceae4; --bad: #6c6a63; --wrong: #ff6b70;
    --btn-bg: #eceae4; --btn-text: #141412; --shadow: rgba(0, 0, 0, .4);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
/* No double-tap zoom (pinch zoom still works) */
html { touch-action: manipulation; }
body {
    margin: 0;
    font-family: var(--ui);
    background: var(--bg);
    color: var(--text);
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    padding-right: max(16px, env(safe-area-inset-right, 0px));
}
button { font: inherit; color: inherit; }
button:focus-visible { outline: 3px solid var(--honey); outline-offset: 2px; }

main {
    max-width: 520px; margin: 0 auto; padding-block: 64px 48px;
    display: flex; flex-direction: column; gap: 16px;
}
header { text-align: center; display: flex; flex-direction: column; gap: 4px; }
h1 { margin: 0; font-size: 32px; letter-spacing: -.01em; }
.sub { margin: 0; color: var(--muted); font-size: 15px; }

.modes { display: flex; justify-content: center; gap: 6px; }
.modes button {
    border: 1px solid var(--border); background: var(--card); border-radius: 999px;
    padding: 6px 14px; font-size: 14px; cursor: pointer;
}
.modes button[aria-pressed="true"] { background: var(--btn-bg); color: var(--btn-text); border-color: var(--btn-bg); }

/* ---------- Rank ---------- */
.rank { display: flex; align-items: center; gap: 12px; }
.rank strong { min-width: 92px; font-size: 15px; }
.track {
    flex: 1; position: relative; display: flex; justify-content: space-between; align-items: center; height: 20px;
}
.track::before, .track::after {
    content: ""; position: absolute; left: 4px; right: 4px; top: 50%; height: 2px; translate: 0 -50%; background: var(--border);
}
.track::after { right: auto; width: calc((100% - 8px) * var(--fill, 0)); background: var(--honey); }
.dot { position: relative; z-index: 1; width: 9px; height: 9px; border-radius: 50%; background: var(--border); }
.dot.on { background: var(--honey); }
.dot.here { width: 14px; height: 14px; box-shadow: 0 0 0 3px var(--honey-soft); }
.score {
    min-width: 36px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums;
    background: var(--honey); color: var(--honey-text); border-radius: 999px; padding: 2px 8px; font-size: 14px;
}

/* ---------- Found words ---------- */
.found { border: 1px solid var(--border); background: var(--card); border-radius: 10px; }
.found-head {
    width: 100%; display: flex; align-items: center; gap: 8px; padding: 10px 12px;
    background: none; border: 0; cursor: pointer; text-align: left; font-size: 14px; border-radius: 10px;
}
.found-head span:first-child { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.found .chev { color: var(--muted); transition: rotate .15s; }
.found.open .chev { rotate: 180deg; }
.found-list {
    list-style: none; margin: 0; padding: 4px 12px 12px; columns: 3 110px; column-gap: 16px;
    max-height: 50vh; overflow: auto; font-size: 14px;
}
.found-list li { padding: 4px 0; border-bottom: 1px solid var(--border); break-inside: avoid; }
.pangram { font-weight: 700; }
.found-list .bonus { color: var(--muted); font-style: italic; }
.star { color: var(--honey); font-style: normal; }
.bonus-note { margin: 12px 0 0; }

/* ---------- Entry and hive ---------- */
.play { display: flex; flex-direction: column; align-items: center; gap: 12px; user-select: none; -webkit-user-select: none; }
.msg {
    margin: 0; height: 30px; padding: 4px 12px; border-radius: 6px; font-size: 14px; font-weight: 600;
    opacity: 0; transition: opacity .15s;
}
.msg.show { opacity: 1; }
.msg.bad { background: var(--btn-bg); color: var(--btn-text); }
.msg.good { background: var(--card); border: 1px solid var(--border); }
.msg.pangram { background: var(--honey); color: var(--honey-text); }
.msg.bonus { background: var(--honey-soft); color: var(--text); border: 1px dashed var(--honey); }

.entry {
    min-height: 44px; max-width: 100%; display: flex; align-items: center; justify-content: center; flex-wrap: wrap;
    font-size: 30px; font-weight: 700; letter-spacing: .02em; text-transform: uppercase;
}
.entry .c { color: var(--honey); }
.entry .x { color: var(--bad); }
.caret { width: 2px; height: 34px; margin-left: 2px; background: var(--honey); animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.entry.shake { animation: shake .35s; }
@keyframes shake { 20%, 60% { translate: -8px 0; } 40%, 80% { translate: 8px 0; } }

.hive {
    --c: min(92px, 27vw);
    position: relative; width: calc(var(--c) * 2.62); height: calc(var(--c) * 2.73);
    touch-action: none; /* a slide across the letters spells, it doesn't scroll the page */
}
.cell {
    position: absolute; width: var(--c); height: calc(var(--c) * .866);
    left: calc(50% + var(--x) * var(--c) - var(--c) / 2);
    top: calc(50% + var(--y) * var(--c) - var(--c) * .433);
    padding: 0; border: 0; background: none; cursor: pointer;
    clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%);
    -webkit-tap-highlight-color: transparent;
}
.cell:focus-visible { outline: none; }
.cell svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.cell polygon { fill: var(--cell); stroke: transparent; stroke-width: 6; transition: fill .1s; }
.cell.center polygon { fill: var(--honey); }
.cell:focus-visible polygon { stroke: var(--text); }
.cell span {
    position: relative; font-size: calc(var(--c) * .32); font-weight: 700; color: var(--cell-text);
    transition: opacity .15s;
}
.cell.center span { color: var(--honey-text); }
.cell.fade span { opacity: 0; }
.cell.press { animation: press .18s; }
/* Cells picked up in the current slide */
.cell.trail polygon { fill: var(--cell-press); }
.cell.center.trail polygon { fill: var(--honey); filter: brightness(.9); }
@keyframes press { 50% { scale: .9; } }
@media (hover: hover) { .cell:hover polygon { fill: var(--cell-press); } .cell.center:hover polygon { fill: var(--honey); filter: brightness(.95); } }

.controls { display: flex; gap: 10px; margin-top: 4px; }
.pill {
    min-width: 88px; height: 46px; padding: 0 18px; border-radius: 999px; cursor: pointer;
    border: 1px solid var(--border); background: var(--card); font-size: 15px;
}
.pill.round { min-width: 46px; width: 46px; padding: 0; font-size: 20px; }
.pill:active { background: var(--cell); }

/* ---------- Tools, rules ---------- */
.tools { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.tools button {
    border: 1px solid var(--border); background: transparent; border-radius: 8px;
    padding: 6px 12px; font-size: 14px; cursor: pointer;
}
#resultsBtn { background: var(--honey); color: var(--honey-text); border-color: var(--honey); font-weight: 600; }

.rules {
    border: 1px solid var(--border); background: var(--card); border-radius: 10px; padding: 4px 16px 12px;
    font-size: 14px; line-height: 1.5;
}
.rules h2 { font-size: 16px; margin: 12px 0 4px; }
.rules ul { margin: 0; padding-left: 20px; }
.rules p { margin: 8px 0 0; color: var(--muted); }
kbd {
    font: inherit; font-size: 12px; padding: 1px 5px; border: 1px solid var(--border);
    border-bottom-width: 2px; border-radius: 4px; background: var(--bg);
}

/* ---------- Dialogs ---------- */
.sheet {
    width: min(420px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 20px;
    border: 1px solid var(--border); border-radius: 14px; background: var(--card); color: var(--text);
    box-shadow: 0 12px 40px var(--shadow);
}
.sheet::backdrop { background: rgba(0, 0, 0, .45); }
.sheet h2 { margin: 0 32px 6px 0; font-size: 20px; }
.sheet .close {
    position: absolute; top: 12px; right: 12px; width: 32px; height: 32px; border-radius: 50%;
    border: 0; background: transparent; cursor: pointer; font-size: 16px; color: var(--muted);
}
.note { margin: 0 0 12px; color: var(--muted); font-size: 14px; line-height: 1.4; }
.ranks { list-style: none; margin: 0; padding: 0; font-size: 15px; }
.ranks li { display: flex; justify-content: space-between; padding: 8px 10px; border-radius: 6px; }
.ranks li:nth-child(odd) { background: var(--bg); }
.ranks li.here { background: var(--honey); color: var(--honey-text); font-weight: 700; }
.ranks li span:last-child { font-variant-numeric: tabular-nums; }
.mini-hive { display: flex; gap: 4px; margin: 4px 0 10px; }
.mini-hive span {
    width: 28px; height: 28px; display: grid; place-items: center; border-radius: 6px;
    background: var(--cell); font-weight: 700; font-size: 14px;
}
.mini-hive span.c { background: var(--honey); color: var(--honey-text); }
.answer-list { list-style: none; margin: 0; padding: 0; columns: 2 120px; column-gap: 16px; font-size: 14px; }
.answer-list li { padding: 4px 0; border-bottom: 1px solid var(--border); break-inside: avoid; color: var(--muted); }
.answer-list li.got { color: var(--text); }
.tick { color: var(--honey); margin-right: 4px; font-weight: 700; }

/* ---------- Hints ---------- */
.sheet h3 { margin: 16px 0 6px; font-size: 14px; }
.peek {
    display: flex; flex-direction: column; align-items: center; gap: 8px;
    padding: 12px; border-radius: 10px; background: var(--bg);
}
.peek-word { margin: 0; display: flex; flex-wrap: wrap; justify-content: center; align-items: baseline; gap: 4px; font-size: 22px; font-weight: 700; }
.peek-word em { margin-left: 8px; font-size: 13px; font-weight: 400; font-style: normal; color: var(--muted); }
.peek .pill { height: 38px; font-size: 14px; }
.peek .pill:disabled { cursor: default; color: var(--muted); }
.grid-wrap { overflow-x: auto; }
.hint-grid { border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; margin: 0 auto; }
.hint-grid th, .hint-grid td { min-width: 28px; padding: 4px 6px; text-align: center; }
.hint-grid thead th { color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--border); }
.hint-grid tbody th { text-align: left; }
.hint-grid tr.sum { border-top: 1px solid var(--border); }
.hint-grid tr.sum td, .hint-grid tr.sum th, .hint-grid td:last-child { font-weight: 700; }
.hint-grid td:last-child, .hint-grid thead th:last-child { border-left: 1px solid var(--border); }
.hint-grid .done { color: var(--bad); }
.hint-grid .none { color: var(--border); }
.starts { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; font-size: 14px; }
.starts li { padding: 3px 8px; border-radius: 6px; background: var(--bg); font-variant-numeric: tabular-nums; }
.starts li.done { color: var(--bad); text-decoration: line-through; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* Hint steps: free clues first, then the counted letter reveal */
.hint-lead { margin: 0 0 2px; font-weight: 600; }
.hint-step { margin-top: 14px; padding-top: 4px; border-top: 1px solid var(--border); }
.hint-step h3 { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.hint-step .note { margin-bottom: 8px; }
.step {
    width: 22px; height: 22px; display: inline-grid; place-items: center; border-radius: 50%;
    background: var(--honey); color: var(--honey-text); font-size: 12px;
}
.free, .cost {
    margin-left: auto; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 600;
    text-transform: uppercase; letter-spacing: .04em;
}
.free { background: var(--bg); color: var(--muted); border: 1px solid var(--border); }
.cost { background: var(--honey-soft); color: var(--text); border: 1px solid var(--honey); }

/* ---------- How to play ---------- */
.intro-hive { display: flex; justify-content: center; gap: 4px; margin: 6px 0 14px; }
.intro-hive span {
    width: 34px; height: 30px; display: grid; place-items: center; font-weight: 700;
    background: var(--cell); clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%);
}
.intro-hive span.c { background: var(--honey); color: var(--honey-text); }
.intro-steps { margin: 0; padding-left: 20px; font-size: 15px; line-height: 1.45; }
.intro-steps li + li { margin-top: 6px; }
.intro-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.intro-actions button {
    padding: 10px 18px; border-radius: 999px; font-weight: 700; cursor: pointer;
}
.intro-hide { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.intro-ok { background: var(--honey); color: var(--honey-text); border: 1px solid var(--honey); }
