:root {
  --bg: #090c16;
  --panel: rgba(18, 24, 42, 0.86);
  --panel-solid: #121a30;
  --card: rgba(255, 255, 255, 0.045);
  --line: rgba(255, 255, 255, 0.09);
  --text: #eef2ff;
  --muted: #8d98ba;
  --accent: #7dff3f;
  --accent-ink: #0b1a05;
  --gold: #ffc83d;
  --danger: #ff4d5e;
  --blue: #4da3ff;
  --tg-t: 0px;
  --tg-b: 0px;
  --tg-l: 0px;
  --tg-r: 0px;
  --safe-t: calc(env(safe-area-inset-top, 0px) + var(--tg-t));
  --safe-b: calc(env(safe-area-inset-bottom, 0px) + var(--tg-b));
  --safe-l: calc(env(safe-area-inset-left, 0px) + var(--tg-l));
  --safe-r: calc(env(safe-area-inset-right, 0px) + var(--tg-r));
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

input {
  -webkit-user-select: text;
  user-select: text;
}

.hidden {
  display: none !important;
}

#game {
  position: fixed;
  inset: 0;
  display: block;
  touch-action: none;
  background: #0a0f1c;
}

h2,
h3 {
  margin: 0;
}

.muted {
  color: var(--muted);
}

.center-text {
  text-align: center;
  padding: 24px 0;
}

.pos {
  color: #6dff7a;
}
.neg {
  color: #ff6b7a;
}

/* ------------------------------------------------------------------ logo & shared bits */
.logo {
  font-weight: 900;
  font-size: 24px;
  letter-spacing: -0.5px;
  display: inline-flex;
}
.logo span {
  color: #fff;
}
.logo b {
  color: var(--accent);
  text-shadow: 0 0 18px rgba(125, 255, 63, 0.55);
}
.logo.big {
  font-size: 46px;
}

.spinner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.12);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
  margin: 8px 0;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.glass {
  background: var(--panel);
  border: 1px solid var(--line);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.btn {
  appearance: none;
  border: 0;
  border-radius: 14px;
  padding: 13px 18px;
  font: 800 15px var(--font);
  letter-spacing: 0.2px;
  cursor: pointer;
  color: var(--text);
  transition: transform 0.08s, filter 0.15s, opacity 0.15s;
}
.btn:active {
  transform: scale(0.97);
}
.btn.primary {
  background: linear-gradient(180deg, #9bff62, #6fe52e);
  color: var(--accent-ink);
  box-shadow: 0 6px 22px rgba(125, 255, 63, 0.25);
}
.btn.secondary {
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid var(--line);
}
.btn.wide {
  width: 100%;
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(0.6);
}

.link {
  background: none;
  border: 0;
  color: var(--blue);
  font: 600 13px var(--font);
  cursor: pointer;
  padding: 6px;
}

.row {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
}
.row.small {
  justify-content: space-between;
  font-size: 12px;
}

.chip {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 12px;
  font: 800 13px var(--font);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.wallet-chip .coin {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #ffe07a, #e09a00);
  color: #6b4200;
  font-size: 12px;
}
.wallet-chip .plus {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 15px;
  line-height: 1;
}

/* ------------------------------------------------------------------ screens */
.screen {
  position: fixed;
  inset: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: calc(var(--safe-t) + 12px) calc(var(--safe-r) + 14px) calc(var(--safe-b) + 18px) calc(var(--safe-l) + 14px);
  z-index: 10;
  background: linear-gradient(180deg, rgba(9, 12, 22, 0.55), rgba(9, 12, 22, 0.9));
}
.screen.center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
  background: var(--bg);
}
#screen-blocked p {
  max-width: 320px;
  margin: 0;
  line-height: 1.45;
}
.blocked-icon {
  font-size: 54px;
}
.idbox {
  font: 800 28px ui-monospace, Menlo, Consolas, monospace;
  letter-spacing: 1px;
  background: rgba(255, 255, 255, 0.07);
  padding: 10px 18px;
  border-radius: 12px;
  border: 1px dashed var(--line);
  -webkit-user-select: text;
  user-select: text;
}

/* ------------------------------------------------------------------ lobby */
.lobby-wrap {
  max-width: 540px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
@media (min-width: 1000px) {
  .lobby-wrap {
    max-width: 1120px;
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(340px, 0.85fr);
    column-gap: 28px;
    row-gap: 16px;
    align-items: start;
  }
  .lobby-top,
  #banner-testnet,
  #banner-maint,
  .stats-card,
  .lobby-foot {
    grid-column: 1 / -1;
  }
  .skins {
    flex-wrap: wrap;
    overflow: visible;
  }
  #preview {
    aspect-ratio: 16 / 7;
  }
}
.lobby-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.top-actions {
  display: flex;
  gap: 8px;
}
.banner {
  text-align: center;
  font: 800 12px var(--font);
  letter-spacing: 0.6px;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(77, 163, 255, 0.14);
  color: #9fd0ff;
  border: 1px solid rgba(77, 163, 255, 0.3);
}
.banner.warn {
  background: rgba(255, 200, 61, 0.12);
  color: var(--gold);
  border-color: rgba(255, 200, 61, 0.3);
}
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
}
.preview-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: radial-gradient(120% 100% at 50% 0%, rgba(125, 255, 63, 0.09), rgba(255, 255, 255, 0.03));
}
#preview {
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 5;
  display: block;
}
#nick {
  width: 100%;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  font: 700 16px var(--font);
  color: var(--text);
  text-align: center;
  outline: none;
}
#nick:focus {
  border-color: var(--accent);
}
.skins {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 2px 8px;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
}
.skins::-webkit-scrollbar {
  height: 4px;
}
.skins::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 4px;
}
.skin {
  flex: 0 0 auto;
  width: 68px;
  height: 54px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.3);
  border: 2px solid transparent;
  padding: 0;
  cursor: pointer;
  scroll-snap-align: center;
  display: grid;
  place-items: center;
}
.skin canvas {
  width: 60px;
  height: 46px;
}
.skin.sel {
  border-color: var(--accent);
  background: rgba(125, 255, 63, 0.12);
  box-shadow: 0 0 16px rgba(125, 255, 63, 0.3);
}

