:root {
  --ink: #020812;
  --paper: #eef5f2;
  --dim: rgba(238, 245, 242, 0.64);
  --faint: rgba(238, 245, 242, 0.34);
  --line: rgba(238, 245, 242, 0.16);
  --signal: #ff5a1f;
  --mint: #6fffd2;
  --zone: #a8ece4;
  --f-display: 'Fraunces Variable', 'Iowan Old Style', 'Palatino Linotype', Georgia, serif;
  --f-ui: 'Instrument Sans Variable', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --f-mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Consolas, monospace;
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --out: cubic-bezier(0.16, 1, 0.3, 1);
  --bar: 68px;
  --H: 100vh;
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  background: var(--ink);
  color: var(--paper);
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  font-family: var(--f-ui);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  text-rendering: optimizeLegibility;
}

::selection {
  background: var(--signal);
  color: #1c0b03;
}

button,
input {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  touch-action: manipulation;
}

:focus-visible {
  outline: 2px solid var(--mint);
  outline-offset: 3px;
  border-radius: 3px;
}

/* the picture behind the page: the vault and, above it, its light and sparks */
#kgl,
#kfx {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
#kgl {
  z-index: 0;
}
#kfx {
  z-index: 1;
  pointer-events: none;
}

#app {
  position: fixed;
  inset: 0;
  z-index: 2;
  display: grid;
  grid-template-rows: var(--bar) 1fr;
}

/* ---------- shared type ---------- */

.mono {
  font-family: var(--f-mono);
  font-variant-numeric: tabular-nums;
}
.sep {
  display: inline-block;
  margin: 0 -0.19em;
}
.dim {
  color: var(--dim);
}
.small {
  font-size: 13px;
}
.eyebrow {
  font-family: var(--f-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--dim);
  margin: 0;
}
.dot {
  display: inline-block;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: currentColor;
  margin: 0 0.9em;
  vertical-align: middle;
  opacity: 0.7;
}
.ico {
  display: inline-grid;
  place-items: center;
  flex: none;
}
.ico svg {
  display: block;
}

[data-in] {
  animation: rise 0.9s var(--out) both;
  animation-delay: calc(var(--i, 0) * 85ms + 140ms);
}
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
}
@keyframes fade {
  from {
    opacity: 0;
  }
}

.gem-ico {
  display: inline-grid;
  place-items: center;
  flex: none;
  vertical-align: -0.18em;
}
.gem-ico svg {
  display: block;
  filter: drop-shadow(0 0 5px color-mix(in srgb, var(--c, transparent) 55%, transparent));
}
.gem-ico.socket {
  color: var(--faint);
}
.gem-ico.socket svg {
  filter: none;
}

/* ---------- top bar ---------- */

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(14px, 3vw, 34px);
  padding-top: env(safe-area-inset-top);
  position: relative;
  z-index: 3;
}
/* a soft shade keeps the bar readable against the picture behind it */
.bar::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 150px;
  background: linear-gradient(180deg, rgba(1, 22, 32, 0.5), rgba(1, 22, 32, 0));
  pointer-events: none;
  z-index: -1;
}

