:root {
  color-scheme: light;
  --paper: #ecedf9;
  --ink: #272044;
  --muted: #575272;
  --rule: #c3bfd9;
  --violet: #6349b6;
  --panel: #fff;
  --type: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --numbers: "Courier New", monospace;
  font-family: var(--type);
  color: var(--ink);
  background: var(--paper);
  -webkit-tap-highlight-color: #6349b633;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; background-image: radial-gradient(#b3acd54f 1px, transparent 1px); background-size: 20px 20px; }
h1, h2, p, ol, dl, dd { margin: 0; }
h1, h2 { line-height: 1.2; text-wrap: balance; }
a { color: inherit; }
button, input, select { font: inherit; }
button, a, select { touch-action: manipulation; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .52; }
:focus-visible { outline: 3px solid var(--violet); outline-offset: 5px; }
main:focus { outline: none; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip { position: fixed; top: .75rem; left: .75rem; z-index: 3; padding: .7rem 1rem; background: white; border: 2px solid; transform: translateY(-150%); }
.skip:focus { transform: none; }
.shell { width: min(100% - 44px, 66rem); margin-inline: auto; }
.lobby { padding-block: clamp(3rem, 8vh, 6rem) 4.5rem; }
.lobby-head { display: grid; grid-template-columns: auto 1fr; align-items: center; column-gap: 1.15rem; margin-bottom: clamp(1.6rem, 3.5vw, 2.5rem); }
.lobby-head h1 { font-size: clamp(2.65rem, 7vw, 5.25rem); letter-spacing: -.075em; font-weight: 900; }
.lobby-head p { grid-column: 2; margin-top: .65rem; font-size: 1.07rem; color: var(--muted); }
.brand-mark { width: clamp(2.3rem, 5vw, 3.6rem); aspect-ratio: 1; display: grid; place-items: center; background: #d9cdfa; border: 2px solid var(--ink); border-radius: 24% 24% 29% 29%; box-shadow: 0 4px var(--ink); transform: rotate(-8deg); }
.brand-mark::before { content: ""; width: 48%; height: 48%; background: var(--ink); clip-path: polygon(34% 0,66% 0,66% 34%,100% 34%,100% 66%,66% 66%,66% 100%,34% 100%,34% 66%,0 66%,0 34%,34% 34%); }
.machines { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(1.25rem, 4vw, 2.6rem); }
.bomb { --case: #ffc09e; --shadow: #a95d47; --screen: #302031; --light: #ffad85; }
.snake { --case: #c3edac; --shadow: #567e4c; --screen: #142d27; --light: #a9ed80; }
.cabinet, .game-cabinet { background: var(--case); border: 2px solid var(--ink); box-shadow: 0 7px 0 -1px var(--shadow), 0 9px 0 -1px var(--ink); }
.cabinet { min-width: 0; display: flex; flex-direction: column; padding: clamp(.8rem, 2.3vw, 1.45rem); border-radius: 22px 22px 13px 13px; text-decoration: none; transition: transform .16s ease; }
.cabinet:hover { transform: translateY(-4px); }
.cabinet:active { transform: translateY(3px); }
.marquee { display: flex; justify-content: space-between; align-items: center; gap: .75rem; padding: .1rem .35rem .85rem; }
.marquee h2 { font-size: clamp(1.3rem, 3.1vw, 2rem); font-weight: 850; letter-spacing: -.045em; }
.lamp { width: .8rem; height: .8rem; flex: none; border: 2px solid var(--ink); border-radius: 50%; background: #fff8df; box-shadow: inset 0 -2px var(--shadow); }
.preview { position: relative; aspect-ratio: 1.53; display: grid; place-content: center; border: 4px solid var(--ink); border-radius: 12px; overflow: hidden; box-shadow: inset 0 0 0 2px #ffffff35; background-color: var(--screen); color: var(--light); }
.bomb-preview, .bomb-screen { background-image: repeating-linear-gradient(0deg, transparent 0 4px, #0002 4px 5px); }
.preview-number { display: block; font: 900 clamp(4rem, 14vw, 9.5rem)/.9 var(--numbers); letter-spacing: -.12em; padding-right: .12em; text-shadow: 4px 4px #8b504f; transform: rotate(-6deg); }
.preview-ticks { display: flex; gap: .35rem; justify-content: center; margin-top: clamp(.45rem, 1.7vw, 1.3rem); }
.preview-ticks i { width: clamp(.4rem, 1.2vw, .75rem); height: .32rem; background: var(--light); }
.snake-preview { background-image: linear-gradient(#b5ed9c1f 1px, transparent 1px), linear-gradient(90deg, #b5ed9c1f 1px, transparent 1px); background-size: 20px 20px; background-position: center; }
.pixel-art { --cell: clamp(16px, 4.7vw, 40px); display: grid; grid-template: repeat(4, var(--cell)) / repeat(8, var(--cell)); }
.pixel-art i { display: block; background: #a9ed80; box-shadow: inset -3px -4px #0003; }
.pixel-art .pixel-tail { grid-area: 4 / 1 / 5 / 4; border-radius: 14px 0 0 14px; background: #82c868; }
.pixel-art .pixel-turn { grid-area: 2 / 3 / 5 / 4; border-radius: 10px 0 6px 0; }
.pixel-art .pixel-body { grid-area: 2 / 4 / 3 / 5; }
.pixel-art .pixel-head { grid-area: 2 / 5 / 3 / 6; border-radius: 0 8px 8px 0; position: relative; }
.pixel-head::after { content: ""; position: absolute; width: 16%; aspect-ratio: 1; top: 23%; right: 23%; background: #142d27; box-shadow: 0 .4em #142d27; }
.pixel-art .pixel-food { grid-area: 2 / 8 / 3 / 9; place-self: center; width: 65%; aspect-ratio: 1; border-radius: 28%; background: #ff937d; }
.cabinet-foot { display: flex; justify-content: space-between; align-items: center; gap: .6rem; padding: .9rem .15rem .1rem; flex: 1; }
.cabinet-foot p { font-size: .95rem; line-height: 1.55; }
.play-icon { flex: none; width: 2.5rem; height: 2.5rem; display: grid; place-items: center; padding-left: .12rem; border: 2px solid var(--ink); border-radius: 50%; background: var(--ink); color: white; font-size: .9rem; box-shadow: 0 3px var(--shadow); }
.cabinet:hover .play-icon { background: white; color: var(--ink); }
.game { padding-block: clamp(1.6rem, 4vh, 3rem) 3.5rem; }
.back { display: inline-flex; gap: .5rem; align-items: center; min-height: 44px; font-size: .92rem; font-weight: 750; text-decoration: underline; text-underline-offset: .24em; }
.back:hover { color: var(--violet); }
.game h1 { margin: .3rem 0 1.35rem; font-size: clamp(2.15rem, 6vw, 3.9rem); letter-spacing: -.065em; font-weight: 900; }
.game-layout { display: grid; grid-template-columns: minmax(0, 32rem) minmax(0, 20rem); align-items: start; gap: clamp(1.4rem, 4vw, 3rem); }
.game-cabinet { border-radius: 19px 19px 12px 12px; padding: clamp(.75rem, 2.25vw, 1.35rem); min-width: 0; }
.game-notes { padding-top: .9rem; border-top: 2px solid var(--ink); }
.game-notes h2 { font-size: 1.2rem; margin-bottom: .6rem; }
.game-notes p { line-height: 1.7; color: var(--muted); }
.game-notes p + h2, .game-notes label { margin-top: 1.5rem; }
.bomb-screen { background-color: var(--screen); border-radius: 10px; color: var(--light); text-align: center; padding: 1.2rem .45rem; }
.bomb-screen h2, .bomb-screen p { font-size: .95rem; font-weight: 650; }
.range { display: flex; justify-content: center; align-items: baseline; gap: .19em; font: 800 clamp(2.5rem, 10vw, 5.05rem)/1.05 var(--numbers); margin-block: .55rem .5rem; font-variant-numeric: tabular-nums; }
.range-dash { font-size: .63em; }
.fuse { display: flex; gap: .35rem; justify-content: center; margin-bottom: .6rem; }
.fuse span { width: clamp(.85rem, 4vw, 1.6rem); height: .55rem; background: var(--light); border: 1px solid var(--light); border-radius: 2px; }
.fuse [data-used="true"] { background: transparent; opacity: .64; }
#bomb-form { margin-top: 1rem; }
label { display: block; font-weight: 750; margin-bottom: .4rem; }
.form-row { display: flex; gap: .5rem; align-items: stretch; }
input, select { min-height: 44px; border: 2px solid var(--ink); background: #fff; color: var(--ink); border-radius: 7px; padding: .5rem .75rem; }
input { width: 100%; min-width: 0; }
input[aria-invalid="true"] { border-color: #8b2433; }
input:disabled { opacity: .6; }
.dark-button, .bright-button, .plain-button, .dpad button { min-height: 44px; border: 2px solid var(--ink); border-radius: 7px; padding: .42rem .85rem; font-weight: 750; }
.dark-button { background: var(--ink); color: #fff; flex: none; }
.dark-button:hover:not(:disabled) { background: #4b3a75; }
.plain-button { background: transparent; color: var(--ink); }
.plain-button:hover:not(:disabled), .dpad button:hover { background: #ffffffb3; }
.bomb-status { margin-block: .55rem .65rem; min-height: 1.6em; line-height: 1.5; }
.bomb-status[data-tone="error"], .bomb-status[data-tone="loss"] { color: #7f1c28; font-weight: 750; }
.bomb-status[data-tone="win"] { color: #1a482d; font-weight: 750; }
.history { color: var(--ink); padding-inline-start: 1.45rem; font-variant-numeric: tabular-nums; }
.history li { padding: .4rem .2rem; border-bottom: 1px solid var(--rule); }
.game-notes:has(.history li) .history-empty { display: none; }
.snake-layout { grid-template-columns: minmax(0, 28rem) minmax(0, 20rem); }
.scoreboard { display: flex; gap: .75rem 1.15rem; justify-content: space-between; flex-wrap: wrap; margin-bottom: .55rem; }
.scoreboard div { display: flex; align-items: baseline; gap: .45rem; }
.scoreboard dt { font-size: .85rem; font-weight: 750; }
.scoreboard dd { font: 800 1.5rem/1 var(--numbers); font-variant-numeric: tabular-nums; }
.board-wrap { border: 3px solid var(--ink); border-radius: 9px; overflow: hidden; position: relative; background: var(--screen); }
canvas { display: block; width: 100%; height: auto; }
.board-overlay { position: absolute; inset: 0; display: grid; place-items: center; background: #142d27ad; padding: .6rem; }
.overlay-card { text-align: center; border: 1px solid #b5ed9c; border-radius: 10px; background: #142d27; color: #f2ffe9; padding: clamp(.65rem, 2.6vw, 1.35rem); max-width: 100%; }
.overlay-card h2 { font-size: clamp(1.15rem, 4vw, 1.65rem); }
.overlay-card p { font-size: .9rem; margin-block: .45rem .7rem; }
.bright-button { background: var(--light); color: #142d27; border-color: var(--light); }
.bright-button:hover { background: #dcffc8; }
.bright-button:focus-visible { outline-color: #fff; }
.snake-controls { display: flex; gap: .5rem 1rem; flex-wrap: wrap; align-items: end; justify-content: space-between; margin-top: .7rem; }
.dpad { display: grid; grid-template-columns: repeat(3, minmax(44px, auto)); gap: .25rem; }
.dpad button { padding: 0; background: #ecf9e5; color: var(--ink); font-size: 1.2rem; }
.dpad button:first-child { grid-column: 2; }
.dpad button:nth-child(2) { grid-column: 1; }
@media (max-width: 43rem) {
  .game-layout { grid-template-columns: minmax(0, 1fr); }
  .game-cabinet { max-width: 32rem; }
  .game-notes { margin-top: .5rem; }
}
@media (max-width: 37rem) {
  .machines { grid-template-columns: minmax(0, 1fr); }
  .lobby { padding-top: 2.4rem; }
  .preview { aspect-ratio: 1.85; }
  .preview-number { font-size: clamp(4.4rem, 21vw, 7rem); }
  .pixel-art { --cell: clamp(19px, 7.6vw, 34px); }
}
@media (max-width: 21rem) {
  .shell { width: calc(100% - 28px); }
  .range { font-size: 2.4rem; }
}
@media (prefers-reduced-motion: reduce) {
  .cabinet { transition: none; }
}