.tables h3 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--muted);
  margin: 4px 2px 8px;
}
#table-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.card.table {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
}
.tbl-icon {
  flex: 0 0 auto;
  min-width: 54px;
  height: 54px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  padding: 0 6px;
  font: 900 18px var(--font);
  background: linear-gradient(180deg, rgba(255, 200, 61, 0.2), rgba(255, 200, 61, 0.06));
  color: var(--gold);
  border: 1px solid rgba(255, 200, 61, 0.25);
}
.card.table.free .tbl-icon {
  background: linear-gradient(180deg, rgba(125, 255, 63, 0.18), rgba(125, 255, 63, 0.05));
  border-color: rgba(125, 255, 63, 0.25);
  font-size: 24px;
}
.tbl-info {
  flex: 1;
  min-width: 0;
}
.tbl-title {
  font: 800 16px var(--font);
}
.tbl-desc {
  font-size: 12px;
  margin-top: 2px;
}
.tbl-players {
  font-size: 11px;
  color: #6dff7a;
  margin-top: 4px;
}
.card.table .btn {
  flex: 0 0 auto;
  padding: 12px 14px;
  font-size: 14px;
  max-width: 132px;
}
.stats-card {
  display: flex;
  justify-content: space-around;
}
.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.stat b {
  font: 900 20px var(--font);
}
.stat span {
  font-size: 11px;
}
.lobby-foot {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  padding: 4px 0 10px;
  font-size: 12px;
}