/* the name of the game leads back to the start screen */
.game-tab {
  display: flex;
  align-items: center;
  gap: 11px;
  background: none;
  border: 0;
  padding: 8px 12px 8px 6px;
  color: var(--paper);
}
.game-name {
  font-family: var(--f-mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.34em;
  text-transform: uppercase;
}
/* its mark: a cut stone */
.game-mark {
  position: relative;
  width: 12px;
  height: 24px;
  flex: none;
}
.game-mark::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 10px;
  height: 10px;
  margin: -5px 0 0 -5px;
  transform: rotate(45deg);
  background: linear-gradient(135deg, #fff1bd 0 50%, #f2c14e 50% 100%);
  box-shadow: 0 0 12px 1px rgba(242, 193, 78, 0.6);
  transition: transform 0.6s var(--spring);
}
.game-tab:hover .game-mark::after {
  transform: rotate(225deg) scale(1.2);
}
.bar-actions {
  display: flex;
  gap: 8px;
}
.iconbtn {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(2, 18, 28, 0.28);
  color: var(--paper);
  transition:
    background 0.2s,
    border-color 0.2s,
    transform 0.3s var(--spring);
}
.iconbtn:hover {
  background: rgba(238, 245, 242, 0.1);
  border-color: rgba(238, 245, 242, 0.45);
  transform: translateY(-1px);
}
.iconbtn:active {
  transform: scale(0.92);
}
.iconbtn[aria-pressed='true'] {
  border-color: rgba(238, 245, 242, 0.55);
}
.iconbtn[aria-pressed='false'] {
  color: var(--faint);
}
.iconbtn.small {
  width: 34px;
  height: 34px;
}
/* the language button shows the code of the language it switches to */
.lang-code {
  font-family: var(--f-mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.06em;
  line-height: 1;
}

/* ---------- buttons ---------- */

.cta {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  border: 0;
  border-radius: 999px;
  padding: 14px 22px 14px 26px;
  background: var(--signal);
  color: #1c0b03;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.01em;
  box-shadow:
    0 14px 40px -12px rgba(255, 90, 31, 0.85),
    inset 0 1px 0 rgba(255, 255, 255, 0.4),
    inset 0 -2px 0 rgba(120, 30, 0, 0.25);
  transition:
    transform 0.35s var(--spring),
    box-shadow 0.25s,
    filter 0.2s;
  position: relative;
  white-space: nowrap;
}
.cta:hover {
  transform: translateY(-2px);
  filter: brightness(1.06);
  box-shadow:
    0 20px 50px -12px rgba(255, 90, 31, 0.95),
    inset 0 1px 0 rgba(255, 255, 255, 0.4),
    inset 0 -2px 0 rgba(120, 30, 0, 0.25);
}
.cta:active {
  transform: translateY(1px) scale(0.97);
  transition-duration: 0.08s;
}
.cta:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.9);
  outline-offset: 4px;
  border-radius: 999px;
}

.cta.danger {
  background: #ff3d3d;
  box-shadow: none;
  padding: 12px 22px;
}

.ghost {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 12px 18px;
  background: rgba(2, 18, 28, 0.3);
  font-size: 14px;
  font-weight: 500;
  transition:
    border-color 0.2s,
    background 0.2s,
    transform 0.3s var(--spring);
}
.ghost:hover {
  border-color: rgba(238, 245, 242, 0.55);
  background: rgba(238, 245, 242, 0.08);
  transform: translateY(-2px);
}
.ghost:active {
  transform: scale(0.97);
}

.textbtn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: 0;
  padding: 10px 2px;
  font-family: var(--f-mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  position: relative;
  white-space: nowrap;
}
.textbtn::after {
  content: '';
  position: absolute;
  left: 2px;
  right: 2px;
  bottom: 6px;
  height: 1px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.45s var(--out);
}
.textbtn:hover::after {
  transform: scaleX(1);
}
.textbtn.dim {
  color: var(--dim);
}
.textbtn.danger {
  color: #ff8a8a;
}
.row {
  display: flex;
  gap: 22px;
  align-items: center;
  justify-content: center;
}

/* ---------- view ---------- */

#view {
  position: relative;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(238, 245, 242, 0.25) transparent;
  transition:
    opacity 0.24s,
    transform 0.24s;
}
#view.leaving {
  opacity: 0;
  transform: translateY(-12px);
}
/* leaving the start screen: the name goes letter by letter */
#view[data-screen='home'].leaving {
  transition-duration: 0.3s;
  transition-delay: 0.22s;
  transform: none;
}

/* ---------- home ---------- */

.meta {
  margin: 16px 0 0;
  font-size: 13px;
  color: var(--dim);
  text-shadow: 0 1px 12px rgba(1, 26, 38, 0.6);
}

.home-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 30px;
  margin-top: 22px;
}
.home-ladder {
  position: absolute;
  left: clamp(14px, 3vw, 34px);
  bottom: 26px;
  text-align: left;
  animation: fade 1.2s 0.9s both;
}

