.plinko-layout {
  min-height: clamp(580px, calc(100vh - 36px), 840px);
  width: min(1320px, calc(100vw - 28px));
  padding: 10px;
  gap: 10px;
  border: 0;
  border-radius: 16px;
  background: #121731;
  box-shadow: none;
}

.plinko-left-rail {
  gap: 16px;
  background: #1f2546;
  border: 0;
  border-radius: 14px;
}

.mode-toggle {
  border: 0;
  border-radius: 12px;
  background: #121731;
  padding: 4px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
}

.mode-btn {
  min-height: 42px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #a4aac6;
  font-family: inherit;
  font-size: 1.02rem;
  font-weight: 700;
  cursor: pointer;
}

.mode-btn.is-active {
  background: #283599;
  color: #eef2ff;
}

.mode-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.plinko-balance-text {
  font-size: 1.06rem;
  color: #a4aac6;
  font-family: "Consolas", "SFMono-Regular", Menlo, monospace;
}

.plinko-left-rail .spin-btn {
  border: 0;
  background: #283599;
  color: #ffffff;
  box-shadow: none;
}

.plinko-left-rail .bet-pill {
  border: 0;
  background: #121731;
  box-shadow: none;
}

.plinko-left-rail .mini-btn {
  border: 0;
  background: #343c64;
  color: #ffffff;
}

.plinko-left-rail .risk-toggle {
  border: 0;
  background: #121731;
  padding: 4px;
}

.plinko-left-rail .risk-btn {
  color: #a4aac6;
}

.plinko-left-rail .risk-btn.is-active {
  background: #283599;
  color: #eef2ff;
}

.plinko-right-rail {
  --plinko-board-width: min(80%, 760px);
  background: #121731;
  border: 0;
  border-radius: 14px;
  padding: 10px 22px 8px;
}

.plinko-stage {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  justify-items: center;
  gap: 8px;
}