/* ------------------------------------------------------------------ HUD */
#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}
#hud > * {
  position: absolute;
}
#hud-me {
  left: calc(var(--safe-l) + 10px);
  top: calc(var(--safe-t) + 10px);
  padding: 8px 14px;
  border-radius: 14px;
  min-width: 118px;
}
#hud-money {
  font: 900 28px var(--font);
  color: var(--gold);
  text-shadow: 0 0 14px rgba(255, 200, 61, 0.4);
  line-height: 1.05;
}
#hud-money.free {
  color: #fff;
  text-shadow: none;
}
#hud-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}
#hud-sub.no-len .len-part {
  display: none;
}
/* separator only when there is a rank to show after the length */
#hud-sub:not(.no-len) #hud-rank:not(:empty)::before {
  content: ' · ';
}
#hud-lb {
  right: calc(var(--safe-r) + 10px);
  top: calc(var(--safe-t) + 10px);
  width: 176px;
  padding: 8px 10px;
  border-radius: 14px;
  font-size: 12px;
}
.lb-title {
  font: 800 11px var(--font);
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  margin-bottom: 4px;
}
#lb-list {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: lb;
}
#lb-list li,
#lb-me {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 4px;
  border-radius: 6px;
}
#lb-list li {
  counter-increment: lb;
}
#lb-list li::before {
  content: counter(lb) '.';
  color: var(--muted);
  width: 18px;
  flex: 0 0 18px;
}
#lb-list .n,
#lb-me .n {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#lb-list .v,
#lb-me .v {
  color: var(--gold);
  font-weight: 800;
}
#lb-list li.bot .n {
  color: var(--muted);
}
#lb-list li.me,
#lb-me {
  background: rgba(125, 255, 63, 0.16);
  font-weight: 800;
}
#lb-me {
  margin-top: 4px;
}

#hud-feed {
  left: calc(var(--safe-l) + 10px);
  top: calc(var(--safe-t) + 92px);
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: min(260px, 52vw);
}
.feed-item {
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 8px;
  background: rgba(10, 14, 28, 0.62);
  animation: slidein 0.25s ease-out;
  transition: opacity 0.5s;
}
.feed-item.kill {
  color: #ffd98a;
}
.feed-item.cash {
  color: #8dffa0;
}
.feed-item.mine {
  outline: 1px solid rgba(125, 255, 63, 0.6);
  font-weight: 700;
}
.feed-item.out {
  opacity: 0;
}
@keyframes slidein {
  from {
    transform: translateX(-16px);
    opacity: 0;
  }
}

#minimap {
  left: calc(var(--safe-l) + 12px);
  bottom: calc(var(--safe-b) + 16px);
  width: 104px;
  height: 104px;
  opacity: 0.9;
}
#hud-conn {
  left: 50%;
  top: calc(var(--safe-t) + 8px);
  transform: translateX(-50%);
  background: rgba(255, 77, 94, 0.9);
  padding: 6px 14px;
  border-radius: 999px;
  font: 800 12px var(--font);
}
#hud-ping {
  left: 50%;
  bottom: calc(var(--safe-b) + 6px);
  transform: translateX(-50%);
  font-size: 10px;
  color: rgba(255, 255, 255, 0.35);
}
#hint {
  left: 50%;
  bottom: calc(var(--safe-b) + 150px);
  transform: translateX(-50%);
  width: min(86vw, 520px);
  text-align: center;
  font: 700 13px var(--font);
  background: rgba(10, 14, 28, 0.78);
  padding: 9px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
}
body:not(.touch) #hint {
  bottom: calc(var(--safe-b) + 40px);
}

#joystick {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 6;
}
.js-base,
.js-knob {
  position: absolute;
  left: 0;
  top: 0;
  border-radius: 50%;
}
.js-base {
  width: 168px;
  height: 168px;
  border: 3px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 0 24px rgba(0, 0, 0, 0.25);
}
#joystick.docked .js-base {
  left: calc(var(--safe-l) + 14px);
  bottom: calc(var(--safe-b) + 18px);
  top: auto;
}
.js-knob {
  width: 74px;
  height: 74px;
  background: rgba(255, 255, 255, 0.55);
  border: 3px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
}
#joystick.live .js-knob {
  background: rgba(255, 255, 255, 0.85);
}