.challenge-banner {
  margin-bottom: 18px;
  padding: 14px 22px;
  border: 1px solid rgba(255, 90, 31, 0.6);
  border-radius: 6px;
  background: rgba(40, 12, 2, 0.55);
  max-width: 520px;
}
.challenge-banner p {
  margin: 6px 0 2px;
}

/* ---------- a round ---------- */

@keyframes beat {
  to {
    transform: scale(1.35);
  }
}

@keyframes shake {
  15% {
    transform: translateX(-12px);
  }
  35% {
    transform: translateX(10px);
  }
  55% {
    transform: translateX(-7px);
  }
  75% {
    transform: translateX(4px);
  }
}

.first-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--f-mono);
  font-style: normal;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #06231b;
  background: var(--mint);
  border-radius: 999px;
  padding: 3px 10px 3px 7px;
  margin-right: 6px;
  box-shadow: 0 0 24px rgba(111, 255, 210, 0.6);
  vertical-align: 1px;
}
.first-badge.record {
  background: #ffb08c;
  color: #2a0f03;
  box-shadow: 0 0 24px rgba(255, 140, 90, 0.55);
  margin: 0 0 0 4px;
}
.home-streak {
  margin: 14px 0 0;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--dim);
  text-shadow: 0 1px 12px rgba(1, 26, 38, 0.6);
}

.answers-name em,
.arch-date em {
  font-family: var(--f-mono);
  font-style: normal;
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--signal);
  margin-left: 9px;
}

.deepest {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
  margin: 12px 6px 0;
  font-size: 14px;
}

/* ---------- log ---------- */

.log,
.page {
  max-width: 780px;
  margin: 0 auto;
  padding: 6px 22px calc(70px + env(safe-area-inset-bottom));
}
.log-head {
  padding: 10px 0 18px;
}

.log-rank {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 18px;
  font-size: 14px;
}
.rank-name {
  font-family: var(--f-display);
  font-style: italic;
  font-weight: 340;
  font-size: clamp(26px, 4vw, 40px);
  letter-spacing: -0.02em;
  color: #ffb08c;
}
.card {
  border-top: 1px solid var(--line);
  padding: 16px 0 20px;
}
.card-title {
  margin-bottom: 10px;
}
.profile,
.field {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}
.profile-rule {
  stroke: rgba(238, 245, 242, 0.14);
  stroke-width: 1;
}

.field-line {
  fill: none;
  stroke: var(--paper);
  stroke-width: 1.6;
  stroke-linejoin: round;
  stroke-linecap: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
}
.fresh .field-line {
  animation: draw 2.4s var(--out) 0.5s both;
}
@keyframes draw {
  from {
    stroke-dashoffset: 1;
  }
}

.profile-n {
  font-family: var(--f-mono);
  font-size: 10px;
  fill: rgba(238, 245, 242, 0.6);
}

