:root {
  --black: #000;
  --amber: #ffb000;
  --amber-dim: #9b6b00;
  --red: #ff4438;
  --green: #62e51f;
  --blue: #6194ff;
}

* {
  box-sizing: border-box;
}

/* The hidden attribute must always win, even over display-setting classes. */
[hidden] {
  display: none !important;
}

html {
  color-scheme: dark;
  background: var(--black);
}

body {
  position: relative;
  min-width: 320px;
  margin: 0;
  padding: 34px 18px 24px;
  color: var(--amber);
  background: var(--black);
  font-family: "Courier New", Courier, monospace;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.045em;
}

.star-lane {
  position: fixed;
  z-index: 0;
  top: 0;
  bottom: 0;
  width: max(54px, calc((100vw - 1040px) / 2));
  overflow: hidden;
  color: var(--amber);
  pointer-events: none;
}

.star-lane-left {
  left: 0;
}

.star-lane-right {
  right: 0;
}

.star-track {
  position: absolute;
  left: 50%;
  display: grid;
  width: min(110px, 72%);
  grid-template-columns: repeat(2, 1fr);
  gap: 28px 20px;
  justify-items: center;
  color: var(--amber);
  font-size: clamp(1rem, 1.7vw, 1.55rem);
  line-height: 1;
  text-shadow: 0 0 5px #7d5600;
  transform: translateX(-50%);
  opacity: 0.78;
}

.star-track span:nth-child(3n) {
  font-size: 0.72em;
  opacity: 0.65;
}

.star-track span:nth-child(4n) {
  transform: translateX(8px);
}

.star-lane-left .star-track {
  animation: stars-up 18s linear infinite;
}

.star-lane-right .star-track {
  animation: stars-down 18s linear infinite;
}

button,
input {
  font: inherit;
}

.site-shell {
  position: relative;
  z-index: 1;
  width: min(100%, 1000px);
  margin: 0 auto;
  padding: 14px;
  border: 2px dashed var(--amber-dim);
}

.site-header {
  position: relative;
  padding: 2px 0 12px;
  text-align: center;
  border-bottom: 2px dashed var(--amber-dim);
}

/* Top-left badge stack: IKYDK on top, the how-to-flip play button under it
   (desktop). On mobile this becomes a centered row below the tagline. */
.header-badges {
  position: absolute;
  left: 14px;
  top: 10px;
  z-index: 6;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.ikydk-wrap {
  position: relative;
}

.howto-wrap {
  position: relative;
}

/* Small retro play button — orange triangle in a boxed sign, inverts on
   hover/open like the IKYDK button. */
.howto-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 22px;
  padding: 0;
  background: var(--black);
  border: 1px solid var(--amber-dim);
  cursor: pointer;
}

.howto-button::before {
  content: "";
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 6px 0 6px 10px;
  border-color: transparent transparent transparent var(--amber);
}

.howto-button:hover,
.howto-button[aria-expanded="true"] {
  background: var(--amber);
}

.howto-button:hover::before,
.howto-button[aria-expanded="true"]::before {
  border-left-color: var(--black);
}

.howto-popover {
  position: absolute;
  left: 0;
  top: calc(100% + 8px);
  z-index: 7;
  padding: 8px;
  background: #030303;
  border: 2px solid var(--amber);
  box-shadow: 0 0 22px rgba(255, 176, 0, 0.25);
}

.howto-gif {
  display: block;
  /* Desktop gets the 460px cap; on mobile the 74vw term wins and keeps it
     inside the small viewport. */
  width: min(460px, 74vw);
  height: auto;
}

.ikydk-button {
  padding: 4px 9px;
  color: var(--amber);
  background: var(--black);
  border: 1px solid var(--amber-dim);
  font: inherit;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  cursor: help;
}

.ikydk-button:hover,
.ikydk-button[aria-expanded="true"] {
  color: var(--black);
  background: var(--amber);
}

.ikydk-popover {
  position: absolute;
  left: 0;
  top: calc(100% + 8px);
  z-index: 7;
  width: min(340px, 78vw);
  padding: 14px 16px;
  color: var(--amber);
  background: #030303;
  border: 2px solid var(--amber);
  box-shadow: 0 0 22px rgba(255, 176, 0, 0.25);
  text-align: left;
  letter-spacing: 0;
}