.plinko-stage-header {
  min-height: 20px;
  width: var(--plinko-board-width);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.plinko-speed-toggle {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 8px;
  background: #1f2546;
  color: #ffffff;
  font-size: 1.08rem;
  line-height: 1;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.plinko-speed-toggle svg {
  width: 16px;
  height: 16px;
  color: #ffffff;
}

.plinko-speed-toggle.is-fast {
  background: #283599;
}

.plinko-speed-toggle:not(.is-fast) {
  background: #1f2546;
}

.plinko-history-rail {
  margin-left: auto;
  min-height: 30px;
  max-width: min(520px, 74%);
  display: flex;
  flex-direction: row-reverse;
  justify-content: flex-start;
  gap: 4px;
  align-items: center;
  overflow: hidden;
}

.plinko-history-chip {
  --chip-bg: #7f6124;
  --chip-fg: #121731;
  height: 30px;
  min-width: 46px;
  padding: 0 10px;
  border-radius: 8px;
  background: var(--chip-bg);
  color: var(--chip-fg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: "Consolas", "SFMono-Regular", Menlo, monospace;
  font-size: 0.9rem;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
}

.plinko-history-chip.is-enter {
  animation: history-enter 210ms ease-out 1;
}

.plinko-history-chip.is-exit {
  animation: history-exit 220ms ease-in 1 forwards;
}

@keyframes history-enter {
  0% {
    opacity: 0;
    transform: translateX(14px);
  }
  100% {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes history-exit {
  0% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateX(-10px);
  }
}

.plinko-board {
  position: relative;
  width: var(--plinko-board-width);
  height: clamp(330px, calc(100vh - 315px), 550px);
  min-height: 330px;
  margin: 0 auto;
  border: 0;
  border-radius: 12px;
  background: #121731;
  overflow: hidden;
}

.peg-layer,
.trail-layer,
.bucket-layer {
  position: absolute;
  inset: 0;
}

.trail-layer {
  pointer-events: none;
}

.peg {
  position: absolute;
  width: 8px;
  height: 8px;
  margin-left: -4px;
  margin-top: -4px;
  border-radius: 50%;
  background: #767faa;
  opacity: 0.92;
}

.drop-ball {
  position: absolute;
  width: 14px;
  height: 14px;
  margin-left: -7px;
  margin-top: -7px;
  border-radius: 50%;
  background: #dbe7fb;
  z-index: 6;
  will-change: left, top;
}

.peg-hit {
  position: absolute;
  width: 10px;
  height: 10px;
  margin-left: -5px;
  margin-top: -5px;
  border-radius: 50%;
  background: rgba(205, 219, 255, 0.9);
  box-shadow: 0 0 0 0 rgba(156, 183, 255, 0.5);
  pointer-events: none;
  z-index: 5;
  animation: peg-hit-pulse 360ms ease-out forwards;
}

@keyframes peg-hit-pulse {
  0% {
    opacity: 0.95;
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(156, 183, 255, 0.45);
  }
  100% {
    opacity: 0;
    transform: scale(2);
    box-shadow: 0 0 0 12px rgba(156, 183, 255, 0);
  }
}

.bucket-btn {
  --bucket-heat: 0;
  --bucket-hue: calc(44 - (58 * var(--bucket-heat)));
  position: absolute;
  transform: translate(-50%, -50%);
  border: 0;
  border-radius: 5px;
  background: #343c64;
  color: #d7e2f5;
  font-family: "Consolas", "SFMono-Regular", Menlo, monospace;
  font-size: 0.71rem;
  font-weight: 900;
  line-height: 1;
  padding: 0 3px;
  cursor: pointer;
  transition: transform 110ms ease, filter 110ms ease;
}

.bucket-btn.is-on {
  background: hsl(var(--bucket-hue) 88% 52%);
  color: #192132;
}

.bucket-btn:hover:not(:disabled) {
  transform: translate(-50%, -52%);
  filter: brightness(1.03);
}

.bucket-btn.is-hit {
  box-shadow: 0 0 0 2px rgba(255, 218, 127, 0.33);
}

.bucket-btn.is-miss {
  box-shadow: 0 0 0 2px rgba(227, 131, 131, 0.3);
}

.bucket-btn.is-impact {
  animation: bucket-impact 300ms cubic-bezier(0.2, 0.85, 0.25, 1) 1;
}

@keyframes bucket-impact {
  0% {
    transform: translate(-50%, -50%);
  }
  30% {
    transform: translate(-50%, -43%);
  }
  62% {
    transform: translate(-50%, -54%);
  }
  100% {
    transform: translate(-50%, -50%);
  }
}

.plinko-footer-row {
  min-height: 30px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 2px 2px 0;
}

.plinko-foot-pill {
  border: 0;
  border-radius: 999px;
  background: #1f2546;
  color: #a4aac6;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 5px 12px;
}

.plinko-foot-btn {
  font-family: inherit;
  cursor: pointer;
}

.plinko-foot-btn[aria-expanded="true"] {
  color: #eef2ff;
  background: #283599;
}

.plinko-fair-panel {
  position: fixed;
  right: 16px;
  bottom: 14px;
  z-index: 30;
}

.plinko-fair-card {
  width: min(340px, calc(100vw - 28px));
  border: 0;
  border-radius: 12px;
  background: #1f2546;
  box-shadow: 0 16px 30px rgba(0, 0, 0, 0.34);
  padding: 12px;
  display: grid;
  gap: 8px;
}

.fair-title-row strong {
  font-size: 1.02rem;
}

.fair-seed-input {
  min-height: 40px;
  border: 0;
  border-radius: 10px;
  background: #121731;
  color: #e8edff;
  font-family: "Consolas", "SFMono-Regular", Menlo, monospace;
  font-size: 0.9rem;
  padding: 0 10px;
  outline: none;
}

.fair-seed-input:focus-visible {
  box-shadow: 0 0 0 2px rgba(156, 178, 217, 0.35);
}

.fair-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.fair-line {
  margin: 0;
  color: var(--text-dim);
  font-size: 0.72rem;
  line-height: 1.3;
}

.fair-line code {
  color: #d9e2ff;
}

@media (max-width: 980px) {
  .plinko-layout {
    min-height: auto;
  }

  .plinko-right-rail {
    --plinko-board-width: min(90%, 760px);
  }

  .plinko-board {
    height: clamp(320px, 54vh, 540px);
  }
}

@media (max-width: 760px) {
  .plinko-right-rail {
    --plinko-board-width: min(96%, 690px);
    padding: 10px 12px 8px;
  }

  .plinko-board {
    height: clamp(310px, 50vh, 500px);
  }

  .plinko-footer-row {
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .plinko-history-rail {
    max-width: min(62vw, 420px);
  }

  .fair-actions {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 390px) {
  .plinko-balance-text {
    font-size: 0.96rem;
  }

  .plinko-foot-pill {
    font-size: 0.68rem;
    padding: 4px 8px;
  }
}