.field-area {
  fill: rgba(238, 245, 242, 0.07);
}
.field-avg {
  stroke: rgba(238, 245, 242, 0.45);
  stroke-dasharray: 2 5;
}
.field-me line {
  stroke: var(--signal);
  stroke-width: 1.6;
}
.field-me circle {
  fill: var(--signal);
}
.field-me text {
  font-family: var(--f-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.14em;
  fill: var(--signal);
}
.pct {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 20px;
  margin-bottom: 6px;
}
.pct p {
  margin: 0;
}
.pct-main b {
  font-size: 30px;
  font-weight: 400;
  letter-spacing: -0.04em;
  margin-right: 8px;
}
.pct-main b small {
  font-size: 0.6em;
  margin-left: 3px;
  color: var(--dim);
}
.log-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 6px 0 22px;
}
.log-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--line);
}
.log-row {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto 34px;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.log-row-n {
  font-size: 12px;
  color: var(--dim);
}
.log-row-main {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.log-row-main .eyebrow {
  font-size: 10px;
  letter-spacing: 0.12em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.log-row-answer {
  font-family: var(--f-display);
  font-size: 21px;
  line-height: 1.15;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
}
.log-row.afk .log-row-answer {
  color: var(--dim);
  font-style: italic;
}
.log-row-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
}
.log-row-depth {
  font-size: 16px;
  color: var(--c);
}
.log-row-zone {
  font-size: 12px;
  color: var(--dim);
}
.log-next {
  margin: 26px 0 4px;
  text-align: center;
  color: var(--dim);
  font-size: 14px;
}
.log-next b {
  color: var(--paper);
  font-weight: 400;
}
.log-home {
  display: flex;
  margin: 10px auto 0;
}
.duel {
  border-top: 1px solid var(--line);
  padding: 16px 0 20px;
}
.duel-verdict {
  font-family: var(--f-display);
  font-style: italic;
  font-size: 26px;
  margin: 6px 0 12px;
}
.duel-rows {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.duel-rows li,
.duel-legend {
  display: grid;
  grid-template-columns: 26px 1fr 1fr;
  gap: 10px;
  align-items: start;
  font-size: 12px;
}
.duel-legend {
  margin-bottom: 8px;
}
.duel-legend .me {
  color: var(--paper);
}
.duel-legend .rival {
  color: var(--signal);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.duel-bar {
  display: grid;
  gap: 3px;
}
.duel-bar i {
  display: block;
  height: 4px;
  width: calc(var(--w) * 100%);
  min-width: 2px;
  background: var(--signal);
  border-radius: 2px;
}
.duel-bar.me i {
  background: var(--paper);
}
.duel-bar small {
  color: var(--dim);
}

/* ---------- archive and profile ---------- */

.page-head {
  padding: 4px 0 18px;
}
.page-title {
  font-family: var(--f-display);
  font-style: italic;
  font-weight: 300;
  font-variation-settings:
    'opsz' 144,
    'SOFT' 100,
    'WONK' 1;
  font-size: clamp(46px, 8vw, 88px);
  line-height: 1;
  letter-spacing: -0.04em;
  margin: 8px 0 8px;
}

.arch-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.arch-row {
  width: 100%;
  display: grid;
  grid-template-columns: 48px minmax(84px, 1fr) auto minmax(110px, auto) 18px;
  align-items: center;
  gap: 14px;
  padding: 13px 4px;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--line);
  text-align: left;
  transition:
    background 0.2s,
    padding 0.35s var(--out);
}
.arch-row:hover {
  background: rgba(238, 245, 242, 0.06);
  padding-left: 12px;
}
.arch-n {
  font-size: 13px;
  color: var(--dim);
}
.arch-score {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.2;
}
.arch-score small {
  color: var(--dim);
  font-size: 12px;
}
.arch-score.open {
  font-family: var(--f-mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--signal);
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px 16px;
  padding: 4px 0 22px;
}
.stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stat-num {
  font-size: clamp(28px, 4.6vw, 44px);
  font-weight: 300;
  letter-spacing: -0.05em;
  line-height: 1;
}
.stat-num small {
  font-size: 13px;
  letter-spacing: 0;
  color: var(--dim);
  margin-left: 6px;
}

.toggle,
.field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.toggle span,
.field span {
  display: flex;
  flex-direction: column;
}
.toggle small,
.field small {
  color: var(--dim);
  font-size: 13px;
}
.toggle input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}
.toggle i {
  flex: none;
  width: 46px;
  height: 26px;
  border-radius: 999px;
  background: rgba(238, 245, 242, 0.16);
  position: relative;
  transition: background 0.25s;
}
.toggle i::after {
  content: '';
  position: absolute;
  left: 3px;
  top: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--paper);
  transition: transform 0.35s var(--spring);
}
.toggle input:checked + i {
  background: var(--signal);
}
.toggle input:checked + i::after {
  transform: translateX(20px);
}
.toggle input:focus-visible + i {
  outline: 2px solid var(--mint);
  outline-offset: 3px;
}
.field-input {
  background: rgba(2, 14, 22, 0.5);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 9px 12px;
  width: 190px;
  max-width: 50vw;
  outline: none;
  transition: border-color 0.2s;
}
.field-input:focus {
  border-color: var(--paper);
}
.profile .textbtn.danger {
  margin-top: 12px;
}
/* a choice between two: used for the language */
div.field {
  cursor: default;
}
.field .seg {
  flex: none;
  flex-direction: row;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}
.seg-btn {
  padding: 7px 14px;
  border: 0;
  background: none;
  border-radius: 999px;
  font-size: 14px;
  color: var(--dim);
  transition:
    background 0.2s,
    color 0.2s;
}
.seg-btn:hover {
  color: var(--paper);
}
.seg-btn.on {
  background: var(--paper);
  color: var(--ink);
}

/* ---------- overlays ---------- */

#overlays {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
}
.scrim {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(1, 9, 15, 0.74);
  pointer-events: auto;
  animation: fade 0.22s both;
}
.scrim.closing {
  opacity: 0;
  transition: opacity 0.2s;
}
.sheet {
  position: relative;
  width: min(580px, 100%);
  max-height: min(86dvh, 840px);
  display: flex;
  flex-direction: column;
  background: #071926;
  border: 1px solid rgba(238, 245, 242, 0.18);
  border-radius: 4px;
  box-shadow: 0 50px 140px -30px rgba(0, 0, 0, 0.9);
  animation: sheet 0.5s var(--out) both;
  outline: none;
}
.sheet::before,
.sheet::after {
  content: '';
  position: absolute;
  width: 12px;
  height: 12px;
  border: 1.5px solid var(--signal);
  pointer-events: none;
}
.sheet::before {
  left: -5px;
  top: -5px;
  border-right: 0;
  border-bottom: 0;
}
.sheet::after {
  right: -5px;
  bottom: -5px;
  border-left: 0;
  border-top: 0;
}
@keyframes sheet {
  from {
    opacity: 0;
    transform: translateY(26px) scale(0.98);
  }
}
.sheet.wide {
  width: min(900px, 100%);
}
.sheet-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 22px 24px 16px;
  border-bottom: 1px solid var(--line);
}
.sheet-title {
  font-family: var(--f-display);
  font-style: italic;
  font-weight: 340;
  font-size: clamp(24px, 3.4vw, 34px);
  line-height: 1.08;
  letter-spacing: -0.02em;
  margin: 6px 0 0;
}
.sheet-body {
  padding: 18px 24px 24px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(238, 245, 242, 0.25) transparent;
}
.rules {
  list-style: none;
  margin: 0;
  padding: 0;
}
.rules li {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 8px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}
.rules p {
  margin: 0;
  color: var(--dim);
}
.rules b {
  color: var(--paper);
  font-weight: 600;
}
.rule-n {
  font-size: 12px;
  color: var(--signal);
  padding-top: 3px;
}
.note {
  margin: 0;
  padding: 12px 14px;
  border-left: 2px solid var(--signal);
  background: rgba(255, 90, 31, 0.07);
  font-size: 14px;
  color: var(--dim);
}
.note b {
  color: var(--paper);
}
/* the way to the other language, at the end of the rules */
.help-lang {
  margin: 0;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 14px;
  font-size: 14px;
  color: var(--dim);
}
.sheet.answers {
  height: min(86dvh, 840px);
}
.sheet.answers .sheet-body {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
  overflow: hidden;
  padding-bottom: 0;
}
.answers-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
}
.search {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  color: var(--dim);
}
.search .field-input {
  width: 100%;
  max-width: 260px;
}
.answers-list {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  padding: 0 4px 22px 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(238, 245, 242, 0.25) transparent;
}
.answers-me {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 14px;
  padding: 10px 14px;
  margin-bottom: 14px;
  border-left: 3px solid var(--c);
  background: rgba(238, 245, 242, 0.06);
}
.answers-me b {
  font-family: var(--f-display);
  font-size: 20px;
  font-weight: 400;
}
.answers-me .mono {
  color: var(--c);
  font-size: 13px;
}
.answers-zone {
  border-left: 2px solid var(--c);
  padding-left: 14px;
  margin-bottom: 18px;
}
.answers-zone h3 {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 0 0 4px;
  font-family: var(--f-display);
  font-style: italic;
  font-weight: 400;
  font-size: 22px;
  color: var(--c);
  position: sticky;
  top: 0;
  background: #071926;
  padding: 4px 0;
}
.answers-zone h3 .mono {
  font-style: normal;
  font-size: 11px;
}
.answers-zone ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.answers-zone li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 70px 84px;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid rgba(238, 245, 242, 0.08);
  font-size: 15px;
}
.answers-zone li span:nth-child(n + 2) {
  text-align: right;
  font-size: 12px;
  align-self: center;
}
.answers-zone li.me {
  background: rgba(255, 90, 31, 0.14);
}
.answers-empty {
  padding: 30px 0;
  text-align: center;
}
.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(26px + env(safe-area-inset-bottom));
  z-index: 20;
  transform: translate(-50%, 30px);
  opacity: 0;
  padding: 11px 18px;
  border-radius: 999px;
  background: var(--paper);
  color: #06202c;
  font-size: 14px;
  font-weight: 500;
  pointer-events: none;
  max-width: calc(100vw - 32px);
  text-align: center;
  transition:
    opacity 0.3s,
    transform 0.5s var(--spring);
}
#toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- small screens ---------- */

