/* =========================================================
   Arcade shell — shared by Tetris, Pong, Breakout, Pinball,
   Minesweeper, Poker and Solitaire.
   The page-specific bits live at the bottom of this file.
   ========================================================= */

.arcade {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: center;
  gap: clamp(0.9rem, 2.4vw, 1.8rem);
}

.arcade-stage {
  position: relative;
  flex: 0 1 auto;
}

.arcade-stage canvas {
  display: block;
  max-width: 100%;
  height: auto;
  margin-inline: auto;
  border-radius: 14px;
  background: #05070c;
  image-rendering: pixelated;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.08),
    0 18px 40px rgba(0, 0, 0, 0.5);
}

.arcade-side {
  display: grid;
  gap: 0.75rem;
  flex: 0 1 220px;
  min-width: 160px;
}

.arcade-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
}

.arcade-stat {
  padding: 0.45rem 0.65rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(0, 0, 0, 0.28);
}

/* 16-bit HUD: pixel-font labels over marquee-font numbers. */
.arcade-label {
  display: block;
  margin-bottom: 0.25rem;
  font-family: var(--pixel);
  font-size: 0.5rem;
  font-weight: 400;
  letter-spacing: 0.08em;
  line-height: 1.4;
  text-transform: uppercase;
  color: #cdf08a;
}

.felt--arcade .arcade-label {
  color: var(--cyan);
}

.arcade-value {
  display: block;
  font-family: var(--display);
  font-size: 1.15rem;
  line-height: 1.25;
  color: #fff;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.25);
}

.arcade-next {
  display: grid;
  justify-items: center;
  gap: 0.35rem;
  padding: 0.55rem;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(0, 0, 0, 0.28);
}

.arcade-next canvas {
  width: 120px;
  height: 90px;
  border-radius: 8px;
  background: #070910;
  image-rendering: pixelated;
}

.arcade-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.arcade-actions .btn {
  flex: 1 1 auto;
}

.arcade-hint {
  margin: 0;
  color: #d8e7bd;
  font-size: 0.82rem;
  line-height: 1.5;
}

.arcade-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1rem;
  text-align: center;
  border-radius: 14px;
  background: rgba(4, 6, 10, 0.74);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}

.arcade-overlay[hidden] {
  display: none;
}

.arcade-overlay p {
  margin: 0;
  max-width: 26ch;
  color: #fff;
  font-weight: 600;
  line-height: 1.5;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.9);
}

/* On-screen controls, for fingers rather than mice. */
.arcade-pad {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1.1rem;
}

