/* Williams Arcade · one marquee, six cabinets. */
:root {
  --night: #071523; --panel: #0d2335; --panel-2: #15384a;
  --rule: #41566a; --cream: #fff2d2; --dim: #adbac4;
  --amber: #ffc344; --cherry: #ff4b51; --sky: #9bc8c2; --bezel: #020609;
}
body { background: var(--night); color: var(--cream); }
button:focus-visible, a:focus-visible { outline: 3px solid var(--amber); outline-offset: 4px; }
#menu, .score-page {
  height: 100%; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: max(26px, env(safe-area-inset-top, 0px)) max(24px, env(safe-area-inset-right, 0px)) max(22px, env(safe-area-inset-bottom, 0px)) max(24px, env(safe-area-inset-left, 0px));
  background: radial-gradient(circle at 18px 16px, #e6d9ad25 1px, transparent 1px) 0 0 / 137px 113px, var(--night);
}
#menu > .wrap { max-width: 1120px; gap: 0; }
.marquee { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 12px 0 25px; border: 0; border-bottom: 3px solid #cc542e; position: relative; }
.marquee::after { content: ''; position: absolute; bottom: -8px; left: 0; right: 0; height: 2px; background: #e8a83b; }
.marquee h1 { color: var(--amber); margin: 0 0 9px; font: 400 clamp(32px, 5.6vw, 60px)/1.06 var(--font-marquee); letter-spacing: -.035em; text-shadow: 0 3px 0 #b74c27; }
.marquee .sub { font: 400 9px/1.5 var(--font-pixel); letter-spacing: .11em; color: #c5b99c; }
.coin { flex-shrink: 0; color: #ff4b51; font: 400 12px var(--font-pixel); letter-spacing: .08em; animation: coin-blink 2.4s ease-in-out infinite; }
@keyframes coin-blink { 0%, 100% { opacity: .08; } 40%, 60% { opacity: 1; } }
.arcade-tools { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 27px 0 20px; }
.select-prompt { font: 400 10px var(--font-pixel); color: #9eafb9; letter-spacing: .06em; }
.select-prompt span { color: #f78252; margin-left: 7px; }
.tools { margin-left: auto; gap: 8px; flex-wrap: wrap; }
.grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 21px; }
@media (max-width: 1100px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.card { --cabinet: #a7462c; --cabinet-text: #fff2d2; display: flex; flex-direction: column; padding: 0; gap: 0; overflow: hidden; background: #0b1b28; border: 1px solid #5b5145; border-radius: 5px; box-shadow: 0 4px 0 #03090f; transition: border-color .12s ease, transform .12s ease; }
.card:focus-visible { border-color: var(--amber); transform: translateY(-2px); }
@media (hover: hover) { .card:hover { border-color: var(--amber); transform: translateY(-2px); } } /* iOS treats a first tap on :hover content as hover only */
#card-invaders { --cabinet: #3b746e; }
#card-starfighter { --cabinet: #cc9b3b; --cabinet-text: #091c28; }
#card-asteroids { --cabinet: #a7462c; }
#card-centipede { --cabinet: #596d3b; }
#card-missile { --cabinet: #3e627a; }
.cabinet-marquee { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 13px; background: var(--cabinet); color: var(--cabinet-text); }
.cabinet-title { font: 400 clamp(15px, 1.7vw, 21px)/1.15 var(--font-marquee); letter-spacing: -.035em; }
.cabinet-year { font: 400 10px var(--font-pixel); opacity: .9; }
.screen-bezel { position: relative; display: block; padding: 11px 11px 0; background: #0b1b28; }
.screen { width: 100%; aspect-ratio: 3 / 4; border: 2px solid #2c3b43; border-radius: 7px; background: #000; image-rendering: pixelated; }
#card-asteroids .screen, #card-stackworks .screen { image-rendering: auto; }
.screen-play { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); background: #061420ed; color: var(--amber); padding: 12px; border: 1px solid #ffc34480; font: 400 10px var(--font-pixel); white-space: nowrap; opacity: 0; }
.card:focus-visible .screen-play { opacity: 1; }
@media (hover: hover) { .card:hover .screen-play { opacity: 1; } }
.score-strip { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 13px; min-height: 40px; }
.hi { font: 400 10px var(--font-pixel); max-width: 74%; color: var(--amber); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.device-label { color: #9aadb8; font: 400 10px var(--font-pixel); letter-spacing: .04em; }
.foot { margin: 25px 0 0; padding: 0; border: 0; gap: 20px; align-items: center; color: #8b9ba7; font: 400 8px var(--font-pixel); }
.footer-stars { margin-left: auto; color: #e9b860; font-size: 17px; letter-spacing: 7px; }
/* The score table is a full page, never a modal. */
.score-page { position: fixed; inset: 0; z-index: 10; }
.score-wrap { max-width: 1050px; margin: 0 auto; }
.score-header { display: flex; align-items: center; gap: 25px; border-bottom: 2px solid #cc542e; padding: 10px 0 26px; }
.score-header h1 { margin: 0; color: var(--amber); font: 400 clamp(26px, 4vw, 45px)/1.1 var(--font-marquee); text-shadow: 0 3px 0 #a53e24; }
.score-header .tool { min-width: 80px; }
.score-star { margin-left: auto; color: #e6aa54; font-size: 32px; }
.score-games { display: flex; gap: 5px; overflow-x: auto; padding: 24px 0; }
.score-cabinet { border: 1px solid #354a5a; background: #02070d; padding: 28px 32px; min-height: 360px; }
.score-controls { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 25px; }
.score-controls h2 { font: 400 23px/1.2 var(--font-marquee); margin: 0; color: var(--cream); }
.score-table { width: 100%; border-collapse: collapse; font: 400 14px/1.5 var(--font-pixel); font-variant-numeric: tabular-nums; }
.score-table th { color: #eb644d; font: 400 10px var(--font-pixel); text-align: left; padding: 10px 9px 17px; border-bottom: 1px solid #34414c; }
.score-table th:first-child { width: 13%; }
.score-table th:nth-child(3), .score-table th:last-child { text-align: right; }
.score-table td { padding: 17px 9px; border-bottom: 1px solid #17232d; }
.score-table .rk { color: #90a1ae; }
.score-table .nm { color: var(--cream); text-transform: uppercase; overflow-wrap: anywhere; }
.score-table .sc { color: var(--amber); text-align: right; white-space: nowrap; }
.score-table .dt { color: #93a2ac; font: 500 12px var(--font-ui); text-align: right; white-space: nowrap; }
.score-table tr:first-child .nm, .score-table tr:first-child .rk { color: var(--amber); }
.score-table tr.me { background: #3d3015; }
.score-status { color: #a6b6c2; text-align: center; font: 400 12px/1.8 var(--font-ui); padding: 28px 0; }
.score-status:empty { display: none; }
.score-retry { display: block; margin: 0 auto; }
.score-foot { color: #8b9ba7; font: 400 8px var(--font-pixel); text-align: center; margin: 24px 0; }
/* Carry the cabinet treatment into setup, help, and score screens. */
.overlay { color: var(--cream); background: #03121edb; }
.dialog { border: 3px solid #b45635; border-radius: 7px; box-shadow: 0 7px 0 #02111d; background: var(--night); max-height: calc(100dvh - 32px); overflow-y: auto; }
.dialog h3 { color: var(--cream); text-shadow: 2px 2px 0 #aa4428; }
.dialog .linkbtn { color: #b2d8cc; }
@media (max-width: 850px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .marquee h1 { font-size: clamp(29px, 5.8vw, 49px); }
  .coin { font-size: 10px; }
  .cabinet-title { font-size: 20px; }
}
@media (max-width: 550px) {
  #menu, .score-page { padding: max(18px, env(safe-area-inset-top, 0px)) max(15px, env(safe-area-inset-right, 0px)) max(22px, env(safe-area-inset-bottom, 0px)) max(15px, env(safe-area-inset-left, 0px)); }
  .marquee { align-items: flex-start; flex-wrap: wrap; padding: 5px 0 19px; gap: 13px; }
  .marquee h1 { font-size: clamp(27px, 7.5vw, 40px); white-space: nowrap; }
  .marquee-title { width: 100%; }
  .marquee .sub { font-size: 8px; }
  .coin { position: absolute; bottom: 19px; right: 0; font-size: 8px; }
  .arcade-tools { padding-top: 23px; gap: 10px; }
  .select-prompt { display: none; }
  .tools { gap: 7px; }
  .grid { grid-template-columns: 1fr; gap: 18px; }
  .cabinet-title { font-size: 20px; }
  .foot { font-size: 7px; gap: 12px; }
  .footer-stars { font-size: 12px; letter-spacing: 2px; }
  .score-header { gap: 14px; padding-bottom: 22px; }
  .score-header h1 { font-size: 26px; }
  .score-header .tool { min-width: 0; }
  .score-star { display: none; }
  .score-games { padding: 18px 0; }
  .score-cabinet { padding: 18px 12px; }
  .score-controls { align-items: flex-start; flex-direction: column; gap: 16px; margin-bottom: 18px; }
  .score-controls h2 { font-size: 21px; }
  .score-table { font-size: 10px; }
  .score-table th { font-size: 8px; padding: 8px 4px 12px; }
  .score-table td { padding: 16px 4px; }
  .score-table .dt { font-size: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .coin { animation: none; }
  .card { transition: none; }
  .card:hover { transform: none; }
}

/* Cabinet glass and illuminated marquee trim: decorative, never over gameplay. */
.screen-bezel::after { content: ''; position: absolute; inset: 13px 13px 2px; border-radius: 5px; pointer-events: none; background: repeating-linear-gradient(0deg, transparent 0 3px, #00000024 3px 4px); }
.marquee h1 { text-shadow: 0 3px 0 #b74c27, 0 0 22px #ffc3441c; }
.cabinet-marquee { border-top: 2px solid #fff2d235; border-bottom: 2px solid #00000055; }
.ready-dialog { width: min(100%, 520px); max-height: 92dvh; overflow-y: auto; }
.ready-kicker { color: var(--cherry); font: 11px var(--font-pixel); letter-spacing: .12em; }
.ready-controls { padding: 12px 16px; border: 1px solid #ffc34455; background: #030c14; text-align: left; }
.ready-controls h4 { margin: 0 0 6px; color: var(--amber); font: 11px var(--font-pixel); }
.ready-controls p { margin: 0 0 10px; font-size: 16px; line-height: 1.5; }
.ready-controls dl { margin: 0; display: grid; grid-template-columns: 1fr auto; gap: 9px 16px; align-items: center; font-size: 14px; }
.ready-controls dd { margin: 0; color: var(--amber); text-align: right; font-weight: 700; }
.ready-remember { display: flex; align-items: center; gap: 10px; text-align: left; font-size: 14px; cursor: pointer; }
.ready-remember input { width: 20px; height: 20px; flex-shrink: 0; accent-color: var(--amber); }

/* Platform tag, modes and operator's tip on each cabinet card */
.device-label.best-ipad { color: #7fd3e6; }
.device-label.best-computer { color: var(--amber); }
.card-info { display: flex; flex-direction: column; gap: 8px; padding: 0 13px 14px; text-align: left; }
.card-modes { color: #a9b8c2; font: 500 14px/1.45 var(--font-ui); }
.card-tip { display: block; border-top: 1px dashed #34414c; padding-top: 9px; color: var(--cream); font: 500 13px/1.45 var(--font-ui); }
.card-tip b { display: block; margin-bottom: 4px; color: var(--cherry, #ff4b51); font: 400 7px var(--font-pixel); letter-spacing: .1em; }
.ready-tip { margin: 12px 0 0; padding: 10px 14px; border-left: 3px solid var(--amber); background: #0b1b28; text-align: left; font: 500 14px/1.5 var(--font-ui); color: var(--cream); }
.ready-tip b { display: block; margin-bottom: 4px; color: var(--cherry, #ff4b51); font: 400 9px var(--font-pixel); letter-spacing: .1em; }

/* Cabinet settings (operator switches) in the setup sheet */
.ops-rows { display: flex; flex-direction: column; gap: 10px; }
.ops-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.ops-label { font: 600 14px var(--font-ui); color: var(--cream); }
.ops-seg button { min-width: 48px; }
.ops-select { min-height: 44px; padding: 8px 12px; border-radius: 8px; border: 1px solid #486073; background: #0b1b28; color: var(--cream); font: 600 14px var(--font-ui); max-width: 100%; }
#opsReset { align-self: flex-start; }

/* Game details + operator's tip live in the setup popup, not on the cabinet cards */
.setup-info { margin: 4px 0 0; color: #b9c6cf; font: 500 14px/1.5 var(--font-ui); text-align: center; }
.setup-info b { color: var(--amber); font-weight: 700; }
.setup-tip { margin: 6px 0 2px; }

#card-snake { --cabinet: #2f6f4f; }
/* Setup popup: how it plays best */
.play-best { list-style: none; margin: 8px auto 2px; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, max-content)); justify-content: center; gap: 5px 16px; text-align: left; font: 500 13.5px/1.4 var(--font-ui); color: #b9c6cf; }
@media (max-width: 480px) { .play-best { grid-template-columns: max-content; } }
.play-best li { display: flex; align-items: center; gap: 6px; }
.play-best li::before { content: '•'; color: #5f7584; }
.play-best li.device { color: var(--amber); font-weight: 700; }
.play-best li.device::before { color: var(--amber); }
/* Collapsible cabinet settings */
.ops-toggle { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 44px; background: transparent; border: 1px solid #34414c; border-radius: 8px; color: var(--cream); cursor: pointer; padding: 8px 12px; }
.ops-toggle .label { margin: 0; }
.ops-state { font: 600 13px var(--font-ui); color: var(--amber); }
.ops-state.custom { color: #7fd3e6; }
.ops-toggle .chev { transition: transform .15s ease; color: #9eafb9; }
.ops-toggle[aria-expanded="true"] .chev { transform: rotate(180deg); }
.ops-body { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
/* Info buttons */
.info-btn { display: inline-grid; place-items: center; width: 22px; height: 22px; margin-left: 6px; padding: 0; border-radius: 50%; border: 1px solid #5f7584; background: transparent; color: #b9c6cf; font: italic 700 12px Georgia, serif; cursor: pointer; vertical-align: middle; position: relative; }
.info-btn::after { content: ''; position: absolute; inset: -11px; }
.info-btn[aria-expanded="true"] { background: var(--amber); color: #091c28; border-color: var(--amber); }
.ops-info { margin: -4px 0 4px; padding: 8px 12px; border-left: 3px solid var(--amber); background: #0b1b28; color: var(--cream); font: 500 13px/1.5 var(--font-ui); text-align: left; }
/* Operator's tips at the top of How to Play */
.op-tips { margin: 18px 0 4px; border-left: 3px solid var(--amber); background: #0b1b28; }
.op-tips summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; padding: 0 14px; cursor: pointer; list-style: none; user-select: none; -webkit-user-select: none; }
.op-tips summary::-webkit-details-marker { display: none; }
.op-tips summary:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.op-tips h4 { margin: 0; color: var(--cherry); font: 400 10px var(--font-pixel); letter-spacing: .1em; text-transform: uppercase; }
.op-tips .chev { width: 8px; height: 8px; margin-top: -4px; border-right: 2px solid var(--amber); border-bottom: 2px solid var(--amber); transform: rotate(45deg); transition: transform .2s; }
.op-tips[open] .chev { margin-top: 4px; transform: rotate(-135deg); }
.op-tips ul { margin: 0; padding: 0 14px 12px 32px; font-size: 1.05em; }
.op-tips li { margin: 8px 0; }
.op-tips[open] ul { animation: tipsOpen .2s ease-out; }
@keyframes tipsOpen { from { opacity: 0; transform: translateY(-4px); } }
@media (hover: hover) { .op-tips summary:hover .chev { border-color: var(--cherry); } }

/* Original game, maker and year under each cabinet's screen */
.card-orig { color: var(--cream); font: 600 14px/1.35 var(--font-ui); }


/* Attract mode: the hovered (or touched) cabinet plays a demo */
.card { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.card.demo .screen-play { opacity: 1; top: auto; bottom: 6px; transform: translateX(-50%); padding: 4px 8px; font-size: 9px; background: #061420b0; border-color: #ffc34440; animation: demo-blink 1.6s ease-in-out infinite; }
@keyframes demo-blink { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .card.demo .screen-play { animation: none; } }

#card-breakout { --cabinet: #aa4934; }
#card-maze { --cabinet: #d9b72f; --cabinet-text: #121c2c; }
#card-river { --cabinet: #4e8750; }
#card-stackworks { --cabinet: #986646; }
#game.compact-controls .pad { gap: 6px; }
#game.compact-controls .tb { width: clamp(44px, 12vw, 60px); height: clamp(44px, 12vw, 60px); font-size: 10px; } /* 44px: the smallest comfortable touch target */
#game.compact-controls .tb.big { width: clamp(60px, 16vw, 72px); height: clamp(60px, 16vw, 72px); line-height: 1.1; }

#game.fourway.touchmode #padL { display: grid; grid-template-columns: repeat(3, auto); grid-template-rows: repeat(2, auto); }
#game.fourway #padL .tb:nth-child(1) { grid-area: 1 / 2; }
#game.fourway #padL .tb:nth-child(2) { grid-area: 2 / 1; }
#game.fourway #padL .tb:nth-child(3) { grid-area: 2 / 2; }
#game.fourway #padL .tb:nth-child(4) { grid-area: 2 / 3; }

/* Four-way cabinets leave the right hand free for pause. */
#game.fourway.touchmode #pauseBtn { left: auto; right: 18px; transform: none; }

/* New vector / territory cabinets */
#card-surge { --cabinet: #f3f300; --cabinet-text: #101010; }
#card-divide { --cabinet: #007f7f; }
#card-surge .screen, #card-divide .screen { image-rendering: auto; }

/* Add to Home Screen coach: pinned at the top, out of the way of play, pointing at Safari's Share */
.coach { position: fixed; z-index: 60; top: max(10px, env(safe-area-inset-top, 0px)); left: 50%; transform: translateX(-50%); width: min(440px, calc(100% - 24px)); padding: 10px 14px 12px; background: #0b1b28f2; border: 2px solid var(--amber); border-radius: 8px; box-shadow: 0 6px 24px #000a; color: var(--cream); }
.coach[hidden] { display: none; }
.coach-head { display: flex; align-items: center; justify-content: space-between; }
.coach-kicker { color: var(--cherry); font: 400 9px var(--font-pixel); letter-spacing: .12em; }
.coach-x { background: none; border: 0; color: #b9c6cf; font: 600 18px var(--font-ui); width: 40px; height: 40px; margin: -8px -10px -8px 0; cursor: pointer; }
.coach-steps { margin: 4px 0 6px; padding-left: 22px; font: 500 15px/1.4 var(--font-ui); }
.coach-steps li { margin: 4px 0; }
.coach.one .coach-steps { list-style: none; padding-left: 0; }
.coach-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.coach-actions .btn { padding: 10px 22px; }
.coach-never { background: none; border: 0; padding: 8px 0; color: #8b9ba7; font: 500 13px var(--font-ui); text-decoration: underline; cursor: pointer; min-height: 40px; }
.coach-arrow { display: none; position: absolute; color: var(--amber); font: 700 26px/1 var(--font-ui); animation: coach-nudge 1.2s ease-in-out infinite; }
.coach[data-point="down"] .coach-arrow { display: block; left: 50%; bottom: -34px; transform: translateX(-50%); }
.coach[data-point="down"] .coach-arrow::before { content: '↓  Share is down here'; font: 400 9px var(--font-pixel); letter-spacing: .08em; white-space: nowrap; background: #0b1b28f2; padding: 4px 8px; border-radius: 4px; border: 1px solid #ffc34480; }
.coach[data-point="up"] .coach-arrow { display: block; right: 52px; top: 6px; }
.coach[data-point="up"] .coach-arrow::before { content: 'Share is up here  ↗'; font: 400 9px var(--font-pixel); letter-spacing: .08em; white-space: nowrap; }
@keyframes coach-nudge { 50% { translate: 0 4px; } }
@media (prefers-reduced-motion: reduce) { .coach-arrow { animation: none; } }
.share-glyph { display: inline-block; padding: 0 5px; border: 1px solid #ffc34480; border-radius: 4px; color: var(--amber); font-size: 12px; line-height: 18px; }
.install-link { background: none; border: 0; padding: 6px 0; color: #8b9ba7; font: inherit; letter-spacing: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; min-height: 32px; }
.install-link:hover, .install-link:focus-visible { color: var(--amber); }

/* Circuit Run: eight-way slide pad, independent from the Fire pointer. */
#card-circuit { --cabinet: #2492ff; }
#card-circuit .screen { image-rendering: auto; }
.circuit-stick { display:grid; grid-template-columns:repeat(3,1fr); grid-template-rows:repeat(3,1fr); width:142px; height:142px; touch-action:none; border-radius:50%; background:#101a24; border:1px solid #6d9292; }
#game .circuit-stick .tb { width:44px; height:44px; margin:0; }
#game .circuit-stick [data-dir="up"] {grid-area:1/2;}
#game .circuit-stick [data-dir="left"] {grid-area:2/1;}
#game .circuit-stick [data-dir="right"] {grid-area:2/3;}
#game .circuit-stick [data-dir="down"] {grid-area:3/2;}
#card-heli { --cabinet: #2f8f3a; }
#card-heli .screen { image-rendering: auto; }
#card-sledder { --cabinet: #1e64e6; }
#card-sledder .screen { image-rendering: auto; }
#card-sledder .screen-bezel::after { display: none; } /* no scanlines on the white page */

/* Section titles in the GENERATION and TYPE sorts: marquee lettering, with the cabinet's double stripe */
.grid-head { grid-column: 1 / -1; display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px 14px; margin: 26px 0 4px; padding-bottom: 12px; border-bottom: 3px solid #cc542e; position: relative; }
.grid-head::after { content: ''; position: absolute; left: 0; right: 0; bottom: -8px; height: 2px; background: #e8a83b; }
.grid-head:first-child { margin-top: 2px; }
.gh-title { color: var(--amber); font: 400 clamp(22px, 3vw, 34px)/1.05 var(--font-marquee); letter-spacing: -.03em; text-shadow: 0 2px 0 #b74c27; }
.gh-sub { color: #c5b99c; font: 400 10px var(--font-pixel); letter-spacing: .11em; text-transform: uppercase; }


/* ---------- Arcade push-buttons ----------
   Every button in the app is a cabinet button: a bevelled cap on a dark base that sinks 3px when pressed.
   Colour comes from the --cap-* variables, so a variant is just a palette: red (SORT, the main action in
   each dialog), amber (High scores) and dark (everything secondary). Lettering is the app's button font. */
.btn, .tool, .sort-toggle, .dialog .btn {
  --cap-top: #c24a2c; --cap-bot: #8e2e1b; --cap-hi: #ee8a5f; --cap-lo: #5e1d11; --cap-base: #2a120c; --cap-ink: #ffe7ad; --cap-glow: #4a160c;
  -webkit-appearance: none; appearance: none; position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 40px; padding: 8px 16px 9px; margin-bottom: 4px; border: 2px solid var(--cap-base); border-radius: 5px;
  background: linear-gradient(var(--cap-top), var(--cap-bot)); color: var(--cap-ink);
  font: 700 13px/1.1 var(--font-ui); letter-spacing: .09em; text-transform: uppercase; text-shadow: 0 1px 0 var(--cap-glow); white-space: nowrap; cursor: pointer;
  box-shadow: inset 0 2px 0 var(--cap-hi), inset 0 -3px 0 var(--cap-lo), 0 4px 0 var(--cap-base), 0 5px 8px #0008;
  transition: transform .07s, box-shadow .07s, filter .15s, opacity .2s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active, .tool:active, .sort-toggle:active, .sort-ctl.open .sort-toggle {
  transform: translateY(3px); box-shadow: inset 0 2px 0 var(--cap-hi), inset 0 -2px 0 var(--cap-lo), 0 1px 0 var(--cap-base), 0 2px 4px #0008;
}
@media (hover: hover) { .btn:hover, .tool:hover, .sort-toggle:hover { filter: brightness(1.1); } }
.btn:focus-visible, .tool:focus-visible, .sort-toggle:focus-visible { outline: 3px solid var(--amber); outline-offset: 3px; }
.btn:disabled, .tool:disabled { opacity: .5; cursor: default; transform: none; filter: none; }
/* amber cap */
.tool-hi { --cap-top: #ffd65e; --cap-bot: #e49d24; --cap-hi: #fff1b8; --cap-lo: #a5661a; --cap-base: #3a2306; --cap-ink: #241404; --cap-glow: #ffe9a066; }
/* dark cap */
.tool, .btn.ghost, .dialog .btn.ghost { --cap-top: #20394b; --cap-bot: #132532; --cap-hi: #3d5a6d; --cap-lo: #09131b; --cap-base: #02070b; --cap-ink: #e9eef0; --cap-glow: #000; }
.tool.tool-hi { --cap-top: #ffd65e; --cap-bot: #e49d24; --cap-hi: #fff1b8; --cap-lo: #a5661a; --cap-base: #3a2306; --cap-ink: #241404; --cap-glow: #ffe9a066; }
.dialog .row .btn, .srow .btn { min-width: 112px; }
.btn.big, .dialog .btn { font-size: 14px; min-height: 46px; padding: 10px 20px 11px; }
.dialog .btn.ghost { font-size: 13px; }

/* Sound: a small speaker cap at the end of the row, out of the way */
.tool-icon { width: 40px; min-width: 40px; padding: 0; opacity: .72; }
.tool-icon:hover, .tool-icon:focus-visible { opacity: 1; }
.tool-icon .snd-off, .tool-icon[aria-pressed="false"] .snd-on { display: none; }
.tool-icon[aria-pressed="false"] .snd-off { display: inline; }
.tool-icon[aria-pressed="false"] { --cap-ink: #8d9aa3; }

/* Menu row: SORT on the left, High scores and the speaker on the right, all on one line */
.arcade-tools { flex-wrap: nowrap; }
.arcade-tools .tools { flex-wrap: nowrap; align-items: center; transition: opacity .2s steps(4, end), transform .2s steps(4, end), visibility 0s; }
.arcade-tools.sort-crowded .tools { opacity: 0; visibility: hidden; transform: translateX(24px); transition: opacity .18s steps(3, end), transform .18s steps(3, end), visibility 0s linear .18s; }

/* SORT: pressing it shoots the four choices out from behind it, one after another, in stepped (pixel) motion
   with a flash as each lands; pressing it again pulls them back in, last one first. */
.sort-ctl { display: inline-flex; align-items: center; margin: 0 auto 0 0; position: relative; flex-shrink: 0; }
.sort-toggle { z-index: 2; letter-spacing: .16em; padding-left: 15px; padding-right: 13px; }
.sort-ctl.open .sort-toggle { --cap-ink: #fff3c9; --cap-top: #d4583a; --cap-bot: #9c3520; text-shadow: 0 0 6px #ffc344, 0 1px 0 #4a160c; } /* lit while open */
.sort-menu { position: absolute; left: 100%; top: 0; bottom: 4px; display: inline-flex; align-items: center; gap: 5px; margin-left: 7px; z-index: 1; white-space: nowrap; }
.sort-ctl:not(.open) .sort-menu { pointer-events: none; } /* closed, it must not sit over High scores */

/* Small caps: the sort choices and the score-page game tabs. The chosen one is pushed in and lit. */
.sort-btn, .score-games button {
  -webkit-appearance: none; appearance: none; position: relative; min-height: 34px; padding: 6px 10px 7px; white-space: nowrap; cursor: pointer;
  border: 1px solid #03080c; border-radius: 4px; background-color: #15293a; background-image: linear-gradient(#ffffff12, #00000000 60%);
  color: #b9c6cf; font: 700 11px/1.1 var(--font-ui); letter-spacing: .08em; text-transform: uppercase;
  box-shadow: inset 0 1px 0 #3a5466, inset 0 -2px 0 #08121a, 0 2px 0 #02060a;
  transition: transform .07s, box-shadow .07s, color .15s, background-color .15s;
  -webkit-tap-highlight-color: transparent;
}
.sort-btn:active, .score-games button:active { transform: translateY(2px); box-shadow: inset 0 1px 0 #3a5466, inset 0 -1px 0 #08121a, 0 0 0 #02060a; }
@media (hover: hover) { .sort-btn:hover, .score-games button:hover { color: var(--cream); } }
.sort-btn[aria-pressed="true"], .score-games button[aria-pressed="true"] {
  transform: translateY(2px); background-color: #2b1f0b; background-image: none; color: var(--amber); text-shadow: 0 0 6px #ffc34466;
  box-shadow: inset 0 2px 3px #000a, 0 0 0 1px #c99a3a;
}
.score-games { gap: 6px; padding: 24px 2px; }
.score-games button { font-size: 12px; padding: 9px 13px 10px; }

.sort-ctl .sort-btn { min-height: 32px; padding: 6px 9px 7px; font-size: 11px;
  opacity: 0; visibility: hidden; transform: translateX(calc(-70px - var(--i) * 62px)) scale(.4);
  transition: transform .26s steps(5, end), opacity .26s steps(5, end), visibility 0s linear .32s, color .15s, background-color .15s;
  transition-delay: calc((3 - var(--i)) * 50ms), calc((3 - var(--i)) * 50ms), calc(.3s + (3 - var(--i)) * 50ms), 0s, 0s; }
.sort-ctl.open .sort-btn { opacity: 1; visibility: visible; transform: none;
  transition: transform .3s steps(6, end), opacity .3s steps(6, end), visibility 0s, color .15s, background-color .15s;
  transition-delay: calc(var(--i) * 70ms), calc(var(--i) * 70ms), 0s, 0s, 0s;
  animation: sortLand .36s steps(3, end) both; animation-delay: calc(var(--i) * 70ms + .28s); }
.sort-ctl.open .sort-btn[aria-pressed="true"] { transform: translateY(2px); animation-name: sortLandOn; }
@keyframes sortLand { 0% { background-color: #ffc344; color: #1a1206; } 50% { background-color: #3a2a0c; color: #ffe7ad; } 100% { background-color: #15293a; } }
@keyframes sortLandOn { 0% { background-color: #ffc344; color: #1a1206; } 50% { background-color: #3a2a0c; color: #ffe7ad; } 100% { background-color: #2b1f0b; } }
@media (max-width: 400px) { .sort-toggle { padding-left: 12px; padding-right: 10px; letter-spacing: .12em; } .sort-menu { gap: 4px; margin-left: 6px; } .sort-ctl .sort-btn { padding: 6px 6px 7px; font-size: 10px; letter-spacing: .05em; } }
@media (max-width: 550px) { .tool { padding: 8px 12px 9px; font-size: 12px; } .tool-icon { padding: 0; } }

/* In the games: the touch pads are round arcade buttons, the pause button a small dark cap */
.tb { background: radial-gradient(circle at 50% 34%, #ffffff30, #ffffff00 55%), color-mix(in srgb, #1f3a4c 72%, transparent);
  border: 2px solid #00000080; font-family: var(--font-ui); font-weight: 700; letter-spacing: .06em; text-shadow: 0 1px 0 #000a;
  box-shadow: inset 0 3px 0 #ffffff2a, inset 0 -4px 0 #0000005c, 0 4px 0 #000000a0;
  transition: transform .05s, box-shadow .05s, filter .05s; -webkit-tap-highlight-color: transparent; }
.tb.big { background: radial-gradient(circle at 50% 34%, #ffffff3a, #ffffff00 55%), color-mix(in srgb, #c63c26 72%, transparent); border-color: #3a0e0680; }
.tb.on { filter: brightness(1.35); transform: translateY(3px); box-shadow: inset 0 2px 0 #ffffff22, inset 0 -2px 0 #0000005c, 0 1px 0 #000000a0; }
#pauseBtn { border: 2px solid #00000090; background: linear-gradient(#20394bd0, #132532d0); color: #e9eef0;
  box-shadow: inset 0 2px 0 #3d5a6d, inset 0 -3px 0 #09131b, 0 3px 0 #000000a0; font: 700 14px var(--font-ui); -webkit-tap-highlight-color: transparent; }
#pauseBtn:active { box-shadow: inset 0 2px 0 #3d5a6d, inset 0 -2px 0 #09131b, 0 1px 0 #000000a0; translate: 0 2px; }

@media (prefers-reduced-motion: reduce) {
  .sort-btn, .sort-ctl.open .sort-btn { transition: opacity .15s, visibility 0s; transform: none; animation: none; }
  .arcade-tools .tools, .arcade-tools.sort-crowded .tools { transition: none; transform: none; }
}

/* Line Sledder save slots */
.sled-slots { z-index: 40; }
.sled-slots[hidden] { display: none; }
.sled-dialog { width: min(100%, 720px); }
.sled-note { margin: -4px 0 0; font-size: 14px; }
.slot-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 560px) { .slot-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } }
.slot { display: flex; flex-direction: column; gap: 5px; padding: 8px; border: 1px solid #2a3b48; border-radius: 6px; background: #050d14; text-align: left; }
.slot-pic { aspect-ratio: 16 / 9; border-radius: 3px; overflow: hidden; background: #fff; display: grid; place-items: center; border: 2px solid #02070b; }
.slot.empty .slot-pic { background: #0b1b28; border-style: dashed; border-color: #34414c; }
.slot-pic img { width: 100%; height: 100%; object-fit: contain; display: block; }
.slot-pic span { color: #5f7584; font: 400 9px var(--font-pixel); letter-spacing: .12em; }
.slot-name { color: var(--amber); font: 400 10px var(--font-pixel); letter-spacing: .1em; margin-top: 3px; }
.slot-meta { color: #9eafb9; font: 500 12px var(--font-ui); }
.slot-btns { display: flex; gap: 6px; margin-top: 4px; }
.slot-btns .btn, .dialog .slot-btns .btn { flex: 1; min-width: 0; min-height: 44px; padding: 6px 8px 7px; font-size: 12px; letter-spacing: .06em; }
.sled-dialog { touch-action: pan-y; }

/* Toggles (players, CPU level, cabinet settings, score difficulty): a flat strip where one lit block
   slides over to whatever you tap. Only the block's transform animates, so it costs next to nothing. */
.seg, .dialog .seg, .score-difficulty { position: relative; isolation: isolate; display: inline-flex; gap: 2px; padding: 3px; border: 1px solid #2a3b48; border-radius: 6px; background: #050d14; box-shadow: inset 0 1px 3px #0008; }
.seg.wrap { flex-wrap: wrap; justify-content: center; }
.seg button, .dialog .seg button, .score-difficulty button {
  -webkit-appearance: none; appearance: none; position: relative; z-index: 1; min-height: 40px; padding: 8px 14px; border: 0; border-radius: 4px;
  background: transparent; box-shadow: none; transform: none; color: #9fb0bb; text-shadow: none; cursor: pointer;
  font: 700 12px/1.1 var(--font-ui); letter-spacing: .08em; text-transform: uppercase; white-space: nowrap; transition: color .2s; -webkit-tap-highlight-color: transparent; }
.seg button[aria-pressed="true"], .dialog .seg button[aria-pressed="true"], .score-difficulty button[aria-pressed="true"] { background: transparent; color: #241404; }
.seg:not(.has-thumb) button[aria-pressed="true"], .score-difficulty:not(.has-thumb) button[aria-pressed="true"] { background: var(--amber); } /* before the block is placed */
@media (hover: hover) { .seg button:not([aria-pressed="true"]):hover, .score-difficulty button:not([aria-pressed="true"]):hover { color: var(--cream); } }
.seg button:disabled { opacity: .35; cursor: default; }
.seg.big button { min-height: 46px; font-size: 14px; }
.score-difficulty button { min-height: 34px; padding: 6px 12px; font-size: 11px; }
.seg-thumb { position: absolute; z-index: 0; left: 0; top: 0; width: 0; height: 0; border-radius: 4px; background: var(--amber); box-shadow: inset 0 -2px 0 #d9962a; pointer-events: none;
  transition: transform .24s cubic-bezier(.3, .8, .25, 1), width .24s cubic-bezier(.3, .8, .25, 1); will-change: transform; }
.no-anim > .seg-thumb { transition: none; }
@media (prefers-reduced-motion: reduce) { .seg-thumb { transition: none; } }
/* Line Sledder: tracks sheet (my slots + gallery) */
.sled-tabs { align-self: center; }
.sled-tabs button { min-width: 120px; }
.slot-title { display: block; width: 100%; padding: 0; margin: 0; border: 0; background: none; text-align: left; color: var(--cream); font: 700 15px/1.25 var(--font-ui); cursor: pointer; overflow-wrap: anywhere; min-height: 24px; }
.slot-title.empty { color: #7d8e99; cursor: default; }
div.slot-title { cursor: default; }
.slot-pen { color: #7d8e99; font-weight: 400; }
.slot-credit { color: #8fb7d6; font: 500 12px/1.35 var(--font-ui); }
.slot-badge { align-self: flex-start; padding: 2px 6px; border-radius: 3px; background: #10331f; color: #7fdc9b; font: 400 8px var(--font-pixel); letter-spacing: .08em; }
.slot-badge.stale { background: #3a2a0c; color: var(--amber); }
.slot-yours { margin-left: 8px; padding: 1px 5px; border-radius: 3px; background: #10331f; color: #7fdc9b; font: 400 8px var(--font-pixel); letter-spacing: .08em; vertical-align: 2px; }
.slot-form { display: flex; flex-direction: column; gap: 8px; margin: 2px 0 0; }
.slot-field { display: flex; flex-direction: column; gap: 4px; color: #9eafb9; font: 600 11px var(--font-ui); letter-spacing: .08em; text-transform: uppercase; }
.slot-field input { min-height: 44px; padding: 8px 10px; border: 1px solid #486073; border-radius: 4px; background: #0b1b28; color: var(--cream); font: 600 16px var(--font-ui); letter-spacing: 0; text-transform: none; width: 100%; box-sizing: border-box; }
.slot-field input:focus { outline: 2px solid var(--amber); outline-offset: 1px; }
.slot-warn { margin: 0; color: #b9c6cf; font: 500 12.5px/1.4 var(--font-ui); }
.slot-err { margin: 0; color: #ff8a7a; font: 600 13px/1.4 var(--font-ui); }
.slot-empty { grid-column: 1 / -1; margin: 18px 0; color: #9eafb9; text-align: center; font: 500 14px/1.5 var(--font-ui); }
.slot.gallery .slot-btns { flex-direction: column; } /* RIDE above START HERE, so the words always fit */
.slot-btns .btn, .dialog .slot-btns .btn { white-space: normal; overflow-wrap: anywhere; }

/* The small links under a dialog's buttons (How to play · Cabinet File · Controls · Leaderboard) always sit on one
   line: they shrink on narrow screens instead of dropping a single word onto its own row. */
.dialog .row.links { flex-wrap: nowrap; gap: 0 clamp(3px, 1.8vw, 14px); }
.dialog .row.links .linkbtn { flex: 0 1 auto; min-width: 0; white-space: nowrap; padding: 8px clamp(1px, .5vw, 5px); font-size: clamp(10px, 3.1vw, 14px); min-height: 40px; }

/* Cabinet File: easy to find. Its own button under Start / Back (naming the original), and the "Original:" line on
   every cabinet card opens it too. The file itself says plainly that ours is a tribute. */
.cf-ico { width: 18px; height: 18px; flex-shrink: 0; }
.dialog .row.cf-row { margin-top: -4px; }
.dialog .btn.cf-btn { --cap-ink: var(--amber); gap: 10px; min-width: min(100%, 280px); padding-top: 8px; padding-bottom: 9px; }
.cf-btn > span { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; line-height: 1.1; }
.cf-btn small { font: 600 11px var(--font-ui); letter-spacing: .02em; text-transform: none; color: #c8d3da; text-shadow: none; }
.cf-btn small:empty { display: none; }
.card-orig.cf-link { display: flex; align-items: flex-start; gap: 7px; align-self: flex-start; cursor: pointer; text-decoration: underline dotted #ffc34499; text-underline-offset: 4px; }
.card-orig.cf-link .cf-ico { width: 17px; height: 17px; margin-top: 1px; color: var(--amber); }
@media (hover: hover) { .card-orig.cf-link:hover { color: var(--amber); text-decoration-color: var(--amber); } }
.cf-tribute { margin: -4px 0 2px; padding: 8px 12px; border-left: 3px solid var(--amber); background: #0b1b28; color: #d6dee3; font: 500 14px/1.45 var(--font-ui); text-align: left; }

/* Popups on phones: only the text inside scrolls, never the arcade behind it, and the whole popup (Back button
   included) always fits the visible screen, toolbars and all. */
html:has(.sheet:not([hidden])), html:has(.sheet:not([hidden])) body, html:has(.sheet:not([hidden])) #menu, html:has(.sheet:not([hidden])) .score-page { overflow: hidden; }
.sheet { overscroll-behavior: contain; touch-action: none; }
.sheet .dialog { overscroll-behavior: contain; touch-action: pan-y; }
.manual-dialog { max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); overflow: hidden; }
.manual-dialog .manual { flex: 0 1 auto; min-height: 0; max-height: none; overscroll-behavior: contain; touch-action: pan-y; }
.manual-dialog > .row, .manual-dialog > h3, .manual-dialog > .cabinet-kicker, .manual-dialog > .cf-tribute { flex-shrink: 0; }
/* Snake's Level 1-9 row: nine narrow keys that fit a phone */
.dialog .level-seg button { min-width: 0; width: clamp(28px, 8vw, 40px); padding: 8px 0; font-size: 14px; letter-spacing: 0; }

/* High scores: a visible cabinet directory beside a compact record board. */
.score-wrap { max-width: 1120px; }
.score-header { padding-bottom: 22px; }
.score-layout { display: grid; grid-template-columns: 280px minmax(0,1fr); gap: 28px; align-items: start; margin-top: 28px; }
.score-picker { min-width: 0; }
.score-picker-title { display: flex; justify-content: space-between; align-items: center; margin: 0 0 16px; color: var(--cream); font: 700 15px var(--font-ui); text-transform: uppercase; letter-spacing: .09em; }
.score-picker-title span { color: #8ba1af; font: 10px var(--font-pixel); }
.score-games { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); overflow: visible; padding: 0 2px 4px; gap: 9px; }
.score-games button { display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 7px; min-height: 64px; padding: 10px 11px; white-space: normal; text-align: left; font-size: 12px; line-height: 1.2; letter-spacing: .02em; }
.score-games button[aria-pressed="true"] { border-left: 3px solid var(--amber); padding-left: 9px; }
.score-game-year { font: 9px var(--font-pixel); color: #8da5b5; }
.score-games button[aria-pressed="true"] .score-game-year { color: #d3a95b; }
.score-picker-note { margin-top: 22px; color: #78909f; font: 8px/1.7 var(--font-pixel); letter-spacing: .02em; }
.score-cabinet { padding: 24px; border-top: 3px solid var(--amber); min-width: 0; background: linear-gradient(145deg,#0b1b27,#030b12 45%); box-shadow: 0 12px 30px #0003; }
.score-heading { display: flex; align-items: center; gap: 18px; min-width: 0; }
#boardPreview { width: 100px; height: 80px; flex-shrink: 0; background: #000; border: 1px solid #2d414d; border-radius: 4px; image-rendering: pixelated; }
.score-eyebrow { margin: 0 0 8px; color: #e6ae55; font: 9px/1.6 var(--font-pixel); }
.score-controls { margin-bottom: 24px; flex-wrap: wrap; }
.score-controls h2 { font-size: clamp(20px,2.5vw,29px); }
.score-original { margin: 7px 0 0; color: #93a9b8; font: 12px/1.5 var(--font-ui); }
.score-table { font-size: 12px; }
.score-table th { padding: 9px 10px 14px; font-size: 9px; }
.score-table th:first-child { width: 12%; }
.score-table td { padding: 13px 10px; }
.score-table tbody tr:first-child { background: #ffc3440e; }
.score-table tbody tr:first-child .rk { border-left: 2px solid var(--amber); }
.score-table .nm { width: 45%; }
.score-foot { text-align: right; font-size: 8px; line-height: 1.8; }
.score-mobile-picker { display: none; }
@media(max-width:760px) {
  .score-header { gap: 16px; padding: 0 0 20px; }
  .score-header h1 { font-size: clamp(24px,6vw,34px); }
  .score-star { display: none; }
  .score-layout { display: block; margin-top: 20px; }
  .score-picker-title,.score-picker-note,#boardGame { display: none; }
  .score-mobile-picker { display: flex; align-items: center; gap: 16px; color: #a2b4bf; font: 10px var(--font-pixel); margin: 0 0 18px; }
  #boardSelect { flex: 1; min-width: 0; min-height: 48px; padding: 10px 14px; color: var(--cream); background: #142b3a; border: 1px solid #426071; border-radius: 4px; font: 700 16px var(--font-ui); }
  .score-cabinet { padding: 18px 12px; }
  .score-heading { gap: 12px; }
  #boardPreview { width: 64px; height: 56px; }
  .score-controls { margin-bottom: 19px; }
  .score-controls h2 { font-size: 21px; }
  .score-original { font-size: 11px; }
  .score-eyebrow { font-size: 8px; }
  .score-table { font-size: 10px; }
  .score-table td { padding: 14px 5px; }
  .score-table th { font-size: 8px; padding: 8px 5px 12px; }
  .score-table .dt { font-size: 10px; }
  .score-table .nm { width: auto; }
  .score-foot { text-align: center; font-size: 7px; }
}
/* Each game's record holder beside its year in the high-scores directory */
.score-game-top { margin-left: 8px; color: #c9b27a; }
.score-game-top::before { content: '· '; color: #5f7584; }
.score-games button[aria-pressed="true"] .score-game-top { color: var(--amber); }