.round-btn {
  pointer-events: auto;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  appearance: none;
  border: 0;
  border-radius: 50%;
  color: #fff;
  font-family: var(--font);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 0.07s, filter 0.15s;
}
.round-btn.down {
  transform: scale(0.92);
}
.round-btn.boost {
  right: calc(var(--safe-r) + 16px);
  bottom: calc(var(--safe-b) + 22px);
  width: 118px;
  height: 118px;
  background: radial-gradient(circle at 35% 30%, #5eb7ff, #1f6bff);
  box-shadow: 0 8px 28px rgba(31, 107, 255, 0.45), inset 0 0 0 3px rgba(255, 255, 255, 0.25);
  font-size: 40px;
}
.round-btn.boost.active {
  filter: brightness(1.35);
  box-shadow: 0 0 36px rgba(77, 163, 255, 0.9), inset 0 0 0 3px rgba(255, 255, 255, 0.5);
}
body:not(.touch) .round-btn.boost {
  display: none;
}
.round-btn.cash {
  right: calc(var(--safe-r) + 22px);
  bottom: calc(var(--safe-b) + 156px);
  width: 96px;
  height: 96px;
  background: radial-gradient(circle at 35% 30%, #ffe27a, #e59a00);
  box-shadow: 0 8px 26px rgba(229, 154, 0, 0.4), inset 0 0 0 3px rgba(255, 255, 255, 0.3);
  color: #4a2c00;
}
body:not(.touch) .round-btn.cash,
body:not(.touch) .round-btn.boost {
  display: none;
}
#pc-bar {
  display: none;
}
body:not(.touch) #pc-bar {
  display: block;
  left: 50%;
  bottom: calc(var(--safe-b) + 18px);
  transform: translateX(-50%);
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(8, 12, 22, 0.72);
  border: 1px solid var(--line);
  font: 700 13px var(--font);
  color: rgba(255, 255, 255, 0.78);
  white-space: nowrap;
}
.round-btn.cash.locked {
  filter: grayscale(0.85) brightness(0.8);
}
.round-btn.cash.active {
  box-shadow: 0 0 34px rgba(255, 200, 61, 0.95), inset 0 0 0 3px rgba(255, 255, 255, 0.6);
}
.btn-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.1;
  pointer-events: none;
}
.btn-label b {
  font: 900 11px var(--font);
  letter-spacing: 0.4px;
}
.btn-label i {
  font: 900 15px var(--font);
  font-style: normal;
}
.ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
  pointer-events: none;
}
.ring-bg {
  fill: none;
  stroke: rgba(0, 0, 0, 0.18);
  stroke-width: 5;
}
.ring-fg {
  fill: none;
  stroke: #fff;
  stroke-width: 5;
  stroke-linecap: round;
  stroke-dasharray: 175.93;
  stroke-dashoffset: 175.93;
}

.key-hint {
  position: absolute;
  top: -6px;
  right: -2px;
  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  border-radius: 7px;
  background: #12182c;
  color: #fff;
  font: 800 12px var(--font);
  line-height: 22px;
  text-align: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}
body.touch .key-hint {
  display: none;
}

@media (max-height: 520px) {
  .js-base {
    width: 124px;
    height: 124px;
  }
  .js-knob {
    width: 58px;
    height: 58px;
  }
  .round-btn.boost {
    width: 88px;
    height: 88px;
  }
  .round-btn.cash {
    width: 74px;
    height: 74px;
    bottom: calc(var(--safe-b) + 118px);
  }
}

@media (max-width: 520px) {
  #hud-lb {
    width: 140px;
    font-size: 11px;
  }
  #lb-list li:nth-child(n + 6) {
    display: none;
  }
  #hud-money {
    font-size: 24px;
  }
  #minimap {
    width: 72px;
    height: 72px;
    left: calc(var(--safe-l) + 22px);
    bottom: calc(var(--safe-b) + 200px);
  }
  #hud-feed {
    top: calc(var(--safe-t) + 84px);
  }
}