@media (max-width: 900px), (max-height: 720px) {
  .home-ladder {
    display: none;
  }
}

@media (max-width: 700px) {
  :root {
    --bar: 58px;
  }
  .game-name {
    letter-spacing: 0.24em;
  }
  .game-tab {
    gap: 9px;
    padding-right: 9px;
  }
  .bar-actions {
    gap: 6px;
  }
  .iconbtn {
    width: 38px;
    height: 38px;
  }
  .bar .iconbtn {
    width: 36px;
    height: 36px;
  }
  /* on the narrowest phones five buttons do not fit next to the name:
     calm mode can also be reached from the profile */
  @media (max-width: 345px) {
    .bar [data-act='calm'] {
      display: none;
    }
  }

  .home-nav {
    gap: 4px 18px;
  }
  .home-nav .textbtn {
    letter-spacing: 0.1em;
  }

  .deepest {
    margin-top: 8px;
  }

  .stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .scrim {
    padding: 0;
    place-items: end stretch;
  }
  .sheet,
  .sheet.wide {
    width: 100%;
    max-height: 90dvh;
    border-radius: 14px 14px 0 0;
    border-bottom: 0;
  }
  .sheet::before,
  .sheet::after {
    display: none;
  }
  .sheet.answers {
    height: 90dvh;
  }
  .sheet-head {
    padding: 18px 18px 14px;
  }
  .sheet-body {
    padding: 14px 18px calc(22px + env(safe-area-inset-bottom));
  }
  .arch-row {
    grid-template-columns: 40px minmax(64px, 1fr) auto minmax(86px, auto) 16px;
    gap: 10px;
  }
  .log-row {
    grid-template-columns: 24px minmax(0, 1fr) auto 34px;
    gap: 8px;
  }
  .log-row-answer {
    font-size: 18px;
  }
}