.pad-btn {
  min-width: 54px;
  height: 48px;
  padding: 0 0.9rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

.pad-btn:hover {
  background: rgba(255, 255, 255, 0.14);
}

.pad-btn:active {
  background: rgba(255, 255, 255, 0.26);
}

@media (hover: hover) and (pointer: fine) {
  .arcade-pad {
    display: none;
  }
}

/* ---------- Stage sizes ---------- */
.stage-tetris {
  width: min(100%, 300px);
}

.stage-tetris canvas {
  width: auto;
  max-height: calc(100svh - 330px);
}

.stage-pong {
  flex: 1 1 380px;
  max-width: 620px;
}

.stage-pong canvas {
  width: 100%;
  touch-action: none;
}

.stage-breakout {
  width: min(100%, 440px);
}

.stage-breakout canvas {
  width: auto;
  max-height: calc(100svh - 330px);
  touch-action: none;
}

/* Breakout and Pong start with a click or tap on the board, so let it through the overlay. */
.stage-breakout .arcade-overlay,
.stage-pong .arcade-overlay {
  pointer-events: none;
}

/* A stat that spans both columns (Breakout's wave meter). */
.arcade-stat--wide {
  grid-column: 1 / -1;
}

.b-wave-btn {
  flex-basis: 100%;
}

.b-wave-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.b-wave-btn.is-ready {
  color: #10130a;
  border-color: transparent;
  background: var(--lime);
  box-shadow: 0 0 18px rgba(196, 222, 0, 0.55);
}

/* Pinball: a tall table, played by holding the board, so clicks pass the overlay. */
.stage-pinball {
  width: min(100%, 400px);
}

.stage-pinball canvas {
  width: auto;
  max-height: calc(100svh - 360px);
  min-height: 400px;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.stage-pinball .arcade-overlay,
.stage-mines .arcade-overlay {
  pointer-events: none;
}

/* Minesweeper: the board's natural width comes from JS (--mw). */
.stage-mines {
  width: min(100%, var(--mw, 288px));
}

.stage-mines canvas {
  width: 100%;
  image-rendering: auto;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* Segmented toggles (difficulty, draw count) and on/off buttons. */
.arcade-segment {
  display: flex;
  gap: 0.35rem;
}

.arcade-segment .btn {
  flex: 1 1 0;
  padding-inline: 0.5rem;
  font-size: 0.85rem;
}

.btn[aria-pressed="true"] {
  color: #10130a;
  border-color: transparent;
  background: var(--lime);
  box-shadow: 0 0 14px rgba(196, 222, 0, 0.4);
}

.btn[aria-pressed="true"]:hover {
  color: #10130a;
  background: #d4ef1a;
}

@media (max-width: 899px) {
  .arcade-side {
    flex: 1 1 100%;
    max-width: 420px;
  }

  .stage-tetris,
  .stage-breakout {
    max-height: none;
  }

  /* On phones and tablets the tall boards may use nearly the whole screen;
     scroll the board into view and the sidebar sits underneath. */
  .stage-breakout canvas,
  .stage-pinball canvas {
    max-height: calc(100svh - 120px);
  }
}

@media (max-width: 620px) {
  /* On phones, give the tap-heavy boards the full width of the panel. */
  .felt:has(.stage-mines),
  .felt:has(.stage-pinball),
  .felt:has(.stage-breakout) {
    padding-inline: 0.5rem;
  }
}

/* =========================================================
   Poker
   ========================================================= */
.poker-layout {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: clamp(1rem, 2.6vw, 1.8rem);
}

.poker-main {
  flex: 1 1 520px;
  min-width: 0;
}

.poker-aside {
  flex: 0 1 300px;
  display: grid;
  gap: 1rem;
}

.poker-hand {
  display: grid;
  /* Five columns, always: the cards shrink instead of wrapping. */
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: clamp(0.4rem, 1.4vw, 0.9rem);
  max-width: 620px;
  margin: 0.2rem auto 0;
}

.poker-slot {
  display: grid;
  justify-items: center;
  gap: 0.45rem;
  min-width: 0;
}

.poker-card {
  --cw: 100%;
  width: 100%;
  cursor: pointer;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.poker-card.is-held {
  box-shadow:
    0 0 0 3px var(--lime),
    0 0 22px rgba(196, 222, 0, 0.55),
    0 10px 20px rgba(0, 0, 0, 0.45);
  transform: translateY(-4px);
}

.poker-hold {
  padding: 0.3rem 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.32);
  color: #eaf5d2;
  font: inherit;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
}

.poker-hold:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.16);
}

.poker-hold:disabled {
  opacity: 0.4;
  cursor: default;
}

.poker-hold[aria-pressed="true"] {
  color: #10130a;
  border-color: transparent;
  background: var(--lime);
}

.poker-message {
  min-height: 1.6rem;
  margin: 1rem 0 0;
  color: #eef5da;
  font-weight: 600;
  text-align: center;
}

.poker-message.is-win {
  color: #eaffb0;
}

.poker-message.is-lose {
  color: #ffd1dd;
}

.poker-actions {
  margin-top: 0.9rem;
  justify-content: center;
}

.poker-actions .btn {
  flex: 0 1 auto;
}

.poker-paytable {
  width: 100%;
  border-collapse: collapse;
  border-radius: 12px;
  overflow: hidden;
  font-size: 0.85rem;
  color: #e9f5cf;
  background: rgba(0, 0, 0, 0.26);
}

.poker-paytable caption {
  padding: 0.45rem 0.6rem;
  color: #cdf08a;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-align: left;
  text-transform: uppercase;
}

.poker-paytable th,
.poker-paytable td {
  padding: 0.28rem 0.6rem;
  text-align: left;
  font-weight: 400;
}

.poker-paytable thead th {
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #a9cf6e;
}

.poker-paytable th:last-child,
.poker-paytable td:last-child {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.poker-paytable tbody tr + tr {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.poker-paytable tr.is-win {
  color: #10130a;
  background: var(--lime);
}

.poker-paytable tr.is-win th {
  font-weight: 700;
}

@media (max-width: 620px) {
  .poker-aside {
    flex: 1 1 100%;
  }

  .arcade-stat {
    padding: 0.35rem 0.5rem;
  }

  .arcade-value {
    font-size: 1.05rem;
  }
}
