body {
  font-family: Arial, sans-serif;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  margin: 0;
  background: radial-gradient(circle at top, #f7f7ff, #eef1f6);
  color: #111827;
}

/* Top pinned recreation banner */
.recreation-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  z-index: 1000;
  padding: 10px 12px;
  background: #111;
  color: #fff;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.3;
  text-align: center;
}

.recreation-banner__link {
  color: #7dd3fc;
  text-decoration: underline;
}

/* Make room for the pinned banner */
body {
  padding-top: 44px;
  box-sizing: border-box;
}

/* Mobile: banner becomes taller; adjust layout height + padding so content isn't clipped */
@media (max-width: 520px) {
  .recreation-banner {
    padding: 12px 10px;
    font-size: 13px;
    line-height: 1.35;
    white-space: normal;
    word-break: break-word;
  }

  body {
    /* ensure room for 2 lines of banner text on small screens */
    padding-top: 72px;
    height: auto;
    min-height: 100vh;
    align-items: flex-start;
    padding-bottom: 16px;
  }
}

/* --- 10-heads win explosion --- */
.win-explosion {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2000;
  opacity: 0;
}

.win-explosion.go {
  opacity: 1;
  animation: win-shake 0.9s ease-in-out 0s 1;
}

/* Win modal */
.win-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  z-index: 2500;
}

.win-modal.show {
  display: flex;
}

.win-modal__card {
  width: min(520px, 100%);
  border-radius: 18px;
  padding: 1.25rem 1.25rem 1rem 1.25rem;
  background: white;
  color: #111827;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.35);
  text-align: center;
}

.win-modal__title {
  font-size: 1.4rem;
  font-weight: 900;
  margin-bottom: 0.25rem;
}

.win-modal__subtitle {
  font-size: 1rem;
  font-weight: 700;
  color: #6b7280;
  margin-bottom: 1rem;
}

.win-modal__actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
}

@media (max-width: 520px) {
  .win-modal__card {
    padding: 1.05rem 1rem 0.9rem 1rem;
  }
}

@media (prefers-color-scheme: dark) {
  .win-modal__card {
    background: #0f172a;
    color: #f3f4f6;
    border: 1px solid #1f2937;
  }

  .win-modal__subtitle {
    color: #9ca3af;
  }
}

/* layered blasts */
.win-explosion.go::before,
.win-explosion.go::after {
  content: "";
  position: absolute;
  inset: -30vmax;
  background:
    radial-gradient(circle at 20% 30%, rgba(255, 0, 128, 0.75), rgba(255, 0, 128, 0) 55%),
    radial-gradient(circle at 80% 35%, rgba(0, 255, 234, 0.75), rgba(0, 255, 234, 0) 55%),
    radial-gradient(circle at 55% 75%, rgba(255, 230, 0, 0.75), rgba(255, 230, 0, 0) 55%),
    radial-gradient(circle at 30% 80%, rgba(96, 165, 250, 0.75), rgba(96, 165, 250, 0) 55%),
    radial-gradient(circle at 70% 60%, rgba(34, 197, 94, 0.65), rgba(34, 197, 94, 0) 55%);
  mix-blend-mode: screen;
  filter: blur(0px) saturate(1.2);
  transform: scale(0.2) rotate(-12deg);
  opacity: 0;
}