/* ------------------------------------------------------------------ overlays & modals */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(5, 7, 14, 0.62);
}
.result-card {
  width: min(92vw, 400px);
  border-radius: 24px;
  padding: 22px 20px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.overlay.in .result-card {
  animation: pop 0.35s cubic-bezier(0.2, 1.4, 0.4, 1);
}
@keyframes pop {
  from {
    transform: scale(0.8);
    opacity: 0;
  }
}
.res-emoji {
  font-size: 54px;
  line-height: 1;
}
.res-amount {
  font: 900 44px var(--font);
  min-height: 0;
}
.res-amount.gold {
  color: var(--gold);
  text-shadow: 0 0 24px rgba(255, 200, 61, 0.5);
}
.res-amount.neg {
  color: #ff6b7a;
}
.res-amount:empty {
  display: none;
}
.res-stats {
  display: flex;
  justify-content: space-around;
  margin: 10px 0 6px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.result-card .row .btn {
  flex: 1;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(5, 7, 14, 0.66);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.sheet {
  position: relative;
  width: min(100%, 520px);
  max-height: 92vh;
  overflow-y: auto;
  border-radius: 24px 24px 0 0;
  padding: 20px 18px calc(var(--safe-b) + 22px);
  animation: sheet 0.28s ease-out;
  background: var(--panel-solid);
}
@media (min-width: 700px) {
  .modal {
    align-items: center;
  }
  .sheet {
    border-radius: 24px;
  }
}
@keyframes sheet {
  from {
    transform: translateY(40px);
    opacity: 0;
  }
}
.x {
  position: absolute;
  right: 12px;
  top: 10px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 0;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  font-size: 22px;
  cursor: pointer;
}
.wallet-head {
  text-align: center;
  margin-bottom: 12px;
}
.wallet-balance {
  font: 900 38px var(--font);
  color: var(--gold);
}
.tabs {
  display: flex;
  gap: 6px;
  background: rgba(0, 0, 0, 0.28);
  padding: 4px;
  border-radius: 14px;
  margin-bottom: 14px;
}
.tab {
  flex: 1;
  border: 0;
  background: none;
  color: var(--muted);
  font: 800 13px var(--font);
  padding: 10px 6px;
  border-radius: 10px;
  cursor: pointer;
}
.tab.active {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text);
}
.panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.panel.hidden {
  display: none !important;
}
.presets {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.preset {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  border-radius: 12px;
  padding: 11px 0;
  font: 800 15px var(--font);
  cursor: pointer;
}
.preset:active {
  background: rgba(125, 255, 63, 0.2);
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}
.field input {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 13px 14px;
  font: 800 20px var(--font);
  color: var(--text);
  outline: none;
}
.field input:focus {
  border-color: var(--accent);
}
.hint {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
}
.status {
  font-size: 13px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.07);
  line-height: 1.4;
}
.status.ok {
  background: rgba(109, 255, 122, 0.12);
  color: #8dffa0;
}
.status.err {
  background: rgba(255, 77, 94, 0.14);
  color: #ff9aa5;
}
.hist {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 48vh;
  overflow-y: auto;
}
.hist-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 4px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.hist-row small {
  display: block;
  font-size: 11px;
}
.hist-row > div:last-child {
  font-weight: 900;
}
.rules p {
  margin: 10px 0;
  line-height: 1.5;
  font-size: 14px;
}
.sheet h2 {
  margin-bottom: 6px;
}

/* ------------------------------------------------------------------ toasts */
#toasts {
  position: fixed;
  left: 50%;
  top: calc(var(--safe-t) + 14px);
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
  width: min(92vw, 420px);
}
.toast {
  background: rgba(18, 24, 42, 0.96);
  border: 1px solid var(--line);
  padding: 10px 16px;
  border-radius: 12px;
  font: 700 14px var(--font);
  text-align: center;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.5);
  animation: toast-in 0.25s ease-out;
  transition: opacity 0.35s, transform 0.35s;
}
.toast.err {
  border-color: rgba(255, 77, 94, 0.6);
  color: #ffb3bb;
}
.toast.ok {
  border-color: rgba(125, 255, 63, 0.6);
  color: #b9ff93;
}
.toast.out {
  opacity: 0;
  transform: translateY(-8px);
}
@keyframes toast-in {
  from {
    transform: translateY(-12px);
    opacity: 0;
  }
}
