/* Streetdoku: layout modelled on Flagdoku / Tubedoku. */

:root {
  --bg: #F8F8F8;
  --card: #FFFFFF;
  --card-edge: #D9D9D9;
  --cell: #F7F7F7;
  --cell-edge: #CFCFCF;
  --text: #555555;
  --strong: #222222;
  --muted: #7A7A7A;
  --badge: #D3DCDB;
  --btn: #3E544A;
  --btn-text: #FFFFFF;
  --right-bg: #D5EFD6;
  --right-edge: #5DAE63;
  --right-text: #1E5B25;
  --wrong-bg: #F8D6D5;
  --wrong-edge: #D9534F;
  --wrong-text: #8A1F1B;
  --shown-bg: #DCE6F5;
  --shown-edge: #6E8FC4;
  --shown-text: #23406E;
  --hover: #EEF1F0;
  --shadow: 0 2px 6px rgba(0, 0, 0, .12);
  --display: "Fira Sans Condensed", "Arial Narrow", "Roboto Condensed", sans-serif;
  --body: "Fira Sans", "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #151918; --card: #1E2322; --card-edge: #333A38; --cell: #262C2B; --cell-edge: #3E4644;
    --text: #C9CFCD; --strong: #EEF1F0; --muted: #929A98; --badge: #34403E; --btn: #4C6E60; --btn-text: #FFFFFF;
    --right-bg: #1F3D24; --right-edge: #4CAF55; --right-text: #BDEBC1;
    --wrong-bg: #472223; --wrong-edge: #D9534F; --wrong-text: #F6C4C2;
    --shown-bg: #1F2D45; --shown-edge: #6E8FC4; --shown-text: #C9D8F2;
    --hover: #2C3331; --shadow: 0 2px 8px rgba(0, 0, 0, .5);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #151918; --card: #1E2322; --card-edge: #333A38; --cell: #262C2B; --cell-edge: #3E4644;
  --text: #C9CFCD; --strong: #EEF1F0; --muted: #929A98; --badge: #34403E; --btn: #4C6E60; --btn-text: #FFFFFF;
  --right-bg: #1F3D24; --right-edge: #4CAF55; --right-text: #BDEBC1;
  --wrong-bg: #472223; --wrong-edge: #D9534F; --wrong-text: #F6C4C2;
    --shown-bg: #1F2D45; --shown-edge: #6E8FC4; --shown-text: #C9D8F2;
  --hover: #2C3331; --shadow: 0 2px 8px rgba(0, 0, 0, .5);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 400 16px/1.5 var(--body); -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--btn); outline-offset: 2px; }
.muted { color: var(--muted); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

.page {
  max-width: 560px;
  margin: 0 auto;
  padding-inline: 16px;
  padding-block: 20px 40px;
  display: grid;
  gap: 18px;
}
h1, h2 { font-family: var(--display); color: var(--strong); line-height: 1.15; margin: 0; text-wrap: balance; }
.top { display: grid; grid-template-columns: 64px 1fr 64px; align-items: center; }
.streak {
  grid-column: 1; justify-self: start; cursor: pointer;
  border: 2px solid var(--cell-edge); background: var(--card); border-radius: 999px;
  padding: 4px 10px; font-family: var(--display); font-weight: 600; font-size: 17px; color: var(--strong);
  font-variant-numeric: tabular-nums;
}
.streak:hover { border-color: var(--muted); }
.help { justify-self: end; }
.tabs {
  display: flex; justify-self: center; gap: 4px; padding: 4px;
  background: var(--card); border: 2px solid var(--card-edge); border-radius: 999px;
}
.tabs a {
  border-radius: 999px; padding: 7px 18px; text-decoration: none;
  font-family: var(--display); font-weight: 600; font-size: 17px; color: var(--muted);
}
.tabs a:hover { color: var(--strong); }
.tabs a[aria-current="page"] { background: var(--btn); color: var(--btn-text); }
.tabs a:focus-visible { outline: 3px solid var(--btn); outline-offset: 2px; }
.view { display: grid; gap: 18px; }
.title { grid-column: 2; text-align: center; font-size: 34px; font-weight: 700; letter-spacing: .01em; }
.help {
  grid-column: 3; width: 36px; height: 36px; border-radius: 50%; cursor: pointer;
  border: 2px solid var(--cell-edge); background: var(--card); color: var(--text);
  font-family: var(--display); font-weight: 600; font-size: 19px; line-height: 1;
}
.help:hover { border-color: var(--muted); }

/* ---------- Card and grid ---------- */

.card {
  background: var(--card);
  border: 2px solid var(--card-edge);
  border-radius: 6px;
  box-shadow: var(--shadow);
  padding: 18px 14px 20px;
}
.grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
  align-items: center;
}
.badge {
  justify-self: center;
  display: grid; place-items: center;
  width: 78%; aspect-ratio: 1; max-width: 100px;
  background: var(--badge); color: var(--strong);
  border-radius: 6px; box-shadow: var(--shadow);
  font-family: var(--display); font-weight: 500; font-size: clamp(16px, 4.4vw, 24px);
  font-variant-numeric: tabular-nums;
}
.head {
  border: 0; background: transparent; cursor: pointer; padding: 6px 2px; border-radius: 8px;
  display: grid; justify-items: center; align-content: center; gap: 4px; text-align: center;
  min-height: 70px; height: 100%;
}
.head:hover { background: var(--hover); }
.head-icon { font-size: clamp(18px, 4.6vw, 24px); line-height: 1; }
.head-label {
  hyphens: auto; overflow-wrap: break-word; max-width: 100%;
  font-family: var(--display); font-weight: 600; color: var(--text);
  font-size: clamp(13px, 3.9vw, 21px); line-height: 1.12; text-wrap: balance;
}

.cell {
  aspect-ratio: 1; max-width: 100%; width: 100%;
  background: var(--cell); border: 2px solid var(--cell-edge); border-radius: 12px;
  cursor: pointer; padding: 6px;
  display: grid; place-items: center; text-align: center;
  font-family: var(--display); font-weight: 600; line-height: 1.1;
  font-size: clamp(12px, 3.4vw, 18px);
  transition: background-color .15s, border-color .15s;
}
.cell:hover { border-color: var(--muted); }
.cell span { overflow-wrap: break-word; text-wrap: balance; max-width: 100%; }
.cell.l { font-size: clamp(11px, 3vw, 16px); }
.cell.xl { font-size: clamp(10px, 2.6vw, 14px); }
.cell.right { background: var(--right-bg); border-color: var(--right-edge); color: var(--right-text); }
.cell.shown { background: var(--shown-bg); border-color: var(--shown-edge); color: var(--shown-text); }
.cell.wrong { background: var(--wrong-bg); border-color: var(--wrong-edge); color: var(--wrong-text); }
.pop { animation: pop .3s ease-out; }
@keyframes pop { from { transform: scale(.9); } to { transform: none; } }

/* ---------- Buttons ---------- */

.controls { display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; padding-inline: 12px; }
.btn {
  background: var(--btn); color: var(--btn-text); border: 0; border-radius: 8px;
  padding: 12px 22px; min-width: 104px; cursor: pointer;
  font-family: var(--display); font-weight: 500; font-size: 18px; text-transform: uppercase; letter-spacing: .02em;
}
.btn:hover { filter: brightness(1.12); }

/* ---------- Dialogs ---------- */

dialog {
  border: 0; padding: 0; border-radius: 10px; width: min(440px, calc(100vw - 32px));
  background: var(--card); color: var(--text); box-shadow: 0 20px 50px -16px rgba(0, 0, 0, .45);
  margin-top: max(10vh, 16px);
}
dialog::backdrop { background: rgba(0, 0, 0, .45); }
.dialog-inner { padding: 20px; position: relative; display: grid; gap: 10px; }
.close {
  position: absolute; top: 8px; right: 8px; width: 36px; height: 36px; border-radius: 50%;
  border: 0; background: transparent; font-size: 24px; cursor: pointer; color: var(--muted);
}
.close:hover { background: var(--hover); color: var(--strong); }
.sheet-title { font-size: 22px; padding-right: 36px; font-weight: 600; }
.sheet-title i { font-style: normal; color: var(--muted); margin-inline: 2px; }
#sheet-body { display: grid; gap: 10px; }
#sheet-body p { margin: 0; }
.how { margin: 0; padding-left: 20px; display: grid; gap: 6px; }

.info { display: grid; justify-items: center; text-align: center; gap: 8px; padding: 8px 8px 4px; }
.info-icon { font-size: 44px; line-height: 1; }
.info h2 { font-size: 26px; }
.info p { max-width: 36ch; }

#guess-form { display: grid; gap: 6px; }
#guess-input {
  width: 100%; font: 500 18px var(--body); padding: 12px 14px; border-radius: 8px;
  border: 2px solid var(--cell-edge); background: var(--cell); color: var(--strong);
}
#guess-input:focus { border-color: var(--btn); outline: none; }
.suggestions { list-style: none; margin: 0; padding: 0; display: grid; }
.suggestions li { padding: 9px 12px; border-radius: 6px; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; color: var(--strong); }
.suggestions li.hl, .suggestions li[data-i]:hover { background: var(--hover); }
.suggestions li.used { color: var(--muted); }
.suggestions li small { font-size: 12px; color: var(--muted); }
.suggestions li.none { color: var(--muted); cursor: default; }
.feedback { margin: 0; min-height: 1.4em; font-size: 14px; color: var(--wrong-edge); }

