/* Yacht Crash demo - components (D2d-2). Fixed-size boxes avoid layout shifts when values change. */

/* ------------------------------------------------------------------ static shell before the app mounts */
.app-loading {
  color: var(--c-muted);
}

/* ------------------------------------------------------------------ header */
.app-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--gap) var(--gap-lg);
  min-height: 52px;
}

.brand {
  font-weight: 800;
  letter-spacing: 0.18em;
  color: var(--c-ivory);
}

.mode-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25em;
  padding: 4px 12px;
  border: 1px solid var(--c-brass);
  border-radius: 999px;
  color: var(--c-brass-strong);
  font-size: var(--fs-xs);
  letter-spacing: 0.04em;
}

.mode-badge strong {
  letter-spacing: 0.12em;
}

.mode-detail {
  color: var(--c-ivory-dim);
}

.balance {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-left: auto;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  background: var(--c-surface);
  border: 1px solid var(--c-line);
}

.balance-label {
  color: var(--c-muted);
  font-size: var(--fs-sm);
}

.balance-value {
  min-width: 12ch;
  text-align: right;
  font-weight: 700;
  font-size: var(--fs-lg);
}

/* ------------------------------------------------------------------ history (inside the header row) */
.history-bar {
  order: 10;
  flex: 1 1 100%;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: var(--gap);
  min-height: 40px;
}

.history-title {
  flex: none;
  color: var(--c-muted);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.history-list {
  display: flex;
  gap: 8px;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: thin;
  overscroll-behavior-x: contain;
}

.history-chip,
.history-empty {
  flex: none;
  min-width: 7ch;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--c-surface);
  font-size: var(--fs-sm);
  font-weight: 700;
  text-align: center;
}

.history-empty {
  color: var(--c-muted);
  font-weight: 400;
}

.band-low {
  color: var(--c-band-low);
}

.band-mid {
  color: var(--c-band-mid);
}

.band-high {
  color: var(--c-band-high);
}

/* ------------------------------------------------------------------ stage (static placeholder in D2d) */
.stage {
  position: relative;
  min-height: 280px;
  overflow: hidden;
  border-radius: var(--radius-lg);
  border: 1px solid var(--c-line);
  background: linear-gradient(180deg, #0d2f55 0%, #12406f 48%, #0b3a5e 52%, #082a47 100%);
  box-shadow: var(--shadow);
}

.stage-scene-slot {
  position: absolute;
  inset: 0;
}

.stage-overlay {
  position: relative;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 6px;
  height: 100%;
  min-height: inherit;
  padding: var(--gap-lg);
  text-align: center;
}

.stage-title {
  min-height: 1.5em;
  color: var(--c-ivory-dim);
  font-size: var(--fs-lg);
  letter-spacing: 0.06em;
}

.stage-multiplier {
  min-width: 6ch;
  font-size: var(--fs-multiplier);
  font-weight: 800;
  line-height: 1;
  color: var(--c-ivory);
  text-shadow: 0 4px 24px rgb(0 0 0 / 45%);
}

.stage-countdown {
  min-height: 1.5em;
  color: var(--c-brass-strong);
  font-size: var(--fs-lg);
  font-weight: 700;
}

.tone-boarding .stage-multiplier {
  color: var(--c-ivory-dim);
}

.tone-sailing .stage-multiplier {
  color: var(--c-ivory);
}

.tone-crashed .stage-title,
.tone-crashed .stage-multiplier {
  color: var(--c-coral);
}

/* ------------------------------------------------------------------ bet panels (Demo V2: compact) */
.bet-panel {
  position: relative;
  padding: 10px 10px 8px 34px;
  border-radius: var(--radius-md);
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  container-type: inline-size;
}

/* The panel letter sits in the left padding: no extra row. */
.panel-letter {
  position: absolute;
  top: 10px;
  left: 0;
  width: 34px;
  color: var(--c-muted);
  font-size: var(--fs-sm);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-align: center;
}

/* AUTO pill in the corner, shown only while Auto Bet is on (no layout impact). */
.auto-pill {
  position: absolute;
  bottom: 8px;
  left: 3px;
  width: 28px;
  padding: 1px 0;
  border-radius: 4px;
  background: rgb(108 198 255 / 18%);
  color: var(--c-sky);
  font-size: 0.5625rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-align: center;
  visibility: hidden;
}

.bet-panel.auto-on .auto-pill {
  visibility: visible;
}

/*
 * NEON OCEAN V3 / UI-1: a BET / AUTO selector and one control group next to a tall main button:
 *   tabs    main
 *   group   main
 *   status  status
 * BET group: stake (−/+) and presets. AUTO group: Auto Cash Out and Auto Bet (same controls as before).
 * Narrow containers stack everything; presets wrap instead of being cut.
 */
.panel-grid {
  display: grid;
  gap: 6px 8px;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas:
    'tabs'
    'group'
    'main'
    'status';
}

@container (min-width: 300px) {
  .panel-grid {
    grid-template-columns: minmax(0, 1fr) var(--main-button-w);
    grid-template-areas:
      'tabs main'
      'group main'
      'status status';
  }
}

.pg-tabs {
  grid-area: tabs;
}

.pg-group {
  grid-area: group;
  display: grid;
  gap: 6px;
  align-content: start;
  min-width: 0;
}

.pg-main {
  grid-area: main;
  display: grid;
}

/* BET / AUTO segmented selector (text labels, selection also shown by underline and weight, not colour only). */
.mode-tabs {
  display: inline-flex;
  justify-self: start;
  gap: 2px;
  padding: 2px;
  border-radius: 999px;
  background: var(--c-night);
  border: 1px solid var(--c-line);
}

.mode-tab {
  min-width: 56px;
  height: 24px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--c-muted);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
}

