:root {
  --ink: #140e0a;
  --ink-2: #221910;
  --soil: #3a3126;
  --paper: #ead7b4;
  --brass: #e4b15a;
  --brass-dim: #a8843e;
  --moss: #8eae78;
  --crater: #d4533a;
  --line: rgba(228, 177, 90, 0.35);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --hud-h: 200px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--serif);
  overflow: hidden;
  position: fixed;
  inset: 0;
  touch-action: none;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
}

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

#field {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  -webkit-touch-callout: none;
  cursor: crosshair;
}

body.flagging #field { cursor: cell; }

.veil {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at center, transparent 45%, rgba(10, 6, 3, 0.55) 100%),
    repeating-linear-gradient(0deg, rgba(255, 236, 200, 0.015) 0 1px, transparent 1px 4px);
  z-index: 1;
}

.label-short { display: none; }

/* Hint, tools, and the other-sites row sit in this bar. The score ticket stays fixed to the corner until the phone layout pulls it in. */
.hud-bottom {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  position: fixed;
  z-index: 2;
  left: 0;
  right: 0;
  bottom: 0;
  padding:
    0
    calc(16px + var(--safe-right))
    calc(8px + var(--safe-bot))
    calc(16px + var(--safe-left));
  pointer-events: none;
}

.hud-bottom .hint,
.hud-bottom .dock {
  position: relative;
  inset: auto;
  transform: none;
  width: auto;
  max-width: none;
  margin: 0;
}

.hud-bottom .hint {
  align-self: center;
  max-width: min(520px, 100%);
}

.other-sites {
  margin: 0;
  padding: 8px 10px;
  background: rgba(20, 14, 10, 0.94);
  border: 1px solid var(--line);
  color: #b5a48a;
  font-size: 12px;
  line-height: 1.7;
  text-align: center;
  pointer-events: auto;
  touch-action: manipulation;
}

.other-sites a {
  color: inherit;
  text-underline-offset: 2px;
}

.other-sites a:hover,
.other-sites a:focus-visible {
  color: var(--paper);
}

.top, .ticket, .notes, .chat, .dock, .hint, .toast, .over, #mini {
  position: fixed;
  z-index: 2;
}

.top {
  top: calc(14px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  pointer-events: none;
  z-index: 5;
}

.sit-out {
  margin: 8px 0 0;
  color: var(--crater);
  font-style: italic;
  font-size: 0.85rem;
  line-height: 1.35;
}

body.sitting #field { cursor: not-allowed; }

.tools button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.reset-view {
  pointer-events: auto;
  position: relative;
  z-index: 5;
  display: inline-block;
  margin-top: 6px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--brass);
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

h1 {
  margin: 0;
  font-weight: 500;
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  letter-spacing: -0.03em;
  line-height: 1;
}

h1 em {
  font-style: italic;
  color: var(--brass);
  font-weight: 550;
}

.live {
  margin: 6px 0 0;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--moss);
}

.stats-link {
  pointer-events: auto;
  margin-left: 8px;
  color: var(--brass);
  text-decoration: none;
}

.stats-link:hover { text-decoration: underline; }

.pip {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--moss);
  box-shadow: 0 0 0 0 rgba(142, 174, 120, 0.7);
  vertical-align: 1px;
}

.pip.live {
  animation: pulse 1.8s ease-out infinite;
}

.pip.down { background: var(--crater); animation: none; }

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(142, 174, 120, 0.55); }
  100% { box-shadow: 0 0 0 10px rgba(142, 174, 120, 0); }
}