.menu { display: grid; gap: 8px; }
.menu-item {
  display: grid; text-align: left; gap: 1px; padding: 12px 14px; cursor: pointer;
  background: var(--cell); border: 2px solid var(--cell-edge); border-radius: 8px;
  font-family: var(--display); font-weight: 600; font-size: 18px; color: var(--strong);
}
.menu-item small { font-family: var(--body); font-weight: 400; font-size: 13px; color: var(--muted); }
.menu-item:hover { border-color: var(--muted); }
.share-text { width: 100%; font: 15px/1.4 var(--body); padding: 10px; border-radius: 8px; border: 1px solid var(--cell-edge); background: var(--cell); color: var(--strong); }

.archive { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-height: 60vh; overflow: auto; }
.arch {
  width: 100%; display: grid; grid-template-columns: 56px 1fr auto; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 8px; cursor: pointer; text-align: left;
  background: var(--cell); border: 2px solid var(--cell-edge);
}
.arch:hover { border-color: var(--muted); }
.arch.current { border-color: var(--btn); }
.arch-n { font-family: var(--display); font-weight: 600; font-size: 18px; color: var(--strong); font-variant-numeric: tabular-nums; }
.arch-score { font-family: var(--display); font-weight: 600; color: var(--right-text); font-variant-numeric: tabular-nums; }