.mode-tab[aria-selected='true'] {
  background: var(--c-surface-raised);
  color: var(--c-ivory);
  text-decoration: underline 2px var(--c-brass);
  text-underline-offset: 4px;
}

.panel-status {
  grid-area: status;
}

.stake-row {
  display: flex;
  align-items: center;
  gap: 4px;
}

.stake-step {
  flex: none;
  width: 40px;
  height: 40px;
  border: 1px solid var(--c-line);
  border-radius: var(--radius-sm);
  background: var(--c-surface-raised);
  font-size: var(--fs-lg);
  font-weight: 700;
}

.stake-input,
.auto-cashout-input,
.auto-bet-limit {
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--c-line);
  border-radius: var(--radius-sm);
  background: var(--c-night);
}

.stake-input {
  flex: 1 1 auto;
  width: 100%;
  min-width: 5ch;
  max-width: 7rem;
  height: 40px;
  text-align: center;
  font-weight: 700;
}

.unit {
  color: var(--c-muted);
  font-size: var(--fs-sm);
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}

.chip {
  flex: 1 0 26px;
  min-width: 26px;
  max-width: 56px;
  height: 28px;
  padding: 0 4px;
  border: 1px solid var(--c-line);
  border-radius: 999px;
  background: var(--c-surface-raised);
  font-size: var(--fs-xs);
  font-weight: 600;
}

.chip[aria-pressed='true'] {
  border-color: var(--c-brass);
  color: var(--c-brass-strong);
}

.auto-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 14px;
  min-height: 32px;
}

.auto-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  font-size: var(--fs-xs);
  cursor: pointer;
}

.switch input {
  width: 18px;
  height: 18px;
  accent-color: var(--c-brass);
}

