:root {
  color-scheme: light;
  --board: #f2f5f4;
  --paper: #ffffff;
  --ink: #18212e;
  --muted: #5c6878;
  --line: #d5dce2;
  --marker: #2547b8;
  --hit: #2f8f5b;
  --near: #d99a2b;
  --miss: #e3e8ec;
  --miss-ink: #4a5563;
  --on-color: #ffffff;
  --font: "Archivo", "Helvetica Neue", Arial, sans-serif;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --board: #18202b; --paper: #222c39; --ink: #eef2f6; --muted: #9eabbb;
    --line: #34404f; --marker: #7d9bff; --hit: #3aa36b; --near: #d9a13c;
    --miss: #303b49; --miss-ink: #c4cdd8;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --board: #18202b; --paper: #222c39; --ink: #eef2f6; --muted: #9eabbb;
  --line: #34404f; --marker: #7d9bff; --hit: #3aa36b; --near: #d9a13c;
  --miss: #303b49; --miss-ink: #c4cdd8;
}
*, *::before, *::after { box-sizing: inherit; }
html { scroll-padding-top: env(safe-area-inset-top, 0px); }
body {
  margin: 0; background: var(--board); color: var(--ink);
  font-family: var(--font); font-size: 16px; line-height: 1.45;
}
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--marker); outline-offset: 2px; }

.bar {
  display: flex; align-items: center; gap: .5rem;
  max-width: 560px; margin: 0 auto; padding: .9rem 1rem .4rem;
}
.brand {
  margin: 0; font-size: 1.6rem; font-weight: 900; font-stretch: 125%;
  letter-spacing: -.02em; color: var(--marker);
}
.puzzle-no { margin: 0 auto 0 .25rem; color: var(--muted); font-size: .95rem; font-stretch: 75%; }
.icon-btn {
  width: 2.25rem; height: 2.25rem; border-radius: 50%;
  border: 2px solid var(--line); background: var(--paper); cursor: pointer; font-weight: 700;
}

.wrap { max-width: 560px; margin: 0 auto; padding: 0 1rem 2rem; }

/* The card: the one bold thing on the page */
.card {
  position: relative; overflow: hidden; margin-top: .5rem;
  background: var(--paper); border: 2px solid var(--ink); border-radius: 18px 18px 6px 6px;
  padding: 1.1rem 1.1rem 1rem; box-shadow: 6px 6px 0 var(--marker);
}
.play { position: absolute; right: -10px; top: -14px; width: 190px; color: var(--marker); opacity: .12; pointer-events: none; }
.card-top { display: flex; align-items: flex-end; gap: 1rem; position: relative; }
.ovr { display: flex; flex-direction: column; line-height: .85; }
.ovr span { font-size: 5.2rem; font-weight: 900; font-stretch: 62%; letter-spacing: -.03em; }
.ovr small { font-size: .85rem; font-weight: 700; color: var(--muted); padding-left: .2rem; }
.who p { margin: 0; }
.pos { font-size: 1.35rem; font-weight: 800; font-stretch: 110%; }
.mystery { color: var(--muted); }
.card.solved .mystery { color: var(--hit); font-weight: 700; }

.attrs { list-style: none; margin: 1rem 0 0; padding: .6rem 0 0; display: grid; gap: .45rem; position: relative; border-top: 2px dashed var(--line); background: var(--paper); }
.attr { display: grid; grid-template-columns: 7.5rem 1fr 2.4rem; align-items: center; gap: .6rem; font-size: .95rem; }
.attr .bar-track { height: .55rem; border-radius: 99px; background: var(--miss); overflow: hidden; }
.attr .bar-fill { display: block; height: 100%; background: var(--marker); border-radius: inherit; }
.attr .val { text-align: right; font-weight: 800; font-stretch: 75%; font-size: 1.15rem; }
.attr.locked { color: var(--muted); }
.attr.locked .val { font-size: .8rem; font-weight: 600; }