.ticket {
  top: calc(18px + var(--safe-top));
  left: 16px;
  width: min(220px, calc(100vw - 32px));
  pointer-events: auto;
  padding: 14px 16px 12px;
  background:
    radial-gradient(circle at 8px 8px, transparent 5px, var(--ink-2) 6px) top left / 16px 16px repeat-y,
    linear-gradient(180deg, #2a2118, #1c1510);
  border: 1px solid var(--line);
  border-left: 3px solid var(--brass);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
}

.name {
  display: block;
  width: 100%;
  padding: 0;
  background: none;
  border: 0;
  text-align: left;
  font-style: italic;
  font-size: 1.05rem;
  color: var(--brass);
  cursor: pointer;
  pointer-events: auto;
}

.name:hover { color: var(--paper); }

.name-input {
  width: 100%;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--brass);
  padding: 0 0 2px;
  outline: none;
  font-style: italic;
  font-size: 1.05rem;
  color: var(--paper);
}

.score {
  margin: 6px 0 0;
  font-family: var(--mono);
  font-size: 2.4rem;
  line-height: 0.95;
  letter-spacing: -0.04em;
}

.score-label, .personal, .everyone {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #b5a48a;
}

.personal { margin-top: 6px; }

.everyone {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed rgba(228, 177, 90, 0.35);
  color: var(--paper);
}

.everyone strong {
  color: var(--brass);
  font-weight: 600;
}

.cool {
  margin-top: 8px;
  height: 16px;
  position: relative;
  background: #3a2018;
  overflow: hidden;
}

.cool span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--crater);
}

.cool em {
  position: absolute;
  inset: 0;
  font-style: normal;
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 16px;
  text-align: center;
}

.notes {
  top: calc(18px + var(--safe-top));
  right: 16px;
  width: min(260px, calc(100vw - 32px));
  max-height: calc(100dvh - var(--hud-h) - 32px - var(--safe-top));
  overflow: auto;
  padding: 14px 14px 12px;
  background: rgba(20, 14, 10, 0.88);
  border: 1px solid var(--line);
  backdrop-filter: blur(8px);
  transition: transform 0.25s ease, opacity 0.2s ease;
}

.notes.shut {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-8px);
}

.notes-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

h2 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--brass);
}

#close-notes {
  background: none;
  border: 0;
  color: var(--brass);
  cursor: pointer;
  min-height: 44px;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

#leaders {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
}

#leaders li {
  display: grid;
  grid-template-columns: 1.2rem 1fr auto;
  gap: 6px;
  align-items: baseline;
  padding: 4px 0;
  border-bottom: 1px solid rgba(234, 215, 180, 0.08);
  font-size: 0.92rem;
}

#leaders li.me { color: var(--brass); }

#leaders .rank {
  font-family: var(--mono);
  font-size: 0.68rem;
  color: #b5a48a;
}

#leaders .pts {
  font-family: var(--mono);
  font-size: 0.78rem;
}

#leaders .dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 6px;
  border-radius: 50%;
  vertical-align: 1px;
}

.who {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.who span {
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.04em;
  padding: 3px 6px;
  border: 1px solid currentColor;
  opacity: 0.9;
}

.ticker {
  margin: 10px 0 0;
  font-style: italic;
  color: #d9c7a4;
  min-height: 1.3em;
}

.legal {
  margin: 12px 0 0;
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.legal a { color: #b5a48a; }

.subhead {
  margin: 14px 0 0;
  font-size: 0.72rem;
}

.best {
  margin: 6px 0 0;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  color: #d9c7a4;
}

#shame,
#fame {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
}

#shame li,
#fame li {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px;
  padding: 3px 0;
  font-size: 0.82rem;
  border-bottom: 1px solid rgba(234, 215, 180, 0.08);
}

.fame-empty {
  margin: 6px 0 0;
  font-style: italic;
  color: #b5a48a;
  font-size: 0.82rem;
}

.survived {
  margin: 4px 0 0;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--brass);
}

.progress-track {
  margin: 6px auto 0;
  width: min(280px, 72vw);
  height: 6px;
  background: rgba(234, 215, 180, 0.14);
  border: 1px solid rgba(228, 177, 90, 0.4);
}

.progress-track span {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--moss), var(--brass));
}

