:root {
  --bg: #f6f7f9; --card: #fff; --text: #1a1d23; --muted: #6b7280;
  --accent: #e4572e; --line: #d8dce3; --ok: #2e9e5b; --bad: #c0392b;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #14161a; --card: #1e2127; --text: #eceff4; --muted: #9aa3b2;
          --line: #343a45; }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; }
body { background: var(--bg); color: var(--text); font: 16px/1.4 system-ui, sans-serif; }

/* Everything fits in the viewport: the chart absorbs whatever space is left. */
main { height: 100dvh; max-width: 760px; margin: 0 auto; padding: 12px 16px;
       display: flex; flex-direction: column; gap: 8px; }
header { flex: none; display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; }
.timer { text-align: right; font-size: .75rem; color: var(--muted); white-space: nowrap; }
.timer b { display: block; font-size: 1.1rem; color: var(--text); font-variant-numeric: tabular-nums; }
.timer button { padding: 4px 10px; font-size: .85rem; }
h1 { margin: 0; font-size: 1.8rem; line-height: 1.1; letter-spacing: -.5px; }
h1 a { color: inherit; text-decoration: none; }
h1 span { color: var(--accent); }
h1 small { font-size: .9rem; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.sub { color: var(--muted); margin: 2px 0 0; font-size: .85rem; }

.chart-wrap { position: relative; flex: 1 1 0; min-height: 100px; background: var(--card);
              border: 1px solid var(--line); border-radius: 10px; }
#chart { position: absolute; inset: 6px; width: calc(100% - 12px); height: calc(100% - 12px); }

.hints, .guesses { flex: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0;
                   list-style: none; }
.hints:empty, .guesses:empty { display: none; }
.hint { background: var(--card); border-left: 4px solid var(--accent);
        padding: 3px 10px; border-radius: 4px; font-size: .85rem; }
.hint.starter { border-left-color: var(--ok); }
.hint.starter b { color: var(--ok); }
.guesses li { padding: 2px 10px; border-radius: 999px; font-size: .85rem;
              background: var(--card); border: 1px solid var(--line); }
.guesses li.wrong::before { content: "✗ "; color: var(--bad); }
.guesses li.right { border-color: var(--ok); }
.guesses li.right::before { content: "✓ "; color: var(--ok); }
/* Wide screens: move the guess list out of the column into the empty space on the right,
   mirroring the rail on the left. Narrower screens keep the inline chips above the input. */
@media (min-width: 1200px) {
  .guesses { position: fixed; top: 84px; left: calc(50% + 380px + 16px);
             width: min(300px, calc(50% - 380px - 32px)); max-height: calc(100dvh - 120px);
             overflow-y: auto; flex-direction: column; flex-wrap: nowrap; gap: 8px; }
  .guesses::before { content: "Your guesses (" attr(data-count) ")"; font-size: .75rem; font-weight: 600; color: var(--muted);
                     text-transform: uppercase; letter-spacing: .6px; }
  .guesses li { padding: 8px 12px; border-radius: 10px; font-size: .95rem; overflow-wrap: anywhere; }
}

form { flex: none; display: flex; gap: 8px; }
.field { position: relative; flex: 1; }
input[type=text] { width: 100%; padding: 10px 12px; font-size: 1rem; color: var(--text);
                   background: var(--card); border: 1px solid var(--line); border-radius: 8px; }
button { padding: 10px 18px; font-size: 1rem; border: 0; border-radius: 8px; cursor: pointer;
         background: var(--accent); color: #fff; }
button:disabled { opacity: .5; cursor: default; }
/* Opens upward since the input sits at the bottom of the screen. */
#suggest { position: absolute; left: 0; right: 0; bottom: 100%; z-index: 5; margin: 0 0 2px;
           padding: 0; list-style: none; background: var(--card); border-radius: 8px;
           border: 1px solid var(--line); overflow: hidden; box-shadow: 0 -4px 12px #0003; }
#suggest:empty { display: none; }
#suggest li { padding: 8px 12px; cursor: pointer; }
#suggest li.active, #suggest li:hover { background: var(--accent); color: #fff; }

#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 20; }
.overlay { position: fixed; inset: 0; z-index: 10; display: flex; align-items: center;
           justify-content: center; background: #0006; }
.overlay[hidden] { display: none; }
.modal { background: var(--card); border-radius: 14px; padding: 24px 32px; text-align: center;
         max-width: 90vw; border: 3px solid var(--line); animation: pop .4s ease-out; }
.modal.win { border-color: var(--ok); }
.modal h2 { margin: 0 0 6px; font-size: 2rem; }
.modal.win h2 { color: var(--ok); }
.modal p { margin: 0 0 16px; font-size: 1.1rem; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal .keyhint { margin: 10px 0 0; font-size: .8rem; color: var(--muted); }

/* ---------- accounts & stats ---------- */
/* Sidebar to the left of the game column. */
.rail { position: fixed; left: 16px; top: 50%; transform: translateY(-50%); z-index: 5;
        display: flex; flex-direction: column; gap: 10px; }
.rail-btn { width: 78px; padding: 12px 6px 10px; display: flex; flex-direction: column; align-items: center;
            gap: 6px; background: var(--card); color: var(--text); border: 1px solid var(--line);
            border-radius: 14px; font-size: .75rem; font-weight: 600; box-shadow: 0 1px 3px #0000000f;
            transition: border-color .15s, transform .15s, box-shadow .15s; }
.rail-btn[hidden] { display: none; }
a.rail-btn { text-decoration: none; }
.rail-btn:hover { border-color: var(--accent); transform: translateY(-1px); box-shadow: 0 6px 14px #0000001a; }
.rail-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.rail-btn svg { width: 22px; height: 22px; fill: none; stroke: var(--accent); stroke-width: 2;
                stroke-linecap: round; stroke-linejoin: round; }
.rail-btn span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* No room beside the 760px column: icon-only tiles, and the game moves right to clear them. */
@media (max-width: 980px) {
  body { padding-left: 64px; }
  .rail { left: 10px; }
  .rail-btn { width: 48px; height: 48px; padding: 0; justify-content: center; border-radius: 12px; }
  .rail-btn span { display: none; }
}
.overlay.top { z-index: 30; }
.modal.panel { position: relative; text-align: left; width: min(380px, 92vw); padding: 24px; }
.panel h2 { font-size: 1.4rem; margin: 0 0 2px; }
.panel p { font-size: .95rem; margin: 0 0 12px; color: var(--muted); }
.panel .x { position: absolute; top: 8px; right: 8px; background: none; color: var(--muted);
            padding: 4px 9px; font-size: 1rem; }
.panel .x:hover { color: var(--text); }
.panel form { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.panel label { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; font-weight: 600; }
.panel input { width: 100%; padding: 10px 12px; font-size: 1rem; color: var(--text);
               background: var(--bg); border: 1px solid var(--line); border-radius: 8px; }
.panel input:focus { outline: 2px solid var(--accent); outline-offset: 0; }
.panel .err { color: var(--bad); font-size: .85rem; min-height: 1.2em; margin: 0; }
.panel .alt { margin: 12px 0 0; font-size: .9rem; text-align: center; }
.panel .link { background: none; color: var(--accent); padding: 0; font-size: inherit; font-weight: 600; }
.panel .link:hover { text-decoration: underline; }
.panel .row { display: flex; gap: 8px; margin-top: 14px; }
.panel .row > * { flex: 1; text-align: center; text-decoration: none; }
.panel .secondary { background: var(--bg); color: var(--text); border: 1px solid var(--line); }
.panel a.button { display: inline-block; padding: 10px 18px; border-radius: 8px; background: var(--text);
                  color: var(--bg); font-weight: 600; }
.statgrid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; text-align: center; margin: 14px 0 18px; }
.statgrid b { display: block; font-size: 1.7rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.statgrid span { font-size: .72rem; color: var(--muted); }
.panel h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin: 0 0 8px; }
.dist { display: flex; flex-direction: column; gap: 4px; }
.dist div { display: flex; align-items: center; gap: 8px; font-size: .85rem; font-variant-numeric: tabular-nums; }
.dist i { display: block; background: var(--muted); color: #fff; font-style: normal; font-weight: 600;
          text-align: right; padding: 1px 7px; border-radius: 3px; min-width: 24px; }
.dist i.hi { background: var(--ok); }
.modal p.endstats { font-size: .9rem; color: var(--muted); margin-top: -8px; }
.modal p.endstats[hidden] { display: none; }
.endstats .link { background: none; color: var(--accent); padding: 0; font-size: inherit; font-weight: 600; }
/* ---------- end screen: score, share grid ---------- */
.modal p.endscore { margin: -8px 0 6px; font-size: 1rem; color: var(--muted); }
.endscore b { font-size: 1.6rem; color: var(--text); font-variant-numeric: tabular-nums; }
.modal p.endgrid { margin: 0 0 14px; font-size: 1.3rem; letter-spacing: 2px; }
.endbtns { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.endbtns #share { min-width: 110px; font-weight: 600; }
.endbtns .secondary { background: var(--bg); color: var(--text); border: 1px solid var(--line); }