.answer-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 2px 14px; max-height: 50vh; overflow: auto; }
.answer-list li { padding: 5px 0; border-bottom: 1px solid var(--cell-edge); font-size: 15px; color: var(--strong); }
.answer-list li.mine { color: var(--right-text); font-weight: 500; }
.answer-list li.mine::after { content: " (yours)"; font-weight: 400; color: var(--muted); }

@media (max-width: 480px) {
  .card { padding: 12px 8px 14px; }
  .grid { gap: 5px; }
  .cell { border-radius: 9px; padding: 4px; }
  .btn { font-size: 16px; padding: 10px 18px; min-width: 90px; }
  .controls { padding-inline: 4px; flex-wrap: nowrap; gap: 6px; }
  .head-label { font-size: 13px; }
  .controls .btn { min-width: 0; padding: 10px 12px; font-size: 15px; white-space: nowrap; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
.small { font-size: 13px; }

/* ---------- Connections ---------- */

:root { --tile: #EFEFE6; --tile-text: #222; --tile-on: #5A594E; --tile-on-text: #FFF;
  --c-yellow: #F9DF6D; --c-green: #A0C35A; --c-blue: #B0C4EF; --c-purple: #BA81C5; --bus: #DC241F; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --tile: #2C3331; --tile-text: #EEF1F0; --tile-on: #C9CFCD; --tile-on-text: #151918; }
}
:root[data-theme="dark"] { --tile: #2C3331; --tile-text: #EEF1F0; --tile-on: #C9CFCD; --tile-on-text: #151918; }

.conn-card { display: grid; gap: 12px; }
.conn-prompt { margin: 0; font-family: var(--display); font-weight: 600; font-size: 19px; color: var(--text); }
.conn-board { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; }
.tile {
  min-height: 72px; border: 0; border-radius: 8px; cursor: pointer; padding: 6px 4px;
  background: var(--tile); color: var(--tile-text);
  font-family: var(--display); font-weight: 700; text-transform: uppercase; line-height: 1.1;
  font-size: clamp(11px, 3vw, 16px); overflow-wrap: break-word; text-wrap: balance;
  transition: background-color .12s, transform .12s;
}
.tile.l { font-size: clamp(10px, 2.6vw, 14px); }
.tile.xl { font-size: clamp(9px, 2.2vw, 12px); letter-spacing: -.01em; }
.tile:active { transform: scale(.97); }
.tile.on { background: var(--tile-on); color: var(--tile-on-text); }
.bar {
  grid-column: 1 / -1; border-radius: 8px; padding: 10px 12px; text-align: center; color: #222;
  display: grid; gap: 2px; animation: pop .3s ease-out;
}
.bar strong { font-family: var(--display); font-weight: 700; font-size: 17px; text-transform: uppercase; display: inline-flex; gap: 8px; align-items: center; justify-content: center; }
.bar span { font-size: 14px; }
.bar.missed { opacity: .75; }
.c-yellow { background: var(--c-yellow); }
.c-green { background: var(--c-green); }
.c-blue { background: var(--c-blue); }
.c-purple { background: var(--c-purple); }
.roundel {
  display: inline-grid; place-items: center; min-width: 30px; height: 22px; padding: 0 6px; border-radius: 4px;
  background: var(--bus); color: #fff; font-size: 14px; text-transform: none;
}
.conn-mistakes { margin: 0; text-align: center; font-size: 15px; }
.dots { letter-spacing: 3px; color: var(--strong); margin-left: 6px; }
.dots .spent { color: var(--cell-edge); }
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 20;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  width: max-content; max-width: calc(100vw - 32px); margin: 0; padding: 10px 16px; border-radius: 10px;
  background: var(--strong); color: var(--card); font-weight: 500; font-size: 15px; text-align: center;
  box-shadow: 0 8px 24px -8px rgba(0, 0, 0, .45); animation: toast-in .2s ease-out;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }
.tile.hint { box-shadow: inset 0 0 0 3px var(--gold-edge); background: var(--gold-bg); color: var(--gold-text); }
.conn-actions { display: flex; gap: 8px; justify-content: center; }
.conn-actions .btn { min-width: 0; }
.btn.ghost { background: transparent; color: var(--btn); box-shadow: inset 0 0 0 2px var(--btn); }
.btn:disabled { opacity: .45; cursor: default; filter: none; }
.shake { animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-6px); } 50% { transform: translateX(6px); } 75% { transform: translateX(-3px); } }
@media (max-width: 480px) {
  .conn-board { gap: 5px; }
  .tile { min-height: 64px; border-radius: 6px; }
  .conn-actions { gap: 6px; }
  .conn-actions .btn { min-width: 0; padding: 10px 12px; font-size: 15px; }
}