.ikydk-popover p {
  margin: 0 0 8px;
  font-size: 0.8rem;
  line-height: 1.5;
  font-weight: 400;
}

.ikydk-popover .ikydk-punch {
  margin: 10px 0 0;
  padding-top: 8px;
  border-top: 1px dashed var(--amber-dim);
  color: var(--green);
  font-weight: 700;
  letter-spacing: 0.03em;
}

.ascii-logo {
  display: inline-block;
  margin: 0;
  color: var(--amber);
  font-family: "Courier New", Courier, monospace;
  font-size: clamp(0.38rem, 1.4vw, 0.92rem);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: 0;
  white-space: pre;
  text-align: left;
  overflow: hidden;
  text-shadow: 2px 2px 0 #443000;
}

.tagline {
  margin: 10px 0 0;
  font-size: clamp(0.68rem, 2vw, 1rem);
}

.game {
  padding-top: 10px;
}

.flip-result {
  min-height: 1.4em;
  margin: 0 0 10px;
  color: var(--red);
  font-size: clamp(0.9rem, 2.4vw, 1.25rem);
  text-align: center;
  animation: blink 1s steps(2, jump-none) infinite;
}

.cursor {
  display: inline-block;
  width: 0.65em;
  height: 1.05em;
  margin-left: 0.2em;
  vertical-align: -0.15em;
  background: var(--red);
}

/* Desktop: coin frame with the lifetime tally panel to its right, the pair
   centered. Mobile stacks them (see media query below). */
.stage-row {
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 14px;
}

.coin-stage {
  position: relative;
  display: grid;
  width: min(100%, 350px);
  flex: 0 0 auto;
  /* Taller than wide: a coin flip needs airspace. A square stage caps the
     toss at a nudge. */
  aspect-ratio: 1 / 1.15;
  margin: 0;
  place-items: center;
  overflow: hidden;
  border: 2px solid var(--amber);
  background: #010101;
}

/* Lifetime tally: tokens burned + SOL awarded. Matches the frame height. */
.burn-stats {
  flex: 0 0 auto;
  align-self: stretch;
  width: 190px;
  display: flex;
  flex-direction: column;
  padding: 12px 12px 14px;
  border: 2px solid var(--amber-dim);
  background: #010101;
}

.burn-stats-title {
  margin: 0 0 auto;
  color: var(--red);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-align: center;
}

.burn-stats-grid {
  margin: 14px 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.burn-stats-grid div {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.burn-stats-grid dt {
  color: var(--amber-dim);
  font-size: 0.6rem;
  letter-spacing: 0.08em;
}

.burn-stats-grid dd {
  margin: 0;
  color: var(--amber);
  font-size: 1.02rem;
  line-height: 1.15;
  word-break: break-word;
}

.burn-stats-grid dd.burn-stats-burn { color: var(--red); }
.burn-stats-grid dd.burn-stats-sol { color: var(--green); }

.burn-stats-foot {
  margin: auto 0 0;
  color: var(--amber-dim);
  font-size: 0.56rem;
  letter-spacing: 0.06em;
  text-align: center;
  line-height: 1.5;
}

.coin-verdict {
  position: absolute;
  z-index: 3;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.6);
  font-family: inherit;
  font-weight: 700;
  font-size: clamp(2.4rem, 11vw, 4.2rem);
  letter-spacing: 0.04em;
  text-align: center;
  line-height: 1;
  pointer-events: none;
  opacity: 0;
  white-space: nowrap;
  text-shadow: 0 0 18px currentColor, 3px 3px 0 #000;
}

.coin-verdict.is-show {
  animation: verdict-pop 0.5s cubic-bezier(0.2, 1.4, 0.4, 1) forwards;
}

.coin-verdict.is-win { color: var(--green); }
.coin-verdict.is-loss { color: var(--red); }

@keyframes verdict-pop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5) rotate(-6deg); }
  60% { opacity: 1; transform: translate(-50%, -50%) scale(1.12) rotate(2deg); }
  100% { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(0); }
}

.sound-toggle {
  position: absolute;
  z-index: 2;
  top: 8px;
  right: 8px;
  padding: 4px 8px;
  color: var(--amber);
  background: rgba(0, 0, 0, 0.72);
  border: 1px solid var(--amber-dim);
  border-radius: 0;
  font-size: 0.66rem;
  letter-spacing: 0.08em;
  cursor: pointer;
}