.progress-label {
  margin: 3px 0 0;
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #d9c7a4;
}

.chat {
  left: 16px;
  bottom: calc(var(--hud-h) + 12px);
  width: min(320px, calc(100vw - 32px));
  max-height: min(320px, 42vh);
  display: flex;
  flex-direction: column;
  padding: 12px;
  background: rgba(20, 14, 10, 0.92);
  border: 1px solid var(--line);
  backdrop-filter: blur(8px);
}

.chat.shut {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

#chat-log {
  list-style: none;
  margin: 8px 0;
  padding: 0;
  overflow: auto;
  flex: 1;
  min-height: 120px;
}

#chat-log li {
  margin: 0 0 6px;
  font-size: 0.92rem;
  line-height: 1.35;
  word-break: break-word;
}

#chat-log .who-name {
  display: block;
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

#chat-log li.system {
  font-style: italic;
  color: #d9c7a4;
}

#chat-form {
  display: flex;
  gap: 6px;
}

#chat-input {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 0 10px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--line);
  font-family: var(--serif);
  font-size: 1rem;
}

#chat-form button {
  min-height: 44px;
  padding: 0 12px;
  background: var(--brass);
  color: var(--ink);
  border: 0;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.over {
  inset: auto;
  left: 50%;
  top: 46%;
  z-index: 6;
  width: min(36rem, calc(100vw - 28px));
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 22px 22px 18px;
  pointer-events: none;
  background:
    radial-gradient(ellipse at center, rgba(212, 83, 58, 0.32), transparent 72%),
    rgba(12, 6, 4, 0.9);
  border: 1px solid rgba(212, 83, 58, 0.72);
  box-shadow: 0 18px 70px rgba(0, 0, 0, 0.55), 0 0 48px rgba(212, 83, 58, 0.28);
}

.over[hidden] { display: none; }

.over-kicker {
  margin: 0;
  font-family: var(--mono);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--crater);
}

.over-name {
  margin: 8px 0 0;
  font-size: clamp(2.6rem, 8vw, 5.4rem);
  font-style: italic;
  line-height: 0.95;
  text-shadow: 0 8px 40px rgba(0, 0, 0, 0.45);
}

.over-line, .over-next {
  max-width: 36rem;
  margin: 14px 0 0;
  font-size: 1.15rem;
  color: var(--paper);
}

.over-next {
  font-family: var(--mono);
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--brass);
}

.over.win {
  background:
    radial-gradient(ellipse at center, rgba(142, 174, 120, 0.4), transparent 72%),
    rgba(12, 10, 6, 0.92);
  border-color: rgba(228, 177, 90, 0.85);
  box-shadow: 0 18px 70px rgba(0, 0, 0, 0.55), 0 0 56px rgba(142, 174, 120, 0.38);
}

.over.win .over-kicker { color: var(--moss); }

#over-tops {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  width: min(22rem, 100%);
}

#over-tops:empty { display: none; }

#over-tops li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 3px 0;
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  border-bottom: 1px solid rgba(234, 215, 180, 0.12);
}

#mini {
  right: 16px;
  bottom: calc(var(--hud-h) + 12px);
  z-index: 3;
  width: 104px;
  height: 104px;
  background: #0c0907;
  border: 1px solid var(--line);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  touch-action: none;
}

body.far .veil {
  background: repeating-linear-gradient(0deg, rgba(255, 236, 200, 0.012) 0 1px, transparent 1px 4px);
}

body.winflash .veil {
  background: radial-gradient(ellipse at center, rgba(228, 177, 90, 0.38), transparent 62%);
}

.dock {
  left: 16px;
  right: 16px;
  bottom: calc(14px + var(--safe-bot));
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  pointer-events: none;
}

.coords {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  color: var(--brass);
  pointer-events: none;
}

.tools {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  pointer-events: auto;
}

