/* Shared look for every mode. Pages add only their own layout rules. */
:root {
  --bg: #14161C; --surface: #1C1F27; --surface2: #232733; --line: #2E3342;
  --text: #EAEBF1; --muted: #9AA1B4; --accent: #8FA0FF; --accent-ink: #14161C;
  --g: #58B849; --o: #E0862F; --r: #CE4646; --track: #262A36;
  --font-display: "Archivo Black", "Arial Black", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
  --radius: 10px;
}
* { box-sizing: border-box; }
html { scrollbar-color: var(--line) transparent; scrollbar-width: thin; }
body {
  margin: 0; color: var(--text);
  background: var(--bg) radial-gradient(ellipse 80% 50% at 50% -10%, rgba(143,160,255,.06), transparent);
  font: 16px/1.5 system-ui, "Segoe UI", sans-serif;
  display: flex; justify-content: center; min-height: 100vh;
}
.app { width: min(680px, 100%); padding: 1.2rem 1rem 4rem; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input:focus-visible { outline: none; }

/* header: wordmark · mode switcher · pickers */
header { display: flex; align-items: center; gap: .9rem; flex-wrap: wrap; margin-bottom: 1.1rem; }
h1 {
  font-family: var(--font-display); font-weight: 400; font-size: 1.4rem;
  margin: 0; letter-spacing: .01em; line-height: 1;
}
h1 .dev {
  font-family: var(--font-mono); color: var(--muted); font-weight: 500; font-size: .66rem;
  letter-spacing: .16em; text-transform: uppercase; margin-left: .5rem; vertical-align: .2em;
}
.modes {
  display: flex; gap: 2px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 999px; padding: 3px;
}
.modes a {
  padding: .28rem .8rem; border-radius: 999px; font-size: .8rem; color: var(--muted);
  text-decoration: none; white-space: nowrap; transition: color .12s, background .12s;
}
.modes a:hover { color: var(--text); }
.modes a.active { background: var(--surface2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }
.pickers { display: flex; gap: .5rem; margin-left: auto; align-items: center; flex-wrap: wrap; }
@media (max-width: 560px) {
  .modes { flex: 1 1 100%; order: 3; justify-content: space-between; }
  .modes a { padding: .25rem .5rem; font-size: .74rem; flex: 1; text-align: center; }
  .pickers { margin-left: 0; gap: .4rem; flex: 1 1 100%; flex-wrap: nowrap; }
  .pickers select { flex: 1 1 0; min-width: 0; }
  select, .iconbtn { padding: .34rem .4rem; font-size: .8rem; height: 2rem; }
  .app { padding-inline: .8rem; }
}
.app { overflow-x: clip; }
select, .iconbtn {
  background: var(--surface); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: .38rem .55rem; font: inherit; font-size: .85rem; height: 2.15rem;
}
.iconbtn { cursor: pointer; line-height: 1; }
select:hover, .iconbtn:hover { border-color: var(--muted); }

/* guess input */
form { display: flex; gap: .5rem; margin: .6rem 0; }
.inwrap { flex: 1; position: relative; }
input {
  width: 100%; background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: .8rem 3.8rem .8rem 1rem; font: inherit; font-size: 1.02rem; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder { color: rgba(154,161,180,.7); }
input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(143,160,255,.14); }
.count {
  position: absolute; right: .9rem; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-family: var(--font-mono); font-size: .85rem;
}
.hintbtn {
  background: var(--surface); border: 1px solid var(--line); color: var(--text);
  border-radius: var(--radius); padding: 0 .85rem; font-size: 1.05rem; cursor: pointer;
  min-width: 3.2rem; white-space: nowrap;
}
.hintbtn:hover { border-color: var(--accent); }
.msg { min-height: 1.3rem; color: var(--o); font-size: .85rem; margin: 0 0 .4rem .2rem; }
.legend {
  display: flex; gap: .5rem 1.1rem; flex-wrap: wrap; align-items: center;
  color: var(--muted); font-family: var(--font-mono); font-size: .72rem; margin: 0 0 .8rem .2rem;
}
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: .38rem; vertical-align: 0; }

/* guess rows */
.row { display: grid; grid-template-columns: 1fr 4.6rem; gap: .55rem; align-items: center; margin-bottom: .4rem; }
.track { position: relative; background: var(--track); border-radius: 6px; height: 2.1rem; overflow: hidden; }
.fill { position: absolute; inset: 0 auto 0 0; border-radius: 6px; min-width: 6px; }
.fill.g { background: var(--g); } .fill.o { background: var(--o); } .fill.r { background: var(--r); }
.w {
  position: relative; z-index: 1; display: flex; align-items: center; height: 2.1rem;
  padding-left: .8rem; font-weight: 600; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.4);
  white-space: nowrap;
}
.rank {
  text-align: right; font-family: var(--font-mono); font-weight: 600; font-size: .95rem;
  font-variant-numeric: tabular-nums;
}
.row.flash .track { outline: 2px solid var(--accent); }
#pinned:not(:empty) { padding-bottom: .6rem; border-bottom: 1px solid var(--line); margin-bottom: .6rem; }
.hint-empty { color: var(--muted); text-align: center; margin-top: 2.5rem; }
.loading { color: var(--muted); font-size: .85rem; text-align: center; margin-top: .6rem; }

/* end of run */
.winbox {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 1.2rem 1.4rem; margin: .8rem 0 1rem;
}
.winbox h2 { margin: 0 0 .2rem; font-size: 1.1rem; font-weight: 500; color: var(--muted); }
.winbox h2 span { color: var(--g); font-family: var(--font-display); font-weight: 400; font-size: 1.45rem; letter-spacing: .01em; }
.winbox .sub { color: var(--muted); font-size: .9rem; margin: 0 0 .8rem; }
canvas { width: 100%; display: block; }
.chips { margin-top: .9rem; }
.chips .lbl { font-family: var(--font-mono); font-size: .68rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-bottom: .4rem; }
.chips .set { display: flex; flex-wrap: wrap; gap: .35rem; }
.chip { background: var(--surface2); border: 1px solid var(--line); border-radius: 999px; padding: .15rem .7rem; font-size: .82rem; }
.actions { display: flex; gap: .6rem; margin-top: .9rem; flex-wrap: wrap; }
button {
  background: var(--surface2); border: 1px solid var(--line); color: var(--text);
  border-radius: 9px; padding: .5rem .9rem; font: inherit; font-size: .85rem; cursor: pointer;
  transition: border-color .12s, transform .08s;
}
button:hover { border-color: var(--accent); }
button:active { transform: translateY(1px); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.foot { margin-top: 2.2rem; display: flex; justify-content: center; }
.foot button { color: var(--muted); font-size: .78rem; background: none; border: none; }
.foot button:hover { color: var(--r); }

@media (prefers-reduced-motion: no-preference) {
  .winbox:not([hidden]) { animation: pop .35s ease-out; }
  @keyframes pop { from { transform: scale(.97); opacity: 0; } }
  #pinned .row, .pinned .row { animation: rowin .28s ease-out; }
  @keyframes rowin { from { transform: translateY(-6px); opacity: 0; } }
}