.win-explosion.go::before {
  animation: win-burst 1.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.win-explosion.go::after {
  animation: win-burst2 1.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes win-burst {
  0% {
    opacity: 0;
    transform: scale(0.2) rotate(-18deg);
    filter: blur(6px) saturate(1.1);
  }
  20% {
    opacity: 1;
    filter: blur(1px) saturate(1.5);
  }
  60% {
    opacity: 0.95;
    transform: scale(1.05) rotate(8deg);
    filter: blur(0px) saturate(1.8);
  }
  100% {
    opacity: 0;
    transform: scale(1.25) rotate(14deg);
    filter: blur(2px) saturate(1.2);
  }
}

@keyframes win-burst2 {
  0% {
    opacity: 0;
    transform: scale(0.15) rotate(22deg);
    filter: blur(10px) saturate(1.2);
  }
  25% {
    opacity: 0.9;
    filter: blur(2px) saturate(2);
  }
  65% {
    opacity: 0.85;
    transform: scale(1.15) rotate(-6deg);
    filter: blur(0px) saturate(2.2);
  }
  100% {
    opacity: 0;
    transform: scale(1.45) rotate(-14deg);
    filter: blur(3px) saturate(1.4);
  }
}

@keyframes win-shake {
  0% { transform: translate3d(0,0,0); }
  10% { transform: translate3d(-3px, 2px, 0); }
  20% { transform: translate3d(4px, -2px, 0); }
  30% { transform: translate3d(-5px, 3px, 0); }
  40% { transform: translate3d(5px, -3px, 0); }
  50% { transform: translate3d(-4px, 2px, 0); }
  60% { transform: translate3d(3px, -2px, 0); }
  70% { transform: translate3d(-2px, 1px, 0); }
  80% { transform: translate3d(2px, -1px, 0); }
  90% { transform: translate3d(-1px, 1px, 0); }
  100% { transform: translate3d(0,0,0); }
}

@media (prefers-reduced-motion: reduce) {
  .win-explosion.go {
    animation: none;
  }
  .win-explosion.go::before,
  .win-explosion.go::after {
    animation: none;
    opacity: 0;
  }
}

main {
  text-align: center;
  background-color: white;
  padding: 2rem;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  width: min(980px, calc(100vw - 2rem));
  position: relative;
}

.layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 1.25rem;
  align-items: stretch;
  text-align: left;
}

.panel {
  text-align: center;
  position: relative;
}

.tray {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: 70vh;
  min-height: 420px;
}

.tray-header {
  padding: 0.9rem 1rem;
  background: rgba(17, 24, 39, 0.04);
  border-bottom: 1px solid #e5e7eb;
  text-align: left;
}

.tray-title {
  font-weight: 800;
  color: #111827;
}

.tray-subtitle {
  margin-top: 0.2rem;
  font-size: 0.85rem;
  color: #6b7280;
}

.tray-log {
  padding: 0.9rem 0.9rem 1rem 0.9rem;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  justify-content: flex-end;
  flex: 1 1 auto;
}

.log-line {
  width: fit-content;
  max-width: 100%;
  background: white;
  border: 1px solid rgba(229, 231, 235, 1);
  border-radius: 14px;
  padding: 0.55rem 0.7rem;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
  font-weight: 700;
  color: #111827;
  text-align: left;
}

.log-line.heads {
  border-color: rgba(37, 99, 235, 0.25);
}

.log-line.tails {
  border-color: rgba(5, 150, 105, 0.25);
}

/* Shop purchase entries in the log (right-aligned blue bubble) */
.log-line.shop {
  margin-left: auto;
  background: rgba(37, 99, 235, 0.12);
  border-color: rgba(37, 99, 235, 0.35);
  color: #1d4ed8;
  text-align: right;
}

h1 {
  margin: 0 0 0.25rem 0;
  color: #1f2937;
}

.subtitle {
  margin: 0 0 1.5rem 0;
  color: #6b7280;
}

.coin {
  width: 180px;
  height: 180px;
  border-radius: 999px;
  margin: 0 auto 1.25rem auto;
  position: relative;
  user-select: none;
  perspective: 900px;
}

.coin-inner {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  border-radius: 999px;
}

/* Ensure the correct face is visible after the flip animation completes.
   Without this, the coin can land showing the "front" face even when the
   outcome is tails, because the animation ends at a full rotation. */
.coin[data-side="heads"] .coin-inner {
  transform: rotateY(0deg);
}

.coin[data-side="tails"] .coin-inner {
  transform: rotateY(180deg);
}

.coin-side {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  display: grid;
  place-items: center;
  backface-visibility: hidden;
  box-shadow: inset 0 2px 6px rgba(255, 255, 255, 0.35),
    inset 0 -6px 16px rgba(0, 0, 0, 0.25), 0 10px 25px rgba(0, 0, 0, 0.12);
}

.coin-side::after {
  content: "";
  position: absolute;
  inset: 14px;
  border-radius: 999px;
  border: 3px dashed rgba(255, 255, 255, 0.35);
}

.coin-front {
  background: linear-gradient(145deg, #7dd3fc, #2563eb);
}

.coin-back {
  background: linear-gradient(145deg, #a7f3d0, #059669);
  transform: rotateY(180deg);
}

.coin-burst {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  font-weight: 900;
  font-size: 2.25rem;
  letter-spacing: 0.02em;
  z-index: 5;
  text-shadow: 0 8px 22px rgba(0, 0, 0, 0.25);
  opacity: 0;
}

.coin-burst.show {
  animation: burst 0.85s ease-out forwards;
}

@keyframes burst {
  0% {
    transform: translate(-50%, -50%) scale(0.2) rotate(-8deg);
    opacity: 0;
    filter: blur(2px);
  }
  15% {
    opacity: 1;
    filter: blur(0px);
  }
  55% {
    transform: translate(-50%, -65%) scale(1.25) rotate(6deg);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -95%) scale(1.05) rotate(0deg);
    opacity: 0;
  }
}

/* Earned money burst over the Cash stat */
.cash-value {
  position: relative;
  display: inline-block;
}

.cash-bursts {
  position: absolute;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
}

.cash-burst {
  position: absolute;
  left: 50%;
  top: -0.25rem;
  transform: translate(-50%, 0);
  pointer-events: none;
  font-weight: 900;
  font-size: 1.35rem;
  letter-spacing: 0.02em;
  z-index: 5;
  text-shadow: 0 8px 22px rgba(0, 0, 0, 0.25);
  color: #22c55e;
  opacity: 0;
  white-space: nowrap;
}

.cash-burst.show {
  /* slight stagger so multiple bursts don't sit perfectly on top of each other */
  --x: 0px;
  animation: cash-burst 0.85s ease-out forwards;
}

@keyframes cash-burst {
  0% {
    transform: translate(calc(-50% + var(--x)), 10px) scale(0.2) rotate(-8deg);
    opacity: 0;
    filter: blur(2px);
  }
  15% {
    opacity: 1;
    filter: blur(0px);
  }
  55% {
    transform: translate(calc(-50% + var(--x)), -14px) scale(1.1) rotate(6deg);
    opacity: 1;
  }
  100% {
    transform: translate(calc(-50% + var(--x)), -34px) scale(1.0) rotate(0deg);
    opacity: 0;
  }
}

.coin-burst.money {
  background: linear-gradient(90deg, #fbbf24, #22c55e, #60a5fa);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.face {
  font-weight: 800;
  font-size: 4rem;
  color: rgba(255, 255, 255, 0.95);
  letter-spacing: 0.05em;
  text-shadow: 0 8px 22px rgba(0, 0, 0, 0.25);
}

.result {
  position: absolute;
  bottom: -0.75rem;
  background: #111827;
  color: white;
  font-size: 0.9rem;
  padding: 0.35rem 0.6rem;
  border-radius: 999px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18);
}

.coin.flipping {
  animation: coin-pop var(--flip-duration, 0.65s) ease-in-out;
}

@keyframes coin-pop {
  0% {
    transform: translateY(0px) rotateX(0deg) scale(1);
  }
  35% {
    transform: translateY(-120px) rotateX(20deg) scale(1.05);
  }
  100% {
    transform: translateY(0px) rotateX(0deg) scale(1);
  }
}

.coin.flipping .coin-inner {
  animation: coin-spin var(--flip-duration, 0.65s) linear;
}

@keyframes coin-spin {
  0% {
    transform: rotateY(0deg);
  }
  100% {
    transform: rotateY(1440deg);
  }
}

.controls {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.reset-link {
  position: absolute;
  top: 0.9rem;
  right: 1rem;
  font-size: 0.95rem;
  color: #6b7280;
  text-decoration: underline;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}

.reset-link:hover {
  color: #374151;
}

.reset-link:focus {
  outline: 2px solid rgba(37, 99, 235, 0.6);
  outline-offset: 3px;
  border-radius: 6px;
}

button {
  touch-action: manipulation;
  font-size: 1rem;
  padding: 0.75rem 1.1rem;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: background-color 0.2s;
  -webkit-user-select: none;
  user-select: none;
}

.primary {
  background-color: #2563eb;
  color: #fff;
}

.primary:hover {
  background-color: #1d4ed8;
}

.secondary {
  background-color: #e5e7eb;
  color: #111827;
}

.secondary:hover {
  background-color: #d1d5db;
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-top: 0.25rem;
}

.shop {
  margin-top: 1rem;
  text-align: left;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  overflow: hidden;
}

.shop-header {
  padding: 0.9rem 1rem;
  background: rgba(17, 24, 39, 0.04);
  border-bottom: 1px solid #e5e7eb;
}

.shop-title {
  font-weight: 800;
  color: #111827;
}

.shop-subtitle {
  margin-top: 0.2rem;
  font-size: 0.85rem;
  color: #6b7280;
}

.shop-items {
  display: grid;
  gap: 0.65rem;
  padding: 0.9rem;
}

.shop-item {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.75rem 0.85rem;
  border-radius: 14px;
  border: 1px solid #e5e7eb;
  background: white;
  cursor: pointer;
  text-align: left;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.04);
}

.shop-item:hover {
  border-color: rgba(37, 99, 235, 0.35);
}

.shop-item:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.shop-item-name {
  font-weight: 800;
  color: #111827;
}

.shop-item-desc {
  margin-top: 0.2rem;
  font-size: 0.85rem;
  color: #6b7280;
  font-weight: 600;
}

.price {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem 0.55rem;
  border-radius: 999px;
  background: #111827;
  color: white;
  font-weight: 800;
  font-size: 0.9rem;
  white-space: nowrap;
}

/* Hide empty price pill when an upgrade is maxed (we set textContent to '') */
.price:empty {
  display: none;
}

@media (max-width: 520px) {
  .stats {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 920px) {
  main {
    width: min(720px, calc(100vw - 2rem));
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .tray {
    height: 40vh;
    min-height: 260px;
  }
}

.odds {
  margin: 0.25rem 0 1rem 0;
  padding: 0.75rem;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  text-align: left;
}

.odds-row {
  display: grid;
  grid-template-columns: 1fr 120px auto;
  gap: 0.5rem;
  align-items: center;
}

.odds label {
  color: #111827;
  font-weight: 600;
  font-size: 0.95rem;
}

.odds input {
  width: 100%;
  padding: 0.5rem 0.6rem;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  font-size: 1rem;
}

.odds .unit {
  color: #6b7280;
  font-size: 0.9rem;
  white-space: nowrap;
}

.odds-help {
  margin: 0.5rem 0 0 0;
  color: #6b7280;
  font-size: 0.9rem;
}

.odds-current {
  margin-top: 0.5rem;
  color: #111827;
  font-size: 0.95rem;
}

.stat {
  background: #f3f4f6;
  border-radius: 10px;
  padding: 0.75rem 0.5rem;
}

.label {
  color: #6b7280;
  font-size: 0.85rem;
}

.value {
  color: #111827;
  font-weight: 800;
  font-size: 1.4rem;
}

/* Dark mode (system) */
@media (prefers-color-scheme: dark) {
  body {
    background: radial-gradient(circle at top, #0b1220, #060913);
    color: #e5e7eb;
  }

  main {
    background-color: #0f172a;
    box-shadow: 0 2px 18px rgba(0, 0, 0, 0.55);
  }

  .tray {
    background: #0b1220;
    border-color: #1f2937;
  }

  .tray-header {
    background: rgba(255, 255, 255, 0.03);
    border-bottom-color: #1f2937;
  }

  .tray-title {
    color: #f3f4f6;
  }

  .tray-subtitle {
    color: #9ca3af;
  }

  .log-line {
    background: #0f172a;
    border-color: #1f2937;
    color: #f3f4f6;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  }

  .coin-burst {
    text-shadow: 0 10px 24px rgba(0, 0, 0, 0.55);
  }

  h1 {
    color: #f3f4f6;
  }

  .subtitle {
    color: #9ca3af;
  }

  .reset-link {
    color: #9ca3af;
  }

  .reset-link:hover {
    color: #e5e7eb;
  }

  .result {
    background: #111827;
    color: #f9fafb;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.55);
  }

  .secondary {
    background-color: #1f2937;
    color: #f3f4f6;
  }

  .secondary:hover {
    background-color: #111827;
  }

  .odds {
    background: #0b1220;
    border-color: #1f2937;
  }

  .odds label,
  .odds-current {
    color: #f3f4f6;
  }

  .odds-help,
  .odds .unit {
    color: #9ca3af;
  }

  .odds input {
    background: #0f172a;
    border-color: #334155;
    color: #f3f4f6;
  }

  .stat {
    background: #111827;
  }

  .label {
    color: #9ca3af;
  }

  .value {
    color: #f3f4f6;
  }

  .shop {
    background: #0b1220;
    border-color: #1f2937;
  }

  .shop-header {
    background: rgba(255, 255, 255, 0.03);
    border-bottom-color: #1f2937;
  }

  .shop-title {
    color: #f3f4f6;
  }

  .shop-subtitle {
    color: #9ca3af;
  }

  .shop-item {
    background: #0f172a;
    border-color: #1f2937;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
  }

  .shop-item:hover {
    border-color: rgba(96, 165, 250, 0.45);
  }

  .shop-item-name {
    color: #f3f4f6;
  }

  .shop-item-desc {
    color: #9ca3af;
  }

  .price {
    background: #111827;
    color: #f9fafb;
  }
}
