/* Scandinavian restraint: flat colour, hairlines, generous space, no ornament.
   Light-first, because the whole point of the idiom is daylight. */
:root {
  color-scheme: light;
  --paper: #f4f2ed;
  --ink: #23211d;
  --muted: #8d8880;
  --rule: #ddd8ce;
  --well: #eae7e0;
  --accent: #c4705a;      /* used sparingly, once */
  --pad: clamp(1rem, 5vw, 1.75rem);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.5 "Inter", "Helvetica Neue", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

body {
  display: flex;
  flex-direction: column;
  padding:
    max(var(--pad), env(safe-area-inset-top))
    max(var(--pad), env(safe-area-inset-left))
    max(0.9rem, env(safe-area-inset-bottom))
    max(var(--pad), env(safe-area-inset-right));
  -webkit-user-select: none;
  user-select: none;
}

/* ---- masthead ---------------------------------------------------------- */

header {
  flex: none;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding-bottom: 0.7rem;
  border-bottom: 1px solid var(--rule);
}

.wordmark {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: lowercase;
}

.readout { display: flex; gap: 1.6rem; }

.field { text-align: right; }

.field dt {
  font-size: 0.6rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

.field dd {
  margin: 0.15rem 0 0;
  font-size: 1.05rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

/* ---- the well ---------------------------------------------------------- */

#stage {
  flex: 1;
  min-height: 0;
  position: relative;
}

#board {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

footer {
  flex: none;
  padding-top: 0.7rem;
  min-height: 1.9rem;
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: center;
}

/* ---- panels ------------------------------------------------------------ */

#panel {
  position: fixed;
  inset: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: max(2rem, env(safe-area-inset-top)) var(--pad) max(2rem, env(safe-area-inset-bottom));
  background: var(--paper);
}

#panel[hidden] { display: none; }

.sheet { width: min(24rem, 100%); margin: 0 auto; }

h1 {
  margin: 0 0 0.4rem;
  font-size: clamp(2.2rem, 11vw, 3.2rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1;
}

.lede {
  margin: 0 0 2.2rem;
  color: var(--muted);
  font-size: 0.95rem;
  max-width: 20rem;
}

.lede b { color: var(--ink); font-weight: 500; }

.rule { height: 1px; background: var(--rule); margin: 1.6rem 0; }

/* ---- scores ------------------------------------------------------------ */

.scores { margin: 0 0 2rem; }

.scores h2 {
  margin: 0 0 0.7rem;
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

.scores ol { margin: 0; padding: 0; list-style: none; }

.scores li {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  padding: 0.42rem 0;
  border-top: 1px solid var(--rule);
  font-size: 0.9rem;
}

.scores li:last-child { border-bottom: 1px solid var(--rule); }
.scores .who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scores .num { font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }
.scores .mine { color: var(--accent); }
.scores .empty { color: var(--muted); font-size: 0.85rem; padding: 0.42rem 0; }

/* ---- controls ---------------------------------------------------------- */

button {
  display: block;
  width: 100%;
  min-height: 3rem;
  margin: 0;
  padding: 0.85rem 1rem;
  border: 1px solid var(--ink);
  border-radius: 0;
  background: var(--ink);
  color: var(--paper);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  cursor: pointer;
}

button:active { opacity: 0.85; }

button.quiet {
  margin-top: 0.6rem;
  background: none;
  color: var(--ink);
  border-color: var(--rule);
}

input {
  width: 100%;
  margin-bottom: 0.6rem;
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--rule);
  border-radius: 0;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 0.95rem;
}

input::placeholder { color: var(--muted); }
input:focus { outline: none; border-color: var(--ink); }

#note {
  margin: 0.8rem 0 0;
  min-height: 1.1rem;
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  color: var(--muted);
}

#note[data-tone="bad"] { color: var(--accent); }

/* The scaffold's install affordance, kept but made quiet. */
#lab-install-open {
  width: auto;
  min-height: 0;
  margin: 1.4rem auto 0;
  padding: 0.5rem 0.9rem;
  background: none;
  color: var(--muted);
  border-color: var(--rule);
  font-size: 0.62rem;
}

#lab-install-open[hidden] { display: none; }

dialog {
  max-width: min(22rem, 88vw);
  padding: 1.5rem;
  border: 1px solid var(--ink);
  border-radius: 0;
  background: var(--paper);
  color: var(--ink);
}

dialog::backdrop { background: rgba(35, 33, 29, 0.3); }
dialog h2 { margin: 0 0 0.6rem; font-size: 1rem; font-weight: 600; letter-spacing: 0.01em; }
dialog p { margin: 0 0 1.2rem; font-size: 0.85rem; color: var(--muted); }
#lab-offline-status:empty { display: none; }