/* ---------- Timer, results, stats ---------- */

.topbar { display: flex; justify-content: center; align-items: center; gap: 10px; flex-wrap: wrap; margin-block: -6px; }
.timer {
  font-family: var(--display); font-weight: 600; font-size: 20px; color: var(--strong);
  font-variant-numeric: tabular-nums; letter-spacing: .02em;
}
.timer.stopped { color: var(--right-text); }
.theme {
  font-family: var(--display); font-weight: 600; font-size: 14px; text-transform: uppercase; letter-spacing: .08em;
  padding: 3px 10px; border-radius: 999px; background: var(--btn); color: var(--btn-text);
}
.result { display: grid; gap: 12px; text-align: center; justify-items: center; }
.result h2 { font-size: 30px; }
.result-kicker { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.result-line { margin: 0; }
.result-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; width: 100%; }
.result-stats div { display: grid; gap: 2px; padding: 8px 4px; border-radius: 8px; background: var(--cell); text-align: center; }
.result-stats span { font-family: var(--display); font-weight: 700; font-size: 20px; color: var(--strong); font-variant-numeric: tabular-nums; }
.result-stats small { font-size: 12px; color: var(--muted); }
.compare { width: 100%; display: grid; gap: 6px; }
.compare p { margin: 0; }
.hist { display: flex; align-items: flex-end; gap: 3px; height: 56px; padding-inline: 4px; }
.hist span { flex: 1; background: var(--cell-edge); border-radius: 3px 3px 0 0; }
.hist span.me { background: var(--btn); }
.hist-axis { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.share-big { width: 100%; max-width: 280px; }
.next { margin: 0; font-size: 15px; }
.next strong { font-family: var(--display); font-size: 18px; font-variant-numeric: tabular-nums; }
.linkish { border: 0; background: transparent; color: var(--btn); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; font-size: 15px; padding: 4px; }
.freeze-line { font-size: 14px; color: var(--muted); }
.calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.day { display: inline-grid; place-items: center; aspect-ratio: 1; border-radius: 5px; background: var(--cell); border: 1px solid var(--cell-edge); font-size: 12px; }
.legend .day { width: 14px; vertical-align: middle; margin: 0 2px 0 8px; }
.day.solved { background: var(--right-edge); border-color: var(--right-edge); }
.day.revealed { background: var(--shown-edge); border-color: var(--shown-edge); }
.day.lost { background: var(--wrong-edge); border-color: var(--wrong-edge); }
.day.started { background: var(--cell-edge); }
.day.frozen { background: var(--shown-bg); }
.yday-wrap { overflow-x: auto; }
.yday { border-collapse: collapse; width: 100%; font-size: 14px; }
.yday th { font-family: var(--display); font-weight: 600; color: var(--text); padding: 6px 4px; text-align: center; }
.yday td { border: 1px solid var(--cell-edge); padding: 8px 4px; text-align: center; vertical-align: middle; }
.yday td strong { display: block; color: var(--strong); font-weight: 500; }
.yday td small { color: var(--muted); font-size: 12px; }
.yday-bars { display: grid; gap: 6px; }
.arch-date small { color: var(--muted); font-size: 12px; margin-left: 4px; }

/* ---------- Golden street ---------- */

:root { --gold-bg: #FFF1B8; --gold-edge: #D4A017; --gold-text: #6B4E00; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --gold-bg: #4A3B0B; --gold-edge: #E0B634; --gold-text: #FBE7A1; }
}
:root[data-theme="dark"] { --gold-bg: #4A3B0B; --gold-edge: #E0B634; --gold-text: #FBE7A1; }
.cell.gold { background: var(--gold-bg); border-color: var(--gold-edge); color: var(--gold-text); box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold-edge) 35%, transparent); }
.golden-chip {
  border: 2px solid var(--gold-edge); background: var(--card); color: var(--gold-text); border-radius: 999px;
  padding: 3px 10px; cursor: pointer; font-family: var(--display); font-weight: 600; font-size: 14px;
}
.golden-chip.found { background: var(--gold-bg); }
.golden-result { margin: 0; padding: 8px 12px; border-radius: 8px; background: var(--gold-bg); color: var(--gold-text); }
.golden-name { font-family: var(--display); font-weight: 700; font-size: 26px; color: var(--gold-text); margin: 0; }