.sound-toggle:hover {
  color: var(--black);
  background: var(--amber);
}

.sound-toggle.is-muted {
  color: var(--amber-dim);
  border-color: #3a2800;
}

.sound-toggle.is-muted:hover {
  color: var(--black);
  background: var(--amber-dim);
}

.coin {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: manipulation;
}

/* Result tones. The idle blink is charming; a result you cannot read is not,
   so settled results hold steady. */
.flip-result.is-win {
  color: var(--green);
  animation: none;
}

.flip-result.is-win .cursor {
  background: var(--green);
}

.flip-result.is-loss {
  color: var(--red);
  animation: none;
}

/* Progress states hold steady - blinking reads as "stalled". A ticking
   ellipsis says "working" instead. */
.flip-result.is-busy {
  color: var(--amber);
  animation: none;
}

.flip-result.is-busy .cursor {
  display: none;
}

.flip-result.is-busy::after {
  display: inline-block;
  width: 1.4em;
  text-align: left;
  content: "";
  animation: busy-dots 1.2s steps(4, jump-none) infinite;
}

.seed-line {
  display: flex;
  gap: 8px;
  align-items: baseline;
  justify-content: center;
  margin: 8px 0 0;
  font-size: 0.7rem;
}

.seed-label {
  color: var(--amber-dim);
}

.seed-value {
  color: var(--amber);
  font-family: inherit;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
}

.ledger tbody tr.is-new {
  animation: row-flash 1.2s ease-out 1;
}

.ledger tr.is-yours td {
  color: #fff;
}

.ledger tr.is-new td {
  animation: flash-amber 0.9s ease-out;
}

@keyframes flash-amber {
  0% { background: rgba(255, 176, 0, 0.55); }
  100% { background: transparent; }
}

.ledger tr.is-yours td:first-child::before {
  content: ">";
  margin-right: 6px;
  color: var(--amber);
}

.flip-form {
  display: grid;
  grid-template-columns: 1.05fr 1.15fr 1.15fr auto;
  gap: 18px;
  align-items: start;
  padding: 14px 8px;
}

.side-picker {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.side-stats {
  grid-column: 1 / -1;
  margin-top: 8px;
}

.side-stats-bar {
  display: flex;
  width: 100%;
  height: 12px;
  overflow: hidden;
  border: 1px solid var(--amber-dim);
  background: #050505;
  cursor: help;
}

.side-stats-bar:focus-visible {
  outline: 2px dotted #fff;
  outline-offset: 2px;
}

.side-stats-seg {
  height: 100%;
  transition: width 0.4s ease;
}

.side-stats-seg.is-heads { background: var(--amber); }
.side-stats-seg.is-tails { background: #6b4a00; }

.side-stats-bar:hover .side-stats-seg.is-heads,
.side-stats-bar:focus-visible .side-stats-seg.is-heads { background: #ffc540; }
.side-stats-bar:hover .side-stats-seg.is-tails,
.side-stats-bar:focus-visible .side-stats-seg.is-tails { background: #8a6200; }

.side-stats-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  font-size: 0.64rem;
  letter-spacing: 0.05em;
}

.side-stats-counts {
  margin-top: 2px;
  font-size: 0.58rem;
  color: var(--amber-dim);
}

.side-stats-labels span:first-child { color: var(--amber); }
.side-stats-labels span:last-child { color: #b3831f; }

.side-picker legend {
  width: 100%;
  margin-bottom: 6px;
  font-size: 0.76rem;
  text-align: center;
}

.choice {
  position: relative;
  display: inline-block;
}

.choice input {
  position: absolute;
  opacity: 0;
}

.choice span,
.flip-button {
  display: block;
  padding: 10px 12px;
  color: var(--amber);
  background: var(--black);
  border: 1px solid var(--amber);
  border-radius: 0;
  box-shadow: none;
  cursor: pointer;
}

.choice input:checked + span {
  color: var(--black);
  background: var(--amber);
}

.choice input:focus-visible + span,
.flip-button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 2px dotted #fff;
  outline-offset: 3px;
}

.field {
  display: grid;
  gap: 5px;
  min-width: 0;
  font-size: 0.76rem;
}

.field input {
  width: 100%;
  height: 32px;
  padding: 4px 8px;
  color: #eee;
  background: #050505;
  border: 2px inset #aaa;
  border-radius: 0;
}

.field small {
  color: var(--amber);
  font-size: 0.7rem;
}

.flip-button {
  margin-top: 20px;
  white-space: nowrap;
}

.choice span:hover,
.flip-button:hover {
  color: var(--black);
  background: var(--amber);
}

.flip-button[disabled] {
  color: var(--amber-dim);
  border-color: var(--amber-dim);
  background: var(--black);
  cursor: progress;
}

.flip-button[disabled]:hover {
  color: var(--amber-dim);
  background: var(--black);
}

.ledger {
  padding: 0 8px;
  border-top: 2px dashed var(--amber-dim);
}

.ledger-intro {
  margin: 0 0 10px;
  color: var(--amber-dim);
  font-size: 0.72rem;
  text-align: center;
  line-height: 1.5;
}

.ledger h2 {
  margin: 8px 0 6px;
  font-size: 1rem;
  text-align: center;
}

.table-scroll {
  overflow-x: auto;
}

/* ~10 rows tall, then the ledger scrolls inside itself. Scroll chaining is
   left ON (no overscroll-behavior) so when a touch reaches the ledger's end
   the page keeps moving - nobody gets trapped scrolling history. */
.ledger-scroll {
  max-height: 252px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--amber-dim) transparent;
}

.ledger-scroll thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--black);
}

