:root {
  color-scheme: dark;
  --background: #16171b;
  --surface: #262830;
  --gold: #e4ca75;
  --line: #8e7d50;
  --text: #fffdf6;
  --muted: #c8c7cc;
  --match: #526334;
  --related: #8c611d;
  --different: #761d15;
  --unknown: #4b4656;
  --tile-gap: clamp(4px, 1.2vw, 12px);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  min-height: 100vh;
  min-height: 100svh;
  margin: 0;
  display: flex;
  flex-direction: column;
  background: var(--background) url("./star-chart.svg") center / cover fixed;
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, sans-serif;
}
a { color: var(--gold); text-underline-offset: .2em; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

.site-header {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  align-items: center;
  gap: 8px;
  padding: 6px clamp(10px, 2.8vw, 36px) 1px;
}
h1 {
  margin: 0;
  text-align: center;
  color: var(--gold);
  font-size: clamp(1.55rem, 5.2vw, 3.2rem);
  line-height: 1.15;
  letter-spacing: -.04em;
  text-shadow: 0 2px 9px #000;
}
.icon-button {
  width: 43px;
  height: 43px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid var(--gold);
  background: #202126;
  color: var(--text);
  font-weight: 800;
  font-size: 1.6rem;
  line-height: 1;
}
.icon-button:hover { color: var(--gold); background: var(--surface); }

.frame { width: min(100% - 16px, 732px); margin-inline: auto; flex: 1 0 auto; }
.modes {
  width: min(100%, 460px);
  margin: 10px auto 16px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}
.modes button, .round-actions button, .dialog-actions button {
  border: 1px solid #62583e;
  border-radius: 4px;
  background: #24252bdc;
  color: var(--muted);
}
.modes button { padding: 5px 2px; font-size: .8rem; font-weight: 650; white-space: nowrap; }
.modes button:hover, .modes button[aria-pressed=true] {
  color: var(--gold);
  border-color: var(--gold);
  background: #3a3220;
}

#guess-form, .archive-options { width: min(100% - 16px, 480px); margin-inline: auto; }
.form-row { display: flex; gap: 6px; align-items: stretch; }
.autocomplete { position: relative; flex: 1; min-width: 0; }
.autocomplete label {
  position: absolute;
  left: 9px;
  top: -9px;
  z-index: 1;
  padding: 0 4px;
  border-radius: 3px;
  background: var(--surface);
  color: var(--text);
  font-size: .71rem;
}
input, select {
  padding: 9px 11px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
}
input::placeholder { color: var(--muted); }
#guess { width: 100%; height: 54px; padding-right: 36px; }
#browse {
  position: absolute;
  top: 1px;
  right: 1px;
  bottom: 1px;
  width: 34px;
  border: 0;
  border-radius: 4px;
  background: transparent;
}
#browse:hover { color: var(--gold); }
.primary, .dialog-actions .primary {
  padding: 7px 12px;
  color: #221a0d;
  background: var(--gold);
  border: 1px solid var(--gold);
  border-radius: 4px;
  font-weight: 650;
}
.primary:hover, .dialog-actions .primary:hover { background: #f5e1a1; }
#suggestions {
  position: absolute;
  inset: 100% 0 auto;
  z-index: 3;
  max-height: min(18rem, 48vh);
  margin: 4px 0 0;
  padding: 4px;
  overflow: auto;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
  box-shadow: 0 6px 20px #000a;
}
#suggestions li { padding: 7px 9px; overflow-wrap: anywhere; cursor: pointer; }
#suggestions li:hover, #suggestions li[aria-selected=true] { background: #4b3e24; }
#suggestions small { color: var(--gold); margin-left: 8px; }
.archive-options { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.archive-options label { font-size: .8rem; color: var(--muted); }
.archive-options :is(input, select) { display: block; margin-top: 4px; }
.round-meta { margin: 7px 0 3px; color: var(--gold); text-align: center; font-variant-numeric: tabular-nums; text-shadow: 0 2px 4px #000; }
.notice { margin: 5px 0; color: var(--gold); text-align: center; font-size: .83rem; }
.notice:empty { display: none; }

.table-scroll { overflow: auto; }
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: var(--tile-gap) var(--tile-gap);
  table-layout: fixed;
  text-align: center;
}
th {
  padding: 4px 0 0;
  font-size: clamp(.64rem, 1.95vw, 1.05rem);
  line-height: 1.12;
  text-shadow: 0 2px 4px #000, 0 0 9px #000;
  overflow-wrap: anywhere;
}
td {
  height: clamp(73px, 17vw, 132px);
  padding: 4px;
  border: 1px solid var(--line);
  background: #27282ded;
  font-size: clamp(.65rem, 1.75vw, .96rem);
  font-weight: 650;
  line-height: 1.18;
  overflow-wrap: anywhere;
  text-shadow: 0 1px 3px #000;
}
td.placeholder { color: #c6c3cb; font-weight: 400; }
td.exact, .legend .exact { background: var(--match); }
td.close, .legend .close { background: var(--related); }
td.miss, .legend .miss { background: var(--different); }
td.unknown, .legend .unknown { background: var(--unknown); }
.board-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  margin: 0 var(--tile-gap) 12px;
}
.legend { display: flex; flex-wrap: wrap; gap: 5px 11px; margin: 0; padding: 0; list-style: none; color: var(--text); font-size: .73rem; }
.legend li { display: flex; align-items: center; gap: 4px; text-shadow: 0 1px 4px #000; }
.legend span { width: 17px; height: 17px; border: 1px solid #b8a46a; border-radius: 2px; text-align: center; }
.round-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.round-actions button { padding: 5px 8px; font-size: .75rem; }
.round-actions button:hover, .dialog-actions button:hover { border-color: var(--gold); }
.result {
  margin: 10px var(--tile-gap) 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  text-align: center;
}
.result h3, .result p { margin: 0; }
.result p { font-size: .86rem; }
.result button { margin-top: 8px; }

.site-footer {
  display: flex;
  justify-content: space-evenly;
  flex-wrap: wrap;
  gap: 3px 12px;
  padding: 6px 10px;
  margin-top: 20px;
  background: #262830da;
  color: var(--muted);
  font-size: .71rem;
  text-align: center;
}
.site-footer p { margin: 0; }
dialog {
  position: relative;
  width: min(452px, 100% - 24px);
  max-width: none;
  padding: 24px 29px;
  border: 2px solid var(--gold);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
}
dialog::backdrop { background: #121215c9; }
dialog h2 { margin: 0 20px 12px; text-align: center; color: var(--gold); }
#spoiler-dialog { margin: min(10vh, 72px) auto auto; text-align: center; }
.dialog-close { position: absolute; right: 10px; top: 10px; }
.dialog-close button {
  width: 28px;
  height: 28px;
  padding: 0;
  line-height: 1;
  border: 2px solid currentColor;
  border-radius: 50%;
  background: transparent;
  font-size: 1.15rem;
  font-weight: 750;
}
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.dialog-actions button { padding: 6px 9px; }
@media (max-width: 460px) {
  .site-header { grid-template-columns: 34px minmax(0, 1fr) 34px; }
  .icon-button { width: 34px; height: 34px; font-size: 1.22rem; }
  .modes button { font-size: .71rem; }
  .modes button span { display: none; }
  .site-footer { justify-content: center; }
}
