.plinko-layout {
  grid-template-areas:
    "board controls"
    "feedback controls";
}

.stage-plinko.stage {
  grid-area: board;
  min-height: 0;
  border: 1px solid #3e3050;
  border-radius: 20px;
  background: radial-gradient(ellipse at 50% 8%, #342648 0, #211a2b 45%, #17131e 100%);
  box-shadow: inset 0 1px 0 #e6d4ff12, 0 8px 28px #100a173b;
  container: plinko / inline-size;
}

.plinko-layout #game-sidebar {
  grid-area: controls;
  border-radius: 20px;
  background: linear-gradient(155deg,#27202e,#1a1621 72%);
}
.plinko-layout #game-sidebar .play-primary {
  min-height: 46px;
  border: 1px solid #bc91f28c;
  border-radius: 12px;
  background: linear-gradient(#8a50c7,#6941a2);
  box-shadow: inset 0 1px 0 #fff2, 0 4px 12px #5d2d9e36;
  color: #fff;
}
.plinko-layout #game-sidebar .play-primary:hover:not(:disabled) { background: linear-gradient(#9b61d7,#7849b6); }
.plinko-layout #game-sidebar .play-primary:active:not(:disabled) { background: #7245a9; }
.plinko-layout .form #preview:empty { display:none; }
.plinko-layout .form .plinko-sound {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 36px;
  padding-top: 7px;
  border-top: 1px solid #fff1;
}
.plinko-sound input { width: 18px; height: 18px; accent-color: #b791ed; }

.plinko-board {
  max-width: 638px;
  margin-inline: auto;
  padding: clamp(8px, 2.15cqw, 19px);
}

.stage-plinko .plinko-board canvas {
  height: auto;
  aspect-ratio: 4 / 3;
}

.plinko-bins {
  display: flex;
  justify-content: center;
  margin-inline: clamp(5px, 1.8cqw, 14px);
}

.plinko-bin {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  min-height: clamp(18px, 4.65cqw, 27px);
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #2a2333;
  color: #c4b8d3;
  border-inline: 1px solid #191420;
  border-radius: 4px;
  font: 650 clamp(8px, 2.05cqw, 12px)/1 var(--mono);
  letter-spacing: -.035em;
  white-space: nowrap;
  transition: background .14s, color .14s, transform .14s;
}
.plinko-bin::before {
  content: "";
  position: absolute;
  top: 0;
  left: calc(50% - 3px);
  width: 6px;
  height: 2px;
  border-radius: 0 0 2px 2px;
  background: #15111d99;
  pointer-events: none;
}

.plinko-bin[data-tier="low"] { background: #3c2b55; color: #ede0fc; }
.plinko-bin[data-tier="mid"] { background: #674a86; color: #fff7ff; }
.plinko-bin[data-tier="high"] { background: #bd8af4; color: #241436; }
.plinko-bin.plinko-landed { background: #e3c7ff; color: #29163b; transform: translateY(-3px); box-shadow: 0 0 14px #c593fa86; }
.plinko-bin button {
  display: grid;
  place-items: center;
  inline-size: 100%;
  block-size: 100%;
  min-height: inherit;
  border: 0;
  border-radius: inherit;
  padding: 0;
  background: none;
  color: inherit;
}
.plinko-bin button:focus-visible, .plinko-bin button[aria-pressed="true"] {
  outline: 0;
  box-shadow: inset 0 0 0 2px #f0ddff, inset 0 0 0 3px #210e40;
}
.plinko-bin button:not(:disabled):hover { background: #fff2; }
.plinko-bin-short { display: none; }
.plinko-bin-detail {
  display: block;
  margin-top: 8px;
  padding: 6px 8px;
  border: 1px solid #b186d84a;
  border-radius: 8px;
  background: #b083e315;
  color: #ede1f9;
  font-size: 12px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

@container plinko (max-width: 455px) {
  .plinko-bin {
    font-size: clamp(7px, 2.15cqw, 9px);
    letter-spacing: -.05em;
  }
  .plinko-bin-full { display: none; }
  .plinko-bin-short { display: block; }
}

.plinko-feedback:not([hidden]) {
  grid-area: feedback;
  display: grid;
  gap: 8px;
  min-width: 0;
}

.plinko-feedback output { color: var(--muted); min-height: 1.15em; }
.plinko-feedback output:empty, .plinko-recent:empty { display: none; }
.plinko-recent { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; padding: 0; margin: 0; }
.plinko-recent .button { display: grid; gap: .15em; padding: .4em .65em; text-align: left; justify-items: start; }
.plinko-recent .button span { font: inherit; font-size: .81em; color: var(--muted); }
.plinko-recent .button[data-result="win"] strong { color: #d5ee9a; }
.plinko-recent .button[data-result="loss"] strong { color: #e0bc9e; }

@media (max-width: 900px) {
  .plinko-layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "board" "controls" "feedback";
  }
}

@media (prefers-reduced-motion: reduce) {
  .plinko-bin { transition: none; }
}