/* ---------- Connections page ---------- */

.title { display: grid; justify-items: center; line-height: 1; }
.title-sub { font-size: 13px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin-top: 4px; }
.conn-top { display: flex; justify-content: center; align-items: center; gap: 12px; flex-wrap: wrap; }
.conn-badge {
  width: auto; aspect-ratio: auto; max-width: none; padding: 10px 16px; font-size: 20px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .03em; background: var(--card); border: 2px solid var(--card-edge);
}
.day-card {
  display: grid; justify-items: center; gap: 2px; padding: 8px 18px; border-radius: 8px; text-align: center;
  background: var(--gold-bg); border: 2px solid var(--gold-edge); color: var(--gold-text); box-shadow: var(--shadow);
}
.day-kicker { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; }
.day-name { font-family: var(--display); font-weight: 700; font-size: 22px; color: var(--strong); }
.day-where { font-size: 12px; }
.conn-prompt { margin: 0; text-align: center; font-family: var(--display); font-weight: 600; font-size: 17px; color: var(--text); text-wrap: balance; }
.spark { margin-right: 2px; }
.other-game {
  display: grid; gap: 2px; width: 100%; padding: 12px 14px; border-radius: 10px; text-decoration: none; text-align: center;
  background: var(--cell); border: 2px solid var(--btn); color: var(--btn);
}
.other-game strong { font-family: var(--display); font-size: 18px; }
.other-game small { color: var(--muted); font-size: 13px; }
a.menu-item { text-decoration: none; }
