:root {
  color-scheme: dark;
  --bg: #11151a;
  --panel: rgba(39, 45, 52, 0.72);
  --panel-strong: rgba(31, 37, 44, 0.92);
  --line: rgba(244, 242, 235, 0.17);
  --line-bright: rgba(255, 253, 247, 0.38);
  --text: #f5f3ed;
  --muted: #a7adb3;
  --accent: #a9c5d2;
  --accent-deep: #708995;
  --shadow: 0 28px 70px rgba(0, 0, 0, 0.42), 0 4px 10px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  min-width: 300px;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow-x: hidden;
}

button { font: inherit; }

button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.ambient {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 18% 0%, rgba(169, 197, 210, 0.13), transparent 27rem),
    radial-gradient(circle at 88% 15%, rgba(201, 155, 132, 0.08), transparent 25rem),
    linear-gradient(145deg, #1b2026 0%, #101419 52%, #161a1f 100%);
}

.ambient::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.22;
  background-image: linear-gradient(rgba(255,255,255,.018) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.018) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: linear-gradient(to bottom, black, transparent 82%);
}

.arcade-shell {
  position: relative;
  width: min(1480px, calc(100% - 32px));
  margin: 0 auto;
  padding: 18px 0 48px;
}

.glass {
  position: relative;
  overflow: hidden;
  background: linear-gradient(145deg, rgba(66, 73, 81, 0.72), rgba(20, 25, 31, 0.76));
  border: 1px solid var(--line);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.12), inset 0 -1px 0 rgba(255,255,255,.025), var(--shadow);
  backdrop-filter: blur(24px) saturate(108%);
}

.glass::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(115deg, rgba(255,255,255,.15), transparent 22%, transparent 68%, rgba(169,197,210,.04));
}

.topbar {
  min-height: 72px;
  border-radius: 22px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 18px;
  padding: 10px 14px;
  position: sticky;
  top: 12px;
  z-index: 20;
}

.brand, .wallet {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 11px;
}

.brand {
  border: 0;
  color: var(--text);
  background: transparent;
  cursor: pointer;
  text-align: left;
  min-width: 0;
}

.brand img { width: 44px; height: 44px; border-radius: 13px; }
.brand span, .wallet span:last-child { display: grid; }
.brand small, .wallet small, .eyebrow { color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: 0; }
.brand strong { font-size: 19px; }

.topnav, .segmented {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(4, 7, 11, 0.38);
}

.nav-button, .mode-button, .difficulty-button {
  min-height: 36px;
  padding: 0 18px;
  border: 0;
  border-radius: 11px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  transition: color 160ms ease, background 160ms ease, transform 160ms ease;
}