/* ---------- calm mode and reduced motion ---------- */

html.calm *,
html.calm *::before,
html.calm *::after {
  animation-duration: 0.01ms !important;
  animation-delay: 0s !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
}

/* ---------- account card ---------- */
.account {
  display: grid;
  gap: 12px;
}
.account.busy {
  opacity: 0.6;
  pointer-events: none;
}
.account-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.account-form {
  display: grid;
  gap: 10px;
}
.account-form .field-input {
  width: 100%;
  max-width: 420px;
}
.account-or {
  margin: 4px 0 0;
}
.account-status {
  min-height: 1.4em;
  margin: 0;
  color: var(--signal);
}
.account-status.good {
  color: var(--mint);
}
.linkbtn {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

/* ---------- legal pages ---------- */
.legal-links {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 26px 0 0;
  font-family: var(--f-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
}
.legal-links a {
  color: var(--dim);
  text-decoration: none;
  padding: 6px 2px;
}
.legal-links a:hover,
.legal-links a:focus-visible {
  color: var(--paper);
  text-decoration: underline;
  text-underline-offset: 4px;
}
.legal-text {
  line-height: 1.6;
  overflow-wrap: anywhere;
}
.legal-text h2 {
  font-family: var(--f-ui);
  font-size: 17px;
  font-weight: 600;
  margin: 26px 0 8px;
}
.legal-text h2:first-child {
  margin-top: 0;
}
.legal-text p,
.legal-address {
  margin: 0 0 10px;
  color: var(--dim);
  font-style: normal;
  max-width: 68ch;
}
.legal-text a {
  color: var(--paper);
}
.legal-gap {
  background: var(--signal);
  color: #14060a;
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 600;
}

/* ---------- sign in / account in the bar ---------- */
/* a labelled pill where there is room, a round button like the others on phones */
.acct-label {
  display: none;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}
@media (min-width: 721px) {
  .bar [data-act='account'] {
    width: auto;
    padding: 0 15px 0 11px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
  }
  .acct-label {
    display: inline;
  }
}
/* six buttons do not fit next to the name on phones: calm mode is also in the treasury */
@media (max-width: 430px) {
  .bar [data-act='calm'] {
    display: none;
  }
}

/* ---------- leaderboard ---------- */
.board-tabs {
  margin: 0 0 14px;
}
.board-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.board-list li {
  display: grid;
  grid-template-columns: 38px 1fr auto auto;
  gap: 12px;
  align-items: baseline;
  padding: 11px 4px;
  border-bottom: 1px solid var(--line);
}
.board-list li:last-child {
  border-bottom: 0;
}
.board-list li.me {
  background: rgba(238, 245, 242, 0.07);
  border-radius: 8px;
}
.board-rank {
  color: var(--faint);
  text-align: right;
}
.board-list li:nth-child(-n + 3) .board-rank {
  color: var(--paper);
  font-weight: 600;
}
.board-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.board-name em {
  font-style: normal;
  font-family: var(--f-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--mint);
  margin-left: 8px;
}
.board-total {
  white-space: nowrap;
}
.board-hint {
  margin: 16px 2px 0;
}

/* ---------- lobby ---------- */
.lobby-body {
  display: grid;
  gap: 14px;
}
.lobby-room {
  display: grid;
  gap: 14px;
}
.lobby-code {
  margin: 0;
  font-size: clamp(44px, 12vw, 84px);
  font-weight: 500;
  letter-spacing: 0.22em;
  line-height: 1;
  user-select: all;
}
.lobby-code-input {
  width: 9.5em;
  font-family: var(--f-mono);
  letter-spacing: 0.3em;
  text-transform: uppercase;
}
.lobby-seats {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.lobby-seats li {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.lobby-seats li.empty {
  border-style: dashed;
}
.lobby-seats em {
  font-style: normal;
  font-family: var(--f-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--mint);
}
.lobby-count {
  margin: 0;
  font-size: clamp(90px, 26vw, 180px);
  line-height: 1;
}
.lobby-head {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
}
.lobby-table {
  display: grid;
}
.lobby-row {
  display: grid;
  grid-template-columns: minmax(84px, 0.8fr) 1fr 1fr;
  gap: 10px;
  align-items: baseline;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  overflow-wrap: anywhere;
}
.lobby-row-head {
  font-family: var(--f-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dim);
}
.lobby-row-sum {
  border-bottom: 0;
  font-size: 17px;
}
.ghost:disabled {
  opacity: 0.4;
  pointer-events: none;
}
/* how far the other player is, shown during a lobby round */
.duel-chip {
  position: fixed;
  left: 50%;
  bottom: calc(14px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 40;
  display: flex;
  gap: 10px;
  align-items: baseline;
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(10, 8, 6, 0.86);
  font-size: 13px;
  white-space: nowrap;
  pointer-events: none;
}
