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

* {
  box-sizing: border-box;
}

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 {
  padding: 2px 0 12px;
  text-align: center;
  border-bottom: 2px dashed var(--amber-dim);
}

.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);
}

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

.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;
}

.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 tr.is-yours td {
  color: #fff;
}

.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.4fr 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-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);
}

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

.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(3), .lb-table td:nth-child(3) {
  text-align: right;
}

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

.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;
}

.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;
}

.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 {
  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-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 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 {
    animation: none;
  }

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

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

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

@media (max-width: 800px) {
  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;
  }

  /* 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;
  }
}