.tools button {
  min-height: 44px;
  min-width: 44px;
  padding: 0 12px;
  background: rgba(20, 14, 10, 0.88);
  border: 1px solid var(--line);
  cursor: pointer;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tools button[aria-pressed="true"] {
  background: var(--brass);
  color: var(--ink);
  border-color: var(--brass);
}

.tools button:hover { border-color: var(--brass); }

.hint {
  left: 50%;
  bottom: calc(72px + var(--safe-bot));
  transform: translateX(-50%);
  margin: 0;
  max-width: min(520px, calc(100vw - 32px));
  text-align: center;
  font-style: italic;
  color: #d9c7a4;
  pointer-events: none;
  transition: opacity 0.6s ease;
}

.hint.gone { display: none; }

.toast {
  left: 50%;
  top: 42%;
  transform: translate(-50%, -8px);
  margin: 0;
  padding: 8px 12px;
  background: var(--ink);
  border: 1px solid var(--crater);
  color: var(--paper);
  font-style: italic;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.toast.show { opacity: 1; }

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

body.boom .veil {
  background:
    radial-gradient(ellipse at center, rgba(212, 83, 58, 0.45), transparent 55%),
    radial-gradient(ellipse at center, transparent 45%, rgba(10, 6, 3, 0.55) 100%);
}

body.boom #field {
  animation: shake 0.55s linear;
}

@keyframes shake {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-7px, 2px); }
  40% { transform: translate(6px, -3px); }
  60% { transform: translate(-4px, 1px); }
  80% { transform: translate(3px, -1px); }
}

#over-share, .legal button {
  pointer-events: auto;
  margin-top: 14px;
  min-height: 40px;
  padding: 0 14px;
  background: transparent;
  border: 1px solid var(--brass);
  color: var(--brass);
  cursor: pointer;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.legal button {
  margin: 0;
  min-height: 32px;
  padding: 0 8px;
  border-color: var(--line);
}

.intro {
  position: fixed;
  z-index: 8;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(18px + var(--safe-top)) 16px calc(18px + var(--safe-bot));
  background: rgba(8, 5, 3, 0.78);
}

.intro[hidden] { display: none; }

.intro-card {
  width: min(460px, 100%);
  max-height: min(88vh, 640px);
  max-height: min(640px, calc(100dvh - 36px - var(--safe-top) - var(--safe-bot)));
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding: 22px 20px 18px;
  background: rgba(20, 14, 10, 0.96);
  border: 1px solid var(--line);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}

.intro-kicker {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--moss);
}

.intro-card h2 {
  margin: 8px 0 12px;
  font-size: clamp(1.7rem, 4vw, 2.3rem);
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1.05;
}

.intro-card ul {
  margin: 0;
  padding-left: 1.1rem;
}

.intro-card li {
  margin: 0 0 8px;
  line-height: 1.35;
}

.intro-keys, .intro-more {
  margin: 12px 0 0;
  color: #d9c7a4;
  font-size: 0.95rem;
}

.intro-card button, #intro-go {
  margin-top: 16px;
  min-height: 48px;
  padding: 0 18px;
  background: var(--brass);
  color: var(--ink);
  border: 0;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.intro-more a { color: var(--brass); }

button:focus-visible, a:focus-visible, input:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 2px;
}