.leaderboard-wrap {
  position: relative;
  display: flex;
  justify-content: center;
  margin: 14px 0 0;
}

.lb-panel {
  position: absolute;
  z-index: 5;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  width: min(92vw, 440px);
  padding: 12px 14px;
  background: #030303;
  border: 2px solid var(--amber);
  box-shadow: 0 0 22px rgba(255, 176, 0, 0.25);
}

.lb-title {
  margin: 0 0 8px;
  color: var(--red);
  font-size: 0.74rem;
  text-align: center;
  line-height: 1.5;
}

.lb-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}

.lb-table th {
  padding: 2px 6px;
  border-bottom: 1px dashed var(--amber-dim);
  text-align: left;
}

.lb-table td {
  padding: 2px 6px;
}

.lb-table th:nth-child(4), .lb-table td:nth-child(4),
.lb-table th:nth-child(5), .lb-table td:nth-child(5) {
  text-align: right;
}

.lb-table td:nth-child(3) {
  font-size: 0.72rem;
}

.lb-table tr:first-child td {
  color: #fff;
}

.share-flip-button {
  display: block;
  margin: 12px auto 0;
  padding: 12px 20px;
  color: var(--black);
  background: var(--amber);
  border: 1px solid var(--amber);
  font: inherit;
  font-size: 0.9rem;
  letter-spacing: 0.06em;
  cursor: pointer;
}

.share-flip-button:hover {
  color: var(--amber);
  background: var(--black);
}

.share-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.88);
}

.share-modal[hidden] { display: none; }

.share-modal-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  max-width: 100%;
}

.share-canvas {
  width: min(80vh, 88vw, 520px);
  height: auto;
  border: 2px solid var(--amber);
  box-shadow: 0 0 30px rgba(255, 176, 0, 0.3);
}

.share-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.add-tokens-wrap {
  display: flex;
  justify-content: center;
  margin: 16px 0 4px;
}

.add-tokens-wrap .add-tokens-button {
  font-size: 0.9rem;
  padding: 14px 22px;
  color: var(--black);
  background: var(--amber);
  border-color: var(--amber);
}

.add-tokens-wrap .add-tokens-button.is-soon,
.add-tokens-wrap .add-tokens-button[disabled] {
  color: var(--amber-dim);
  background: var(--black);
  border-color: var(--amber-dim);
  cursor: default;
}

.add-tokens-wrap .add-tokens-button.is-soon:hover,
.add-tokens-wrap .add-tokens-button[disabled]:hover {
  color: var(--amber-dim);
  background: var(--black);
}

.add-tokens-wrap .add-tokens-button:hover {
  color: var(--amber);
  background: var(--black);
}

.token-links {
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 14px 0 4px;
  padding-top: 12px;
  border-top: 2px dashed var(--amber-dim);
}

.token-button {
  display: inline-block;
  padding: 10px 16px;
  color: var(--amber);
  background: var(--black);
  border: 1px solid var(--amber);
  font: inherit;
  font-size: 0.82rem;
  text-decoration: none;
  cursor: pointer;
}