.guess-area { margin-top: 1.4rem; }
.guess-label { display: block; font-weight: 700; margin-bottom: .35rem; }
.combo { position: relative; }
#guessInput {
  width: 100%; font: inherit; font-size: 1.05rem; padding: .8rem .9rem;
  border: 2px solid var(--ink); border-radius: 10px; background: var(--paper); color: var(--ink);
}
#guessInput:disabled { opacity: .5; }
.suggest {
  position: absolute; z-index: 5; left: 0; right: 0; top: calc(100% + 4px); margin: 0; padding: .25rem;
  list-style: none; background: var(--paper); border: 2px solid var(--ink); border-radius: 10px;
  max-height: 320px; overflow-y: auto;
}
.suggest li { padding: .55rem .6rem; border-radius: 6px; cursor: pointer; display: flex; justify-content: space-between; gap: .5rem; }
.suggest li small { color: var(--muted); }
.suggest li[aria-selected="true"], .suggest li:hover { background: var(--miss); }

.guesses { margin-top: 1.4rem; }
.legend, .row-cells { display: grid; grid-template-columns: repeat(5, 1fr); gap: .35rem; }
.legend span { font-size: .8rem; color: var(--muted); text-align: center; }
#guesses { list-style: none; margin: .35rem 0 0; padding: 0; display: grid; gap: .7rem; }
.row-name { font-weight: 700; margin-bottom: .25rem; }
.cell {
  border-radius: 8px; padding: .45rem .2rem; text-align: center; font-weight: 800; font-stretch: 85%;
  background: var(--miss); color: var(--miss-ink); min-height: 2.6rem;
  display: flex; align-items: center; justify-content: center; gap: .15rem;
}
.cell.hit { background: var(--hit); color: var(--on-color); }
.cell.near { background: var(--near); color: #1d1a12; }

.result {
  margin-top: 1.4rem; padding: 1rem; border-radius: 12px; background: var(--paper); border: 2px dashed var(--line);
}
.result-head { margin: 0; font-size: 1.3rem; font-weight: 900; font-stretch: 110%; }
.result-sub, .next { margin: .25rem 0 0; color: var(--muted); }
.share {
  margin-top: .8rem; background: var(--marker); color: var(--on-color); border: 0; border-radius: 10px;
  padding: .7rem 1.2rem; font-weight: 800; cursor: pointer;
}
:root[data-theme="dark"] .share { color: #0f1520; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .share { color: #0f1520; } }

.share-row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-top: .8rem; }
.share-row .share { margin-top: 0; }
.ghost {
  background: transparent; border: 2px solid var(--line); border-radius: 10px;
  padding: .6rem 1rem; font-weight: 700; cursor: pointer; color: var(--ink);
}

dialog {
  max-width: min(440px, calc(100vw - 2rem)); border: 2px solid var(--ink); border-radius: 14px;
  background: var(--paper); color: var(--ink); padding: 1.2rem 1.3rem;
}
dialog::backdrop { background: rgb(10 15 25 / .55); }
dialog h2 { margin: 0 0 .6rem; font-stretch: 110%; }
.k { padding: 0 .3rem; border-radius: 4px; }
.k.hit { background: var(--hit); color: var(--on-color); }
.k.near { background: var(--near); color: #1d1a12; }
.statgrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; margin: 0; text-align: center; }
.statgrid dd { margin: 0; font-size: 2rem; font-weight: 900; font-stretch: 70%; }
.statgrid dt { font-size: .8rem; color: var(--muted); }
.statgrid div { display: flex; flex-direction: column-reverse; }

.toast {
  position: fixed; left: 50%; bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  background: var(--ink); color: var(--board); padding: .6rem 1rem; border-radius: 10px; font-weight: 700;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.toast.show { opacity: 1; }

.foot { max-width: 560px; margin: 0 auto; padding: 0 1rem 2rem; color: var(--muted); font-size: .8rem; }
.foot a { color: inherit; }

@media (max-width: 400px) {
  .ovr span { font-size: 4.4rem; }
  .attr { grid-template-columns: 6.3rem 1fr 2.2rem; }
}
@media (prefers-reduced-motion: reduce) {
  .attr .bar-fill, .toast { transition: none; }
}
