.games-shell { width: min(calc(100% - (var(--page-padding) * 2)), 1280px); min-height: calc(100svh - var(--header-h)); margin-inline: auto; padding: clamp(48px, 7vw, 88px) 0 100px; }
.games-heading { margin-bottom: 22px; }
.games-heading h1 { margin: 0; font-size: clamp(2.8rem, 5.4vw, 5.6rem); line-height: .96; letter-spacing: -.065em; }
.game-library { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: 24px; }
.game-cover-card { max-width: 520px; border: 1px solid var(--line); background: rgba(255,255,255,.025); transition: transform .25s ease, border-color .25s ease, background .25s ease; }
.game-cover-card:hover { transform: translateY(-5px); border-color: color-mix(in srgb, var(--active) 65%, var(--line)); background: color-mix(in srgb, var(--active) 8%, var(--surface)); }
.game-cover-media { position: relative; overflow: hidden; aspect-ratio: 16 / 10; background: repeating-linear-gradient(90deg, transparent 0 15%, rgba(255,255,255,.045) 15% 16%), linear-gradient(145deg, #341315, #110e0d 60%, #283012); isolation: isolate; }
.game-cover-media::before { content: ""; position: absolute; z-index: -1; inset: 12% 8%; background: repeating-linear-gradient(0deg, var(--redbean) 0 23px, transparent 23px 34px); opacity: .65; transform: skewY(-5deg); }
.game-cover-media span { position: absolute; z-index: 2; left: 25px; top: 22px; color: var(--cream); font: 400 clamp(1.5rem, 3vw, 2.7rem)/.9 var(--display); letter-spacing: -.04em; text-shadow: 0 4px 20px rgba(0,0,0,.5); }
.game-cover-media img { position: absolute; z-index: 2; right: 7%; bottom: 4%; width: 38%; height: auto; max-width: none; object-fit: contain; object-position: center; filter: drop-shadow(0 18px 22px rgba(0,0,0,.45)); transform: rotate(8deg); transition: transform .3s ease; }
.game-cover-card:hover .game-cover-media img { transform: translateY(-5px) rotate(4deg) scale(1.04); }
.game-cover-media--amusement { background: radial-gradient(circle at 78% 24%, rgba(255,241,176,.45) 0 7%, transparent 7.5%), repeating-linear-gradient(135deg, transparent 0 34px, rgba(255,255,255,.08) 34px 36px), linear-gradient(145deg, #476f4d, #1d372d 58%, #7c3e53); }
.game-cover-media--amusement::before { inset: auto 6% 8% 6%; height: 42%; border-radius: 50% 50% 0 0; background: repeating-radial-gradient(circle at 50% 100%, rgba(244,199,91,.62) 0 8px, transparent 9px 24px); opacity: .78; transform: none; }
.game-cover-media--amusement img { right: -1%; bottom: -3%; width: 67%; height: auto; aspect-ratio: 720 / 514; object-fit: contain; transform: none; image-rendering: pixelated; }
.game-cover-card:hover .game-cover-media--amusement img { transform: translateY(-5px) scale(1.025); }
.game-cover-media--dadidou { background: radial-gradient(circle at 72% 42%, rgba(255,255,255,.94), rgba(236,234,226,.72) 29%, transparent 30%), linear-gradient(145deg, #d8d4c9, #8f918d 58%, #303330); }
.game-cover-media--dadidou::before { inset: 12% 7%; background: repeating-linear-gradient(172deg, transparent 0 26px, rgba(20,20,18,.16) 27px 29px), radial-gradient(ellipse at 42% 72%, rgba(20,20,18,.28), transparent 46%); opacity: .74; transform: none; }
.game-cover-media--dadidou img { right: -2%; bottom: -17%; width: 61%; height: auto; transform: rotate(-3deg); filter: grayscale(1) contrast(1.12) drop-shadow(0 15px 18px rgba(0,0,0,.3)); }
.game-cover-card:hover .game-cover-media--dadidou img { transform: translateY(-5px) rotate(-1deg) scale(1.025); }
.game-cover-info { min-height: 116px; padding: 22px 24px; display: flex; align-items: end; justify-content: space-between; gap: 20px; }
.game-cover-info small { color: var(--active-soft); font: 400 .68rem var(--display); letter-spacing: .12em; }
.game-cover-info h2 { margin: 8px 0 0; font-size: 1.55rem; }
.game-cover-info h2 small { display:block; margin-top:5px; color:var(--faint); font:500 .62rem/1.2 var(--sans); }
.game-cover-info > b { color: var(--active-soft); font-size: .78rem; white-space: nowrap; }
.game-cover-info > b small,.games-back small { display:block; margin-top:3px; font-size:.56rem; font-weight:500; opacity:.72; }

.game-shell { width: min(calc(100% - (var(--page-padding) * 2)), 1280px); min-height: calc(100svh - var(--header-h)); margin-inline: auto; padding: 12px 0 70px; }
.games-back { display: inline-block; margin-bottom: 8px; color: var(--muted); font-size: .76rem; line-height: 1.25; }
.games-back:hover { color: var(--ink); }
.game-heading { margin-bottom: 22px; }
.game-eyebrow { margin: 0; color: var(--active-soft); font-size: .8rem; font-weight: 700; line-height: 1; letter-spacing: .18em; }
.game-heading h1 { margin: 0; font: 900 clamp(2.4rem, 4.4vw, 4.6rem)/.94 var(--sans); letter-spacing: -.05em; }
.game-heading h1 span { display: block; margin-top: 19px; color: transparent; -webkit-text-stroke: 1px rgba(255,255,255,.38); font: 400 .34em/1 var(--display); letter-spacing: .06em; }
.game-board-wrap { position: relative; min-width: 0; overflow: hidden; border: 1px solid var(--line); background: #090713; box-shadow: 0 35px 100px rgba(0,0,0,.34); }
#breakout-game { width: 100%; height: auto; aspect-ratio: 24 / 17; display: block; touch-action: none; cursor: ew-resize; }
.game-overlay { position: absolute; z-index: 3; inset: 0; padding: 30px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; background: rgba(9,7,19,.64); backdrop-filter: blur(7px); }
.game-overlay > p:first-child { margin: 0 0 10px; color: var(--active-soft); font: 400 .76rem var(--display); letter-spacing: .2em; }
.game-overlay h2 { margin: 0; font-size: clamp(2rem, 5vw, 4.8rem); line-height: 1; letter-spacing: -.06em; }
.game-overlay h2 small { display:block; margin-top:9px; color:var(--muted); font-size:.22em; font-weight:500; letter-spacing:.04em; }
.game-overlay h2 + p { margin: 19px 0 0; color: #c9c3d1; font-size: .95rem; }
.game-overlay h2 + p small { display:block; margin-top:5px; color:var(--faint); font-size:.72rem; }
.game-overlay button { min-width: 210px; min-height: 56px; margin-top: 28px; padding: 0 18px; display: flex; align-items: center; justify-content: space-between; border: 0; color: var(--on-active); background: var(--active); cursor: pointer; font-weight: 900; transition: transform .2s ease, box-shadow .2s ease; }
.game-overlay button small,.game-status small { display:block; margin-top:3px; font-size:.58rem; font-weight:500; opacity:.72; }
.game-overlay button:hover { transform: translateY(-3px); box-shadow: 0 15px 40px color-mix(in srgb, var(--active) 30%, transparent); }
.game-status { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }

@media (max-width: 768px) {
  .games-shell { padding: 32px 0 64px; }
  .games-heading { margin-bottom: 24px; }
  .games-heading h1 { font-size: clamp(2.4rem, 12vw, 3.5rem); }
  .game-cover-info { min-height: 104px; padding: 19px 20px; }
  .game-shell { padding: 32px 0 64px; }
  .game-heading h1 { font-size: clamp(2.5rem, 12vw, 3.7rem); }
  .game-overlay { padding: 20px; }
  .game-overlay h2 + p { max-width: 250px; font-size: .82rem; }
  .game-overlay button { min-width: 175px; min-height: 48px; margin-top: 20px; }
}

@media (max-width: 480px) {
  .game-cover-info { align-items: flex-start; flex-direction: column; gap: 16px; }
}

/* Redbean breakout: the canvas owns its own responsive layout and controls. */
.game-shell .game-layout { display: block; }
.game-shell .game-board-wrap { width: min(900px, 100%); margin-inline: auto; aspect-ratio: 3 / 2; border-radius: 12px; }
.game-shell #breakout-game { width: 100%; height: 100%; aspect-ratio: auto; user-select: none; -webkit-user-select: none; }
.breakout-game .game-hud { position: absolute; z-index: 2; inset: 0 0 auto; min-height: 64px; padding: 10px 14px; display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 16px; border-bottom: 1px solid rgba(255,255,255,.12); color: var(--ink); background: linear-gradient(180deg, rgba(9,7,19,.94), rgba(9,7,19,.72)); pointer-events: none; }
.breakout-game .game-hud-title { display: grid; gap: 2px; min-width: 0; }
.breakout-game .game-hud-title span { font-size: 1rem; font-weight: 900; letter-spacing: -.03em; white-space: nowrap; }
.breakout-game .game-hud-title small { color: var(--active-soft); font: 400 .55rem/1 var(--display); letter-spacing: .12em; }
.breakout-game .game-hud-stats { display: flex; align-items: center; gap: 14px; color: var(--faint); font: 400 .6rem/1 var(--display); letter-spacing: .08em; white-space: nowrap; }
.breakout-game .game-hud-stats b { margin-left: 4px; color: var(--ink); font-size: .84rem; letter-spacing: .05em; }
.breakout-game .game-hud-stats span > small { display:block; margin-bottom:3px; color:var(--faint); font:500 .48rem/1 var(--sans); letter-spacing:0; }
.breakout-game .game-hud-stats .hud-life { color: var(--active-soft); font: 700 .8rem/1 var(--sans); letter-spacing: 0; }
.breakout-game .game-hud-stats .hud-life b { color: var(--active-soft); font-size: .8rem; letter-spacing: .1em; }
.breakout-game .game-hud-actions { display: flex; align-items: center; gap: 7px; pointer-events: auto; }
.breakout-game .hud-icon-button, .breakout-game .hud-reset-button { min-height: 34px; border: 1px solid var(--line); color: var(--ink); background: rgba(255,255,255,.06); cursor: pointer; font-weight: 900; }
.breakout-game .hud-icon-button { width: 36px; height: 36px; min-height: 0; padding: 0; display: grid; place-items: center; color: rgba(238,232,216,.88); border-color: rgba(238,232,216,.2); border-radius: 7px; background: rgba(0,0,0,.24); box-shadow: inset 0 1px rgba(255,255,255,.08); transition: transform .12s ease, color .12s ease, background .12s ease; }
.breakout-game .hud-icon-button:active { transform: translateY(1px) scale(.97); }
.breakout-game .hud-icon-button:disabled { opacity: .38; cursor: default; }
.breakout-game .hud-icon-button svg { width: 20px; height: 20px; fill: currentColor; }
.breakout-game .hud-icon-button .sound-wave, .breakout-game .hud-icon-button .sound-slash { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.breakout-game .hud-icon-button .sound-slash, .breakout-game .hud-icon-button .play-mark { display: none; }
.breakout-game .hud-icon-button.is-muted .sound-wave, .breakout-game .hud-icon-button.is-resume .pause-bars { display: none; }
.breakout-game .hud-icon-button.is-muted .sound-slash, .breakout-game .hud-icon-button.is-resume .play-mark { display: block; }
.breakout-game .hud-reset-button { padding: 0 10px; font-size: .7rem; }
.breakout-game .hud-reset-button small { display:block; font-size:.48rem; font-weight:500; opacity:.72; }
.breakout-game .game-overlay { z-index: 4; overflow: auto; overscroll-behavior: contain; background: radial-gradient(circle at 50% 42%, rgba(52,35,48,.82), rgba(6,12,11,.94) 68%); }
.breakout-game .game-overlay-actions { width: min(100%, 350px); display: grid; gap: 10px; margin-top: 28px; }
.breakout-game .game-overlay-actions button { position: relative; width: 100%; box-sizing: border-box; margin-top: 0; text-align: center; }
.breakout-game .game-overlay-actions button > span { width: 100%; min-width: 0; display: flex; flex-direction: column; align-items: center; text-align: center; }
.breakout-game .game-overlay-actions button > span small { width: 100%; text-align: center; }
.breakout-game .game-overlay-actions button > b { position: absolute; right: 18px; top: 50%; margin: 0; transform: translateY(-50%); }
.breakout-game .game-overlay .overlay-secondary { color: var(--ink); border: 1px solid var(--line); background: rgba(255,255,255,.08); }
.breakout-game .game-overlay .overlay-tertiary { min-height: 48px; margin-top: 0; color: var(--muted); border: 1px solid rgba(255,255,255,.1); background: rgba(255,255,255,.035); font-size: .75rem; }
.breakout-game .game-overlay .overlay-tertiary:hover { color: var(--ink); border-color: var(--line); background: rgba(255,255,255,.07); box-shadow: none; }
.breakout-game .game-summary { width: min(100%, 430px); margin-top: 22px; display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid rgba(255,255,255,.13); background: rgba(0,0,0,.22); }
.breakout-game .game-summary[hidden] { display: none; }
.breakout-game .game-summary div { padding: 12px 8px; border-right: 1px solid rgba(255,255,255,.1); }
.breakout-game .game-summary div:last-child { border-right: 0; }
.breakout-game .game-summary small { display: block; margin-bottom: 5px; color: var(--faint); font-size: .58rem; letter-spacing: .08em; }
.breakout-game .game-summary b { font: 400 1rem var(--display); }
.breakout-game .game-summary:not([hidden]) ~ .game-overlay-actions { width: min(100%, 430px); grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 14px; }
.breakout-game .game-summary:not([hidden]) ~ .game-overlay-actions [data-game-primary] { grid-column: 1 / -1; }
.breakout-game .game-summary:not([hidden]) ~ .game-overlay-actions button { min-width: 0; min-height: 48px; margin: 0; }
.breakout-game .level-select { width: min(100%, 560px); max-height: min(320px, 46vh); margin-top: 20px; padding: 4px; display: grid; grid-template-columns: repeat(6, 1fr); gap: 7px; overflow-y: auto; }
.breakout-game .level-select[hidden] { display: none; }
.breakout-game .level-button { position: relative; min-width: 0; min-height: 54px; margin: 0; padding: 8px 4px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.15); color: var(--ink); background: rgba(255,255,255,.055); font: 400 .77rem var(--display); }
.breakout-game .level-button:hover:not(:disabled), .breakout-game .level-button[aria-current="true"] { border-color: var(--active-soft); color: var(--on-active); background: var(--active); transform: translateY(-2px); box-shadow: 0 8px 22px rgba(0,0,0,.3); }
.breakout-game .level-button:disabled { color: rgba(255,255,255,.25); cursor: not-allowed; }
.breakout-game .level-button small { position: absolute; right: 5px; top: 4px; margin: 0; color: inherit; font: 600 .58rem var(--sans); }
.breakout-game .level-button.final-level { grid-column: span 2; }
.breakout-game .game-volume { width: min(100%, 270px); margin-top: 18px; display: flex; align-items: center; gap: 12px; color: var(--faint); font-size: .68rem; }
.breakout-game .game-volume label { white-space: nowrap; }
.breakout-game .game-volume label small { display: block; font-size: .5rem; }
.breakout-game .game-volume input { width: 100%; accent-color: var(--active); }
.breakout-game .hud-sound.is-muted { color: var(--faint); border-color: var(--line); background: rgba(255,255,255,.04); }
.breakout-game .game-float-message { position: absolute; z-index: 3; left: 50%; top: 31%; transform: translate(-50%, -50%); padding: 8px 14px; color: #fff5dc; text-align: center; text-shadow: 0 4px 18px rgba(0,0,0,.8); font: 400 clamp(1rem, 3vw, 2rem)/1 var(--display); letter-spacing: .06em; pointer-events: none; animation: game-pop 2s ease both; }
.breakout-game .game-float-message[hidden] { display: none; }
@keyframes game-pop {
  0% { opacity: 0; transform: translate(-50%, -35%) scale(.88); }
  12% { opacity: 1; transform: translate(-50%, -50%) scale(1.04); }
  72% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -66%) scale(1); }
}

@media (max-width: 768px) and (orientation: portrait) {
  body[data-page="redbean-breakout"] { height: 100svh; padding-bottom: 0; overflow: hidden; }
  body[data-page="redbean-breakout"] .site-footer { display: none; }
  .game-shell { width: 100%; min-height: calc(100svh - var(--header-h)); padding: 0 0 78px; display: grid; align-content: start; }
  .game-shell .games-back, .game-shell .game-heading { display: none; }
  .game-shell .game-board-wrap { width: min(100%, 44.6svh, 424px); aspect-ratio: 39 / 70; }
  .breakout-game .game-hud { width: 100%; min-width: 0; min-height: 0; padding: max(8px, env(safe-area-inset-top)) 10px 8px; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto auto; grid-template-areas: "title actions" "stats stats"; column-gap: 10px; row-gap: 6px; }
  .breakout-game .game-hud-title { grid-area: title; }
  .breakout-game .game-hud-title span { font-size: .95rem; }
  .breakout-game .game-hud-stats { width: 100%; min-width: 0; grid-area: stats; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .breakout-game .game-hud-stats > span { min-width: 0; display: flex; align-items: baseline; justify-content: center; gap: 5px; text-align: center; }
  .breakout-game .game-hud-stats span > small { display: none; }
  .breakout-game .game-hud-stats b { min-width: 0; margin-left: 0; font-size: .84rem; }
  .breakout-game .game-hud-actions { min-width: 0; gap: 6px; justify-content: flex-end; }
  .breakout-game .hud-icon-button { width: 34px; height: 34px; }
  .breakout-game .hud-pause { order: -1; }
  .breakout-game .game-hud-actions { grid-area: actions; }
  .breakout-game .hud-reset-button { display: none; }
  .breakout-game .hud-best { display: flex; }
  .breakout-game .game-overlay { padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); }
  .breakout-game .game-overlay h2 { font-size: clamp(2rem, 10vw, 3rem); }
  .breakout-game .game-overlay-actions { width: min(100%, 230px); }
  .breakout-game .game-overlay-actions button { width: 100%; }
  .breakout-game .game-summary:not([hidden]) ~ .game-overlay-actions { width: min(100%, 280px); grid-template-columns: 1fr; }
  .breakout-game .game-summary:not([hidden]) ~ .game-overlay-actions [data-game-primary] { grid-column: auto; }
  .breakout-game .level-select { grid-template-columns: repeat(4, 1fr); max-height: 42vh; }
  .breakout-game .level-button { min-height: 48px; }
  .breakout-game .game-summary { grid-template-columns: repeat(2, 1fr); max-width: 280px; }
  .breakout-game .game-summary div:nth-child(2) { border-right: 0; }
  .breakout-game .game-summary div:nth-child(-n+2) { border-bottom: 1px solid rgba(255,255,255,.1); }
  .breakout-game .game-volume { margin-top: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .breakout-game .game-float-message { animation: none; opacity: 1; }
}

@media (max-height: 480px) and (orientation: landscape) {
  body[data-page="redbean-breakout"] { height: 100svh; padding-bottom: 0; overflow: hidden; }
  body[data-page="redbean-breakout"] .site-footer { display: none; }
  .game-shell { width: 100%; min-height: calc(100svh - var(--header-h)); padding: 0 0 78px; display: grid; align-content: start; }
  .game-shell .games-back, .game-shell .game-heading { display: none; }
  .game-shell .game-board-wrap { width: min(100%, 117svh); }
}