.nav-button:hover, .mode-button:hover, .difficulty-button:hover { color: var(--text); }
.nav-button.active, .mode-button.active, .difficulty-button.active { color: #182027; background: linear-gradient(165deg, #dce8ed, #9db8c4 54%, #7c96a2); box-shadow: inset 0 1px #fff, inset 0 -2px rgba(48,67,76,.35), 0 9px 18px rgba(0,0,0,.28); }
.nav-button:active, .mode-button:active, .difficulty-button:active { transform: scale(.97); }

.wallet { justify-self: end; }
.wallet strong { font-size: 18px; }
.credit-mark {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #20272c;
  font-weight: 900;
  background: radial-gradient(circle at 32% 25%, #fff, #cad7dc 32%, #8197a1 74%, #51616a);
  box-shadow: inset 0 1px 0 #fff, inset 0 -3px 6px rgba(37,51,58,.32), 0 8px 18px rgba(0,0,0,.35);
}

.page { display: none; padding-top: 20px; }
.page.active-page { display: block; animation: page-in 360ms cubic-bezier(.2,.85,.25,1); }

@keyframes page-in {
  from { opacity: 0; transform: translateY(9px); }
  to { opacity: 1; transform: none; }
}

.hero {
  min-height: 210px;
  border-radius: 28px;
  padding: 40px;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
}

.hero > *, .play-header > *, .game-card > * { position: relative; z-index: 1; }
.hero h1, .section-heading h1 { margin: 5px 0 6px; font-size: clamp(32px, 4vw, 54px); line-height: 1; }
.hero p:not(.eyebrow) { margin: 0; color: var(--muted); font-size: 16px; }
.eyebrow { margin: 0; color: #b8ccd4; }

.hero-stats { display: flex; gap: 10px; }
.hero-stats span {
  min-width: 112px;
  display: grid;
  gap: 3px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: rgba(7,11,16,.3);
}
.hero-stats strong { font-size: 25px; }
.hero-stats small { color: var(--muted); }

.game-grid {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.game-card {
  position: relative;
  min-height: 226px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 22px;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  background: linear-gradient(155deg, rgba(72,79,86,.82), rgba(26,31,37,.92) 48%, rgba(16,20,25,.94));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.18), inset 0 -2px 0 rgba(0,0,0,.22), 0 18px 36px rgba(0,0,0,.32);
  transition: transform 240ms cubic-bezier(.2,.9,.3,1), border-color 240ms ease, box-shadow 240ms ease;
}

.game-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 77% 0%, color-mix(in srgb, var(--card-accent) 18%, transparent), transparent 46%), linear-gradient(115deg, rgba(255,255,255,.08), transparent 23%);
}

.game-card:hover { transform: translateY(-6px) rotateX(1.5deg); border-color: var(--line-bright); box-shadow: inset 0 1px 0 rgba(255,255,255,.22), 0 28px 52px rgba(0,0,0,.42); }
.game-card:active { transform: translateY(-1px) scale(.985); }
.game-card-icon { width: 56px; height: 56px; border-radius: 18px; display: grid; place-items: center; color: #20262b; background: radial-gradient(circle at 30% 24%, #fff, color-mix(in srgb, var(--card-accent) 72%, #d8d8d2) 38%, color-mix(in srgb, var(--card-accent) 62%, #394149)); border: 1px solid rgba(255,255,255,.48); box-shadow: inset 0 1px #fff, inset 0 -5px 8px rgba(25,31,36,.28), 0 10px 20px rgba(0,0,0,.34); font-size: 24px; font-weight: 900; }
.game-card h2 { margin: 30px 0 5px; font-size: 20px; }
.game-card p { min-height: 38px; margin: 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.game-card-footer { margin-top: 16px; display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 11px; font-weight: 700; }
.game-card-footer strong { color: var(--card-accent); }

.memory-feature-card {
  min-height: 286px;
  display: grid;
  align-content: end;
  isolation: isolate;
}

.memory-feature-card.shared-game-highlight {
  animation: shared-game-pulse 2s cubic-bezier(.2,.9,.25,1) both;
}

@keyframes shared-game-pulse {
  0% { transform: scale(.97); box-shadow: 0 0 0 0 rgba(255,232,154,0); }
  18%, 62% { transform: scale(1.018); border-color: rgba(255,240,184,.98); box-shadow: 0 0 0 3px rgba(255,226,131,.48), 0 0 38px rgba(255,218,106,.8), inset 0 1px 0 rgba(255,255,255,.7); filter: brightness(1.32) saturate(1.18); }
  100% { transform: scale(1); box-shadow: inset 0 1px 0 rgba(255,255,255,.22), 0 18px 38px rgba(0,0,0,.34); filter: none; }
}

.memory-card-demo {
  position: absolute;
  z-index: 0;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
  padding: 12px;
  opacity: .72;
  transform: perspective(600px) rotateX(5deg) rotateZ(-2deg) scale(1.03);
  mask-image: linear-gradient(to bottom, #000 5%, rgba(0,0,0,.92) 50%, transparent 92%);
}

.memory-card-demo span {
  min-width: 0;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.28);
  border-radius: 9px;
  background: #151a20;
  box-shadow: 0 7px 14px rgba(0,0,0,.28), inset 0 1px rgba(255,255,255,.16);
  animation: demo-card-breathe 4.8s ease-in-out infinite;
}

.memory-card-demo span:nth-child(3n) { animation-delay: -1.1s; }
.memory-card-demo span:nth-child(4n) { animation-delay: -2.4s; }
.memory-card-demo img { width: 100%; height: 100%; display: block; object-fit: cover; }
.memory-card-scrim { position: absolute; z-index: 1; inset: 36% 0 0; background: linear-gradient(transparent, rgba(12,16,21,.94) 38%); }
.memory-card-content { position: relative; z-index: 2; display: grid; gap: 6px; }
.memory-card-content h2 { margin: 0; font-size: 23px; }
.memory-card-content p { min-height: 0; margin: 0; }
.memory-card-kicker { color: #eedda7; font-size: 10px; font-weight: 900; }
.memory-reward-badge { justify-self: start; padding: 5px 9px; border: 1px solid rgba(238,221,167,.4); border-radius: 999px; color: #fff2c8; background: rgba(104,83,34,.34); font-size: 10px; font-weight: 900; }
.memory-card-actions { display: grid; grid-template-columns: 1fr auto; gap: 7px; margin-top: 5px; }
.memory-card-actions button { min-height: 38px; border-radius: 12px; }
.memory-play-button { border: 0; color: #20262b; background: linear-gradient(160deg, #f3ead0, #c4aa73); font-weight: 900; }
.memory-share-button { padding-inline: 13px; border: 1px solid var(--line); color: var(--text); background: rgba(8,12,17,.58); font-weight: 800; }
.memory-demo-reward { position: absolute; z-index: 3; top: 74px; right: 18px; color: #fff0b6; font-size: 12px; font-weight: 950; opacity: 0; animation: demo-reward 4.8s ease-in-out infinite; }

@keyframes demo-card-breathe { 0%, 76%, 100% { transform: rotateY(0); filter: brightness(.78); } 84%, 94% { transform: rotateY(180deg); filter: brightness(1.24); } }
@keyframes demo-reward { 0%, 74%, 100% { opacity: 0; transform: translateY(8px) scale(.8); } 82%, 92% { opacity: 1; transform: translateY(0) scale(1); } }

.arcade-share-dialog { width: min(430px, calc(100% - 18px)); padding: 0; border: 0; color: var(--text); background: transparent; }
.arcade-share-dialog::backdrop { background: rgba(4,7,11,.66); backdrop-filter: blur(8px); }
.arcade-share-card { display: grid; gap: 14px; padding: 18px; border: 1px solid var(--line-bright); border-radius: 24px; background: rgba(23,29,37,.94); box-shadow: var(--shadow), inset 0 1px rgba(255,255,255,.16); backdrop-filter: blur(25px); }
.arcade-share-card header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.arcade-share-card h2 { margin: 3px 0 0; font-size: 22px; }
.share-type-picker { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 4px; border: 1px solid var(--line); border-radius: 15px; background: rgba(5,8,12,.38); }
.share-type { min-height: 38px; border: 0; border-radius: 11px; color: var(--muted); background: transparent; }
.share-type.active { color: #20262b; background: linear-gradient(160deg, #f3ead0, #c4aa73); font-weight: 850; }
.arcade-share-card label { display: grid; gap: 7px; color: var(--muted); font-size: 11px; font-weight: 800; }
.arcade-share-card textarea { min-height: 88px; resize: vertical; padding: 11px; border: 1px solid var(--line); border-radius: 14px; color: var(--text); background: rgba(6,10,15,.52); font: inherit; }
#continueArcadeShare { min-height: 42px; border: 0; border-radius: 14px; color: #20262b; background: linear-gradient(160deg, #f3ead0, #c4aa73); font-weight: 900; }

.section-heading { display: flex; justify-content: space-between; align-items: end; gap: 20px; padding: 24px 4px 18px; }
.records-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.record-row { padding: 18px; border-radius: 19px; display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center; }
.record-row .game-card-icon { width: 44px; height: 44px; border-radius: 13px; }
.record-row h2 { margin: 0 0 4px; font-size: 17px; }
.record-row p { margin: 0; color: var(--muted); font-size: 12px; }
.record-row strong { font-size: 22px; }

.play-header {
  min-height: 82px;
  border-radius: 22px;
  padding: 10px 14px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
}

.icon-button, .quiet-button, .overlay-actions button {
  min-height: 42px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--text);
  background: rgba(9,13,19,.48);
  cursor: pointer;
  transition: transform 150ms ease, border-color 150ms ease, background 150ms ease;
}
.icon-button { width: 44px; padding: 0; font-size: 20px; }
.icon-button:hover, .quiet-button:hover { border-color: var(--line-bright); background: rgba(31,40,52,.65); }
.icon-button:active, .quiet-button:active { transform: scale(.96); }

.play-title { display: flex; align-items: center; gap: 11px; }
.play-title > span { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; background: rgba(114,225,189,.12); border: 1px solid rgba(114,225,189,.3); font-size: 22px; }
.play-title small { color: #b8ccd4; font-size: 10px; font-weight: 800; }
.play-title h1 { margin: 2px 0 0; font-size: 20px; }
.play-actions { display: flex; align-items: center; gap: 9px; }

.stage-layout { margin-top: 12px; display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 12px; }
.game-stage { min-height: 620px; border-radius: 26px; display: grid; place-items: center; padding: 14px; }
#gameCanvas { position: relative; z-index: 1; display: block; width: 100%; height: auto; max-height: calc(100vh - 150px); aspect-ratio: 16 / 10; border-radius: 19px; background: #080d13; touch-action: none; }
body.memory-game #gameCanvas {
  width: auto;
  height: min(920px, calc(100vh - 150px));
  max-width: 100%;
  aspect-ratio: 12 / 23;
}
body.portrait-game:not(.memory-game) #gameCanvas {
  width: auto;
  height: min(760px, calc(100vh - 150px));
  max-width: 100%;
  aspect-ratio: 12 / 19;
}

.countdown { position: absolute; z-index: 5; font-size: clamp(70px, 11vw, 150px); font-weight: 900; filter: drop-shadow(0 12px 24px rgba(0,0,0,.5)); animation: count-pop 480ms cubic-bezier(.2,.9,.2,1); }
@keyframes count-pop { from { opacity: 0; transform: scale(.6); } 60% { opacity: 1; transform: scale(1.08); } to { transform: scale(1); } }

.game-overlay {
  position: absolute;
  z-index: 6;
  width: min(420px, calc(100% - 44px));
  padding: 30px;
  border: 1px solid var(--line-bright);
  border-radius: 25px;
  text-align: center;
  background: rgba(15,21,30,.88);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.18), 0 30px 80px rgba(0,0,0,.55);
  backdrop-filter: blur(26px) saturate(130%);
}
.game-overlay h2 { margin: 7px 0 8px; font-size: 32px; }
.game-overlay > p:not(.eyebrow) { color: var(--muted); }
.reward-pill { display: inline-flex; margin: 9px 0 18px; padding: 8px 14px; border-radius: 999px; color: #1b2227; background: linear-gradient(160deg, #e3ecef, #9eb6c0); box-shadow: inset 0 1px #fff, 0 8px 18px rgba(0,0,0,.28); font-weight: 900; }
.overlay-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.overlay-actions button:first-child { color: #1b2227; background: linear-gradient(160deg, #e4edf0, #9fb7c1); border-color: transparent; box-shadow: inset 0 1px #fff, 0 8px 18px rgba(0,0,0,.3); font-weight: 800; }
.overlay-actions:has(#reviveButton:not(.hidden)) #reviveButton {
  grid-column: 1 / -1;
  color: #251f12;
  border-color: rgba(255, 233, 164, .7);
  background: linear-gradient(160deg, #f7e5aa, #c89e4e);
  box-shadow: inset 0 1px rgba(255,255,255,.85), 0 9px 22px rgba(198,151,67,.24);
  font-weight: 900;
}

.game-sidebar { display: grid; align-content: start; gap: 12px; }
.score-card, .instructions, .difficulty { border-radius: 22px; padding: 18px; }
.score-card { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; text-align: center; }
.score-card div { display: grid; }
.score-card small { color: var(--muted); font-size: 10px; font-weight: 800; }
.score-card strong { margin-top: 4px; font-size: 31px; }
.score-card > span { color: var(--muted); font-size: 11px; font-weight: 900; }
.score-card.solo-score { grid-template-columns: 1fr; }
.score-card.solo-score > span,
.score-card.solo-score #opponentScoreGroup { display: none; }
.instructions h2 { margin: 5px 0 8px; font-size: 20px; }
.instructions > p:not(.eyebrow) { min-height: 62px; margin: 0; color: var(--muted); line-height: 1.5; font-size: 13px; }
.control-chips { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 6px; }
.control-chips span { padding: 7px 9px; border: 1px solid var(--line); border-radius: 9px; background: rgba(5,8,12,.34); color: #d9e2eb; font-size: 11px; font-weight: 700; }
.difficulty .wide { margin-top: 10px; display: grid; grid-template-columns: repeat(3, 1fr); }
.difficulty-button { padding: 0 6px; }

.toast { position: fixed; z-index: 50; left: 50%; bottom: 26px; transform: translateX(-50%); padding: 11px 16px; border: 1px solid var(--line-bright); border-radius: 999px; color: var(--text); background: rgba(20,28,38,.9); box-shadow: var(--shadow); backdrop-filter: blur(20px); }
.hidden { display: none !important; }

.memory-wallet {
  position: absolute;
  z-index: 8;
  top: 8px;
  left: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 104px;
  padding: 5px 9px 5px 5px;
  border: 1px solid rgba(255, 253, 247, .4);
  border-radius: 999px;
  background: rgba(12, 17, 22, .72);
  box-shadow: inset 0 1px rgba(255,255,255,.15), 0 12px 28px rgba(0,0,0,.36);
  backdrop-filter: blur(18px) saturate(125%);
  pointer-events: none;
}

.memory-wallet .credit-mark { width: 27px; height: 27px; font-size: 11px; }
.memory-wallet > span:last-child { display: grid; }
.memory-wallet small { color: var(--muted); font-size: 8px; font-weight: 900; }
.memory-wallet strong { font-size: 13px; }
.memory-wallet.wallet-pop { animation: wallet-pop 260ms cubic-bezier(.2, 1.35, .35, 1); }

.memory-skip-countdown {
  position: absolute;
  z-index: 9;
  left: 50%;
  top: 62%;
  min-height: 0;
  padding: 3px 10px;
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 999px;
  color: rgba(255,255,255,.72);
  background: rgba(12,17,22,.38);
  box-shadow: inset 0 1px rgba(255,255,255,.12), 0 5px 13px rgba(0,0,0,.18);
  backdrop-filter: blur(12px) saturate(120%);
  transform: translateX(-50%);
  font-size: 9px;
  font-weight: 750;
  cursor: pointer;
  opacity: .72;
}

.memory-skip-countdown:hover { opacity: 1; background: rgba(25,32,40,.58); }
.memory-skip-countdown:active { transform: translateX(-50%) scale(.94); }

.memory-deck-flip {
  position: absolute;
  z-index: 9;
  top: 8px;
  right: 8px;
  width: 82px;
  min-height: 28px;
  padding: 0 7px;
  border: 1px solid rgba(255,255,255,.28);
  border-radius: 999px;
  color: rgba(255,255,255,.84);
  background: rgba(12,17,22,.48);
  box-shadow: inset 0 1px rgba(255,255,255,.14), 0 7px 16px rgba(0,0,0,.22);
  backdrop-filter: blur(14px) saturate(125%);
  font-size: 9px;
  font-weight: 850;
  cursor: pointer;
}

.memory-deck-flip.confirming { border-color: rgba(196,170,115,.72); color: #fff4ce; }
.memory-deck-flip.used, .memory-deck-flip:disabled { opacity: .42; cursor: default; }
.memory-deck-flip:not(:disabled):active { transform: scale(.95); }

.coin-flight-layer { position: fixed; inset: 0; z-index: 100; pointer-events: none; overflow: hidden; }
.flying-b-coin {
  --coin-x: 0px;
  --coin-y: 0px;
  --coin-delay: 0ms;
  position: absolute;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255,255,255,.75);
  border-radius: 50%;
  color: #30343a;
  background: radial-gradient(circle at 31% 24%, #fff, #eadcae 30%, #c4aa73 68%, #766443);
  box-shadow: 0 5px 13px rgba(0,0,0,.4), inset 0 1px #fff;
  font-size: 9px;
  font-weight: 950;
  animation: coin-flight 720ms cubic-bezier(.28,.72,.32,1) var(--coin-delay) both;
}

@keyframes coin-flight {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.35) rotate(-80deg); }
  18% { opacity: 1; transform: translate(-50%, calc(-50% - 32px)) scale(1.15) rotate(30deg); }
  100% { opacity: 1; transform: translate(calc(var(--coin-x) - 50%), calc(var(--coin-y) - 50%)) scale(.55) rotate(420deg); }
}

@keyframes wallet-pop {
  45% { transform: scale(1.09); filter: brightness(1.25); }
}

body.embedded { min-width: 0; }
body.embedded .arcade-shell { width: min(100% - 14px, 1480px); padding-top: 7px; padding-bottom: 20px; }
body.embedded .topbar { top: 4px; }

body.embedded.play-active .topbar { display: none; }
body.embedded.play-active .play-page { padding-top: 6px; }
body.embedded.play-active .play-header {
  width: max-content;
  min-height: 42px;
  margin: 0 auto 4px;
  padding: 3px;
  display: flex;
  align-items: center;
  gap: 3px;
  border-radius: 999px;
}
body.embedded.play-active .icon-button,
body.embedded.play-active .play-actions > .quiet-button { width: 36px; min-height: 36px; padding: 0; border-radius: 999px; font-size: 16px; }
body.embedded.play-active .play-title { display: none; }
body.embedded.play-active .play-actions { display: contents; }
body.embedded.play-active .play-actions .segmented { display: none; }
body.embedded.play-active #restartButton { order: 2; }
body.embedded.play-active #shareGameButton { order: 3; }
body.embedded.play-active #backButton { order: 1; }
body.embedded.play-active .stage-layout { display: block; margin-top: 3px; }
body.embedded.play-active .game-sidebar { display: none; }
body.embedded.play-active .game-stage { min-height: 0; padding: 5px; border-radius: 19px; }
body.embedded.play-active #gameCanvas { max-height: calc(100dvh - 58px); border-radius: 15px; }
body.embedded.play-active.portrait-game #gameCanvas {
  width: min(100%, calc((100dvh - 68px) * 12 / 19));
  height: auto;
  max-width: 100%;
  max-height: calc(100dvh - 68px);
}
body.embedded.play-active.memory-game #gameCanvas {
  width: min(100%, calc((100dvh - 68px) * 12 / 23));
  aspect-ratio: 12 / 23;
}
body.embedded.play-active.portrait-game:not(.memory-game) #gameCanvas { aspect-ratio: 12 / 19; }
body.embedded.play-active .game-overlay { width: calc(100% - 18px); padding: 20px 14px; border-radius: 19px; }
body.embedded.play-active .game-overlay h2 { font-size: 25px; }

body.embedded:not(.play-active) .hero {
  min-height: 0;
  padding: 10px 12px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
}
body.embedded:not(.play-active) .hero .eyebrow { display: none; }
body.embedded:not(.play-active) .hero h1 { margin: 0; font-size: 19px; line-height: 1; white-space: nowrap; }
body.embedded:not(.play-active) .hero p:not(.eyebrow) { display: none; }
body.embedded:not(.play-active) .hero-stats { gap: 6px; }
body.embedded:not(.play-active) .hero-stats span { min-width: 52px; padding: 6px 7px; border-radius: 11px; }
body.embedded:not(.play-active) .hero-stats strong { font-size: 15px; }
body.embedded:not(.play-active) .hero-stats small { font-size: 8px; }

@media (max-width: 520px) {
  .memory-wallet { top: 6px; left: 6px; transform: scale(.8); transform-origin: top left; }
}

@media (max-width: 1100px) {
  .game-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stage-layout { grid-template-columns: 1fr; }
  .game-sidebar { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .game-stage { min-height: 0; }
}

@media (max-width: 720px) {
  .arcade-shell { width: min(100% - 18px, 620px); padding-top: 9px; }
  .topbar { top: 6px; grid-template-columns: minmax(0, 1fr) auto; overflow: hidden; }
  .topnav { order: 3; grid-column: 1 / -1; width: 100%; }
  .nav-button { flex: 1; }
  .wallet { gap: 7px; }
  .wallet small, .wallet .credit-mark { display: none; }
  .hero { min-height: 0; padding: 25px 20px; align-items: start; flex-direction: column; }
  .hero h1 { font-size: 36px; }
  .game-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .game-card { min-height: 205px; padding: 15px; }
  .records-grid { grid-template-columns: 1fr; }
  .play-header { grid-template-columns: auto 1fr; }
  .play-actions { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr; }
  .play-actions .segmented { display: grid; grid-template-columns: 1fr 1fr; }
  .play-actions > .quiet-button { width: 100%; }
  .game-stage { padding: 7px; border-radius: 20px; }
  #gameCanvas { border-radius: 15px; }
  .game-sidebar { grid-template-columns: 1fr; }
}

@media (max-width: 410px) {
  .brand small, .brand strong { display: none; }
  .game-grid { grid-template-columns: 1fr; }
  .game-card { min-height: 176px; }
  .game-card h2 { margin-top: 18px; }
  .hero-stats { width: 100%; }
  .hero-stats span { flex: 1; min-width: 0; }
  body.embedded:not(.play-active) .hero-stats { width: auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