.auto-cashout-field {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.auto-cashout-input {
  width: 8ch;
  text-align: right;
}

/* Main button: fixed size and position in every state; only texts and colours change. */
.main-button {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 1px;
  width: 100%;
  min-height: var(--main-button-h);
  height: 100%;
  padding: 6px 8px;
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  background: var(--c-disabled);
  color: var(--c-ivory);
  line-height: 1.1;
  text-align: center;
  transition:
    background-color 120ms ease,
    border-color 120ms ease;
}

.main-label {
  font-size: 0.9375rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.main-sub {
  min-height: 1.1em;
  font-size: 0.625rem;
  letter-spacing: 0.02em;
  opacity: 0.9;
}

.main-amount {
  min-height: 1.1em;
  font-size: var(--fs-sm);
  font-weight: 700;
}

.main-button.action-bet,
.main-button.action-queue {
  background: var(--c-bet);
  color: var(--c-bet-text);
}

.main-button.action-cancel {
  background: var(--c-cancel);
  color: var(--c-cancel-text);
}

/* A queued bet is clearly not an accepted bet: outlined (dashed turquoise), no fill. */
.main-button.is-queued {
  background: transparent;
  border: 2px dashed var(--c-brass);
  color: var(--c-brass-strong);
}

.main-button.is-return {
  background: var(--c-return);
  color: var(--c-return-text);
  box-shadow: 0 0 18px rgb(255 190 24 / 30%);
}

.main-button:disabled {
  opacity: 0.6;
}

.main-button.is-pending {
  opacity: 0.75;
  animation: pending-pulse 1.2s ease-in-out infinite;
}

@keyframes pending-pulse {
  50% {
    opacity: 0.5;
  }
}

/* One status line with a reserved height (no layout shift); long texts are ellipsised (full text in title). */
.panel-status {
  min-height: 16px;
  overflow: hidden;
  color: var(--c-muted);
  font-size: var(--fs-xs);
  line-height: 16px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.panel-status.tone-queued {
  color: var(--c-brass-strong);
}

.panel-status.tone-pending,
.panel-status.tone-info {
  color: var(--c-ivory-dim);
}

.panel-status.tone-accepted,
.panel-status.tone-cashed {
  color: var(--c-sea-green);
}

.panel-status.tone-live {
  color: var(--c-ivory);
}

.panel-status.tone-lost,
.panel-status.tone-error {
  color: var(--c-coral);
}

.panel-status.tone-auto {
  color: var(--c-sky);
}

/* ------------------------------------------------------------------ players & bets */
.players-bets {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 8px;
  padding: var(--gap-lg);
  border-radius: var(--radius-md);
  background: var(--c-surface);
  border: 1px solid var(--c-line);
}

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

.players-title {
  font-size: var(--fs-sm);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.players-count {
  color: var(--c-brass-strong);
  font-size: var(--fs-xs);
}

.bets-columns,
.bet-row {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) minmax(0, 0.9fr) minmax(0, 1fr);
  gap: 6px;
  align-items: center;
}

.bets-columns {
  color: var(--c-muted);
  font-size: var(--fs-xs);
}

.bets-columns span:not(:first-child),
.bet-row > span:not(:first-child) {
  text-align: right;
}

.bets-list {
  min-height: 0;
  max-height: 60vh;
  overflow-y: auto;
  overscroll-behavior: contain;
}

@media (min-width: 1024px) {
  .bets-list {
    max-height: none;
  }
}

.bet-row,
.bets-empty {
  min-height: 32px;
  padding: 4px 2px;
  border-bottom: 1px solid var(--c-line);
  font-size: var(--fs-xs);
}

.bets-empty {
  color: var(--c-muted);
}

.bet-player {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.bet-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge {
  flex: none;
  min-width: 3.2ch;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.625rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-align: center;
}

.badge-sim {
  background: rgb(108 198 255 / 16%);
  color: var(--c-sky);
}

.badge-you {
  background: rgb(212 169 79 / 20%);
  color: var(--c-brass-strong);
}

.bet-row.is-you {
  background: rgb(212 169 79 / 7%);
}

.bet-row.tone-won > span:nth-child(3),
.bet-row.tone-won > span:nth-child(4) {
  color: var(--c-sea-green);
}

.bet-row.tone-lost {
  opacity: 0.5;
}

.players-totals {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 8px;
  padding-top: 6px;
  font-size: var(--fs-xs);
}

.players-totals dt {
  color: var(--c-muted);
}

.players-totals dd {
  text-align: right;
}

/* ------------------------------------------------------------------ desktop top row: history between badge and balance */
@media (min-width: 1024px) {
  .app-header {
    flex-wrap: nowrap;
  }

  .app-header .history-bar {
    order: 0;
    flex: 1 1 0;
  }

  .mode-badge {
    flex: none;
  }

  .mode-detail {
    display: none;
  }
}

@media (min-width: 1360px) {
  .mode-detail {
    display: inline;
  }
}

/* ------------------------------------------------------------------ narrow Players & Bets column: two-line rows */
.players-bets {
  container-type: inline-size;
}

@container (max-width: 279px) {
  .bets-columns,
  .bet-row {
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas:
      'player bet mult'
      'player bet win';
    row-gap: 0;
  }

  .bets-columns > :nth-child(1),
  .bet-row > :nth-child(1) {
    grid-area: player;
  }

  .bets-columns > :nth-child(2),
  .bet-row > :nth-child(2) {
    grid-area: bet;
  }

  .bets-columns > :nth-child(3),
  .bet-row > :nth-child(3) {
    grid-area: mult;
  }

  .bets-columns > :nth-child(4),
  .bet-row > :nth-child(4) {
    grid-area: win;
  }
}

/* ------------------------------------------------------------------ NEON OCEAN V3 / UI-1 refinements */
/* Deep-ocean scene placeholder (static: no animation, nothing hints at the outcome). */
.stage {
  background:
    radial-gradient(ellipse 70% 55% at 50% 38%, rgb(0 229 212 / 10%), transparent 70%),
    linear-gradient(180deg, #0b2236 0%, #0d2c45 52%, #0a2236 56%, #071a2a 100%);
}

/* The multiplier is the protagonist: very large, bright white, steady (no blinking or pulsing). */
.stage-multiplier {
  font-weight: 900;
  letter-spacing: -0.01em;
  color: #ffffff;
  text-shadow:
    0 0 28px rgb(0 229 212 / 28%),
    0 4px 24px rgb(0 0 0 / 55%);
}

.stage-title {
  font-size: var(--fs-sm);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--c-muted);
}

.tone-crashed .stage-title,
.tone-crashed .stage-multiplier {
  color: var(--c-coral);
  text-shadow: none;
}

/* History: compact chips, high-contrast band colour on text and border (the value itself carries the meaning). */
.history-chip {
  padding: 2px 10px;
  border: 1px solid currentcolor;
  background: rgb(9 23 37 / 85%);
  font-size: var(--fs-xs);
}

/* Players & Bets: always declared SIMULATED. */
.sim-tag {
  padding: 1px 6px;
  border: 1px solid var(--c-sky);
  border-radius: 4px;
  color: var(--c-sky);
  font-size: 0.625rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.players-head {
  flex-wrap: wrap;
}

/* Balance in virtual credits, clearly marked CR. */
.balance-value {
  color: var(--c-ivory);
}

.mode-badge {
  border-color: var(--c-brass);
  color: var(--c-brass-strong);
}

/* ------------------------------------------------------------------ S1: canvas scene in the existing slot */
.stage-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

/* Multiplier in the upper part of the scene (sky), so it stays large without covering the yacht. */
.stage-overlay {
  place-content: start center;
  padding-top: clamp(10px, 5%, 36px);
}

.stage-multiplier {
  text-shadow:
    0 0 2px rgb(4 12 24 / 90%),
    0 0 26px rgb(0 229 212 / 30%),
    0 6px 28px rgb(0 0 0 / 70%);
}

.stage-title,
.stage-countdown {
  text-shadow: 0 1px 6px rgb(0 0 0 / 80%);
}

/* ------------------------------------------------------------------ S2-P: cinematic preview label (that mode only) */
.preview-label {
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 2;
  padding: 3px 8px;
  border: 1px solid rgb(255 255 255 / 35%);
  border-radius: 4px;
  background: rgb(4 12 24 / 70%);
  color: #ffffff;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  pointer-events: none;
}