.token-button:hover {
  color: var(--black);
  background: var(--amber);
}

.token-button[disabled],
.token-button.is-soon {
  color: var(--amber-dim);
  border-color: var(--amber-dim);
  cursor: default;
}

.token-button[disabled]:hover,
.token-button.is-soon:hover {
  color: var(--amber-dim);
  background: var(--black);
}

.ca-button code {
  font-family: inherit;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
  text-align: left;
}

th {
  padding: 4px 8px;
  border-bottom: 2px dashed var(--amber-dim);
}

td {
  padding: 3px 8px;
}

th:nth-child(3),
td:nth-child(3),
th:nth-child(4),
td:nth-child(4) {
  text-align: right;
}

/* Ledger column order: NICK | BET | RESULT | WALLET.
   NICK left, BET right (numbers), RESULT + WALLET back to left. */
.ledger th:nth-child(2),
.ledger td:nth-child(2) {
  text-align: right;
}

.ledger th:nth-child(3),
.ledger td:nth-child(3),
.ledger th:nth-child(4),
.ledger td:nth-child(4) {
  text-align: left;
}

.wallet-cell {
  cursor: pointer;
  transition: color 0.12s ease;
}

.wallet-cell:hover {
  color: #fff;
  text-decoration: underline dotted;
}

.wallet-cell.is-copied {
  color: var(--green);
  text-decoration: none;
}

/* deposit address is a wallet-cell but keep its box look */
.deposit-address.wallet-cell:hover {
  color: #fff;
  background: #101010;
  text-decoration: none;
}

.win {
  color: var(--green);
}

.loss {
  color: var(--red);
}

.deposit-panel {
  margin: 12px auto 0;
  padding: 10px 12px;
  width: min(100%, 560px);
  border: 2px dashed var(--amber);
  text-align: center;
  visibility: hidden;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  border-width: 0;
  margin-top: 0;
  padding-top: 0;
  padding-bottom: 0;
  transform: translateY(-4px);
  transition: opacity 0.25s ease, transform 0.25s ease,
              max-height 0.3s ease, margin 0.3s ease, padding 0.3s ease;
}

.secured-panel {
  margin: 0 auto;
  width: min(100%, 560px);
  text-align: center;
  visibility: hidden;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transform: translateY(-4px);
  transition: opacity 0.25s ease, transform 0.25s ease, max-height 0.3s ease, margin 0.3s ease;
}

.secured-panel.is-open {
  visibility: visible;
  max-height: 240px;
  opacity: 1;
  margin: 12px auto 0;
  transform: translateY(0);
}

.secured-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 0 0 12px;
  padding: 10px;
  border: 2px dashed var(--amber);
}

.secured-grid dt {
  font-size: 0.66rem;
  color: var(--amber-dim);
}

.secured-grid dd {
  margin: 4px 0 0;
  font-size: 0.9rem;
  color: #fff;
}

.flip-now {
  width: 100%;
  margin: 0;
  animation: pulse-dim 1.1s ease-in-out infinite;
}

.flip-now:disabled {
  animation: none;
}

.flip-form.is-locked {
  opacity: 0.4;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.deposit-panel.is-open {
  visibility: visible;
  max-height: 220px;
  opacity: 1;
  border-width: 2px;
  margin-top: 12px;
  padding: 10px 12px;
  transform: translateY(0);
}

.deposit-title {
  margin: 0 0 8px;
  font-size: 0.78rem;
}

.deposit-row {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  margin: 0 0 8px;
}

.deposit-address {
  animation: flash-amber 0.9s ease-out;
  padding: 5px 8px;
  max-width: 100%;
  overflow-wrap: anywhere;
  color: #fff;
  background: #050505;
  border: 1px solid var(--amber-dim);
  font-family: inherit;
  font-size: 0.72rem;
}

.deposit-copy {
  padding: 5px 10px;
  color: var(--amber);
  background: var(--black);
  border: 1px solid var(--amber);
  font-size: 0.7rem;
  cursor: pointer;
}

.deposit-copy:hover {
  color: var(--black);
  background: var(--amber);
}

.deposit-copy:active {
  transform: translateY(1px);
}

.deposit-note {
  margin: 0;
  color: var(--amber-dim);
  font-size: 0.66rem;
  line-height: 1.5;
}

.update-note {
  margin: 10px 0 0;
  padding: 10px 0 0;
  border-top: 2px dashed var(--amber-dim);
  font-size: 0.76rem;
  line-height: 1.45;
  text-align: center;
}

.site-footer {
  position: relative;
  z-index: 1;
  width: min(100%, 1000px);
  margin: 20px auto 0;
  font-size: 0.78rem;
  text-align: center;
}

.site-footer nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  justify-content: center;
}