@media (max-width: 800px), (pointer: coarse) {
  /* The 1px scanline sits on top of a moving grid and shimmers while panning.
     backdrop-filter promotes an extra layer that flickers on phone GPUs. */
  .veil,
  body.far .veil {
    background: radial-gradient(ellipse at center, transparent 55%, rgba(10, 6, 3, 0.4) 100%);
  }
  .notes,
  .chat {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}

@media (max-width: 800px) {
  .ticket {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 12px;
    align-items: end;
    width: auto;
    max-width: none;
    padding: 10px 12px;
  }

  .ticket .name { grid-column: 1; }
  .ticket .score {
    grid-column: 2;
    grid-row: 1 / span 2;
    margin: 0;
    align-self: center;
    font-size: 1.7rem;
  }
  .ticket .personal { grid-column: 1; margin-top: 2px; }
  .ticket .cool,
  .ticket .everyone { grid-column: 1 / -1; }
  .score-label { display: none; }

  .notes,
  .notes.shut,
  .notes.open {
    top: auto;
    bottom: 0;
    right: 0;
    left: 0;
    width: auto;
    max-height: min(58dvh, calc(100dvh - 24px));
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
    opacity: 1;
    visibility: visible;
  }

  .notes,
  .notes.shut {
    pointer-events: none;
    transform: translateY(110%);
  }

  .notes.open {
    z-index: 4;
    pointer-events: auto;
    transform: translateY(0);
    padding-bottom: calc(14px + var(--safe-bot));
  }

  .chat,
  .chat.shut,
  .chat.open {
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    width: auto;
    max-height: min(58dvh, calc(100dvh - 24px));
    opacity: 1;
    visibility: visible;
  }

  .chat,
  .chat.shut {
    pointer-events: none;
    transform: translateY(110%);
  }

  .chat.open {
    z-index: 4;
    pointer-events: auto;
    transform: translateY(0);
    padding-bottom: calc(14px + var(--safe-bot));
  }

  .hud-bottom {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    position: fixed;
    z-index: 2;
    left: 0;
    right: 0;
    bottom: 0;
    padding:
      0
      calc(10px + var(--safe-right))
      calc(8px + var(--safe-bot))
      calc(10px + var(--safe-left));
    pointer-events: none;
  }

  .hud-bottom .hint,
  .hud-bottom .ticket,
  .hud-bottom .dock {
    position: relative;
    inset: auto;
    left: auto;
    right: auto;
    top: auto;
    bottom: auto;
    transform: none;
    width: auto;
    max-width: none;
    margin: 0;
  }

  .hud-bottom .ticket,
  .hud-bottom .tools,
  .hud-bottom .tools button {
    pointer-events: auto;
  }

  .hint {
    font-size: 0.88rem;
    line-height: 1.35;
    text-align: center;
  }

  .hint.gone { display: none; }

  .dock {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }

  .label-long { display: none; }
  .label-short { display: inline; }

  .tools {
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    flex-wrap: unset;
    overflow: visible;
    justify-content: stretch;
    width: 100%;
    max-width: none;
    gap: 6px;
  }

  .tools button {
    width: 100%;
    min-width: 0;
    padding: 0 2px;
    font-size: 0.68rem;
    letter-spacing: 0.04em;
    white-space: nowrap;
  }

  .top {
    left: calc(12px + var(--safe-left));
    right: calc(96px + var(--safe-right));
    transform: none;
    text-align: left;
    max-width: none;
  }
  .survived,
  .progress-label,
  .live { line-height: 1.35; }
  .progress-track { margin-left: 0; width: min(220px, 100%); }
  #mini {
    top: calc(10px + var(--safe-top));
    right: calc(10px + var(--safe-right));
    bottom: auto;
    width: 76px;
    height: 76px;
  }
}

@media (max-width: 640px) {
  .tools { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 800px) and (max-height: 520px) {
  .hud-bottom { gap: 4px; }
  .ticket { padding: 6px 8px; }
  .ticket .score { font-size: 1.25rem; }
  .hint { font-size: 0.78rem; }
  .tools { grid-template-columns: repeat(8, minmax(0, 1fr)); }
  .tools button { min-height: 40px; }
}

@media (max-height: 560px) {
  .over {
    top: calc(8px + var(--safe-top));
    transform: translate(-50%, 0);
    max-height: calc(100dvh - 16px - var(--safe-top) - var(--safe-bot));
    overflow: auto;
    pointer-events: auto;
    -webkit-overflow-scrolling: touch;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pip.live { animation: none; }
  .hint, .toast, .notes { transition: none; }
  body.boom #field { animation: none; }
}