a {
  color: var(--blue);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@keyframes blink {
  50% { opacity: 0; }
}

@keyframes busy-dots {
  0%   { content: ""; }
  25%  { content: "."; }
  50%  { content: ".."; }
  75%  { content: "..."; }
  100% { content: "..."; }
}

@keyframes row-flash {
  0% { background: rgba(255, 176, 0, 0.35); }
  100% { background: transparent; }
}

@keyframes stars-up {
  from { transform: translate(-50%, 0); }
  to { transform: translate(-50%, -50%); }
}

@keyframes stars-down {
  from { transform: translate(-50%, -50%); }
  to { transform: translate(-50%, 0); }
}

@media (prefers-reduced-motion: reduce) {
  .flip-result,
  .flip-result.is-busy,
  .flip-button:disabled,
  .deposit-address,
  .coin-verdict.is-show,
  .ledger tr.is-new td {
    animation: none;
  }

  .side-stats-seg { transition: none; }

  .coin-verdict.is-show { opacity: 1; transform: translate(-50%, -50%) scale(1); }

  /* flip.js also skips the trajectory and renders the result directly. */

  .deposit-panel {
    transition: none;
  }

  .ledger tbody tr.is-new {
    animation: none;
  }

  .star-track {
    animation: none !important;
  }
}

@media (max-width: 1120px) {
  .star-lane {
    display: none;
  }
}

@media (max-width: 800px) {
  /* Badges sit below the tagline, centered, in a row: IKYDK then the play
     button beside it. */
  .header-badges {
    position: static;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 12px auto 0;
  }

  /* With the row un-positioned, both popovers anchor to the header and center
     on the viewport instead of drifting off the small triggers. */
  .ikydk-wrap,
  .howto-wrap {
    position: static;
  }

  .ikydk-popover,
  .howto-popover {
    left: 50%;
    transform: translateX(-50%);
  }

  /* No room beside the frame on a phone: stack the tally under it. */
  .stage-row {
    flex-direction: column;
    align-items: center;
    gap: 12px;
  }

  .coin-stage {
    width: 100%;
  }

  .burn-stats {
    width: min(100%, 350px);
    align-self: auto;
  }

  .burn-stats-grid {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: space-between;
  }

  .burn-stats-grid div {
    flex: 1 1 40%;
  }

  body {
    padding: 12px 8px;
    font-size: 14px;
  }

  .site-shell {
    padding: 8px;
  }

  .flip-form {
    grid-template-columns: 1fr 1fr;
  }

  .flip-button {
    margin-top: 20px;
    min-height: 44px;
  }
}

@media (max-width: 520px) {
  .flip-form {
    grid-template-columns: 1fr;
  }

  .side-picker {
    grid-template-columns: 1fr 1fr;
  }

  .side-picker legend {
    grid-column: 1 / -1;
  }

  .choice span {
    text-align: center;
  }

  table {
    min-width: 590px;
  }

  /* The Recent Flips ledger must fit the phone with NO sideways scroll:
     all four columns (NICK | BET | RESULT | WALLET) visible at once. */
  .ledger table {
    min-width: 0;
    width: 100%;
    table-layout: fixed;
    font-size: 0.68rem;
  }

  .ledger th,
  .ledger td {
    padding: 3px 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Fixed widths so BET, RESULT and the short WALLET always show in full;
     NICK takes the remainder and ellipsises long names. */
  .ledger td:nth-child(2),
  .ledger th:nth-child(2) { width: 25%; }
  .ledger td:nth-child(3),
  .ledger th:nth-child(3) { width: 18%; }
  .ledger td:nth-child(4),
  .ledger th:nth-child(4) { width: 32%; }

  /* Side gutters: page-owned touch surface beside the inner scroll area,
     so a thumb on the edge always scrolls the page, never the ledger. */
  .ledger-scroll {
    width: calc(100% - 44px);
    margin: 0 auto;
  }

  .token-button {
    width: 100%;
    text-align: center;
  }
}
