@font-face {
  font-family: Monitor;
  src: local("Monitor Normal"), local("Monitor-Normal");
  font-style: normal;
  font-weight: 400;
}
@font-face {
  font-family: Monitor;
  src: local("Monitor SemiBold"), local("Monitor-SemiBold");
  font-style: normal;
  font-weight: 600;
}
@font-face {
  font-family: Monitor;
  src: local("Monitor Bold"), local("Monitor-Bold");
  font-style: normal;
  font-weight: 700;
}
:root {
  color-scheme: light;
  --page: #fff;
  --field: #141414;
  --ink: #151515;
  --muted: #535353;
  --line: #c9c9c9;
  --accent: #151515;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --type: Monitor, system-ui, sans-serif;
  font: 16px/1.5 var(--type);
}
* { box-sizing: border-box; }
@media (min-width: 641px) { html { scrollbar-gutter: stable both-edges; } }
body { margin: 0; min-width: 290px; background: #000; color: var(--ink); }
#page-wall { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.shell {
  --arena-width: min(calc((100svh - 32px) * 9 / 16), 440px);
  --arena-height: calc((var(--arena-width) - 2px) * 16 / 9 + 2px);
  position: relative;
  min-height: 100svh;
  padding: max(16px, calc((100svh - var(--arena-height)) / 2)) 12px 16px;
}
#arena { width: var(--arena-width); margin-inline: auto; border: 1px solid #fff; }
.stage { position: relative; aspect-ratio: 9 / 16; background: var(--field); color-scheme: dark; }
#play-view, #result { position: absolute; inset: 0; }
#play-view {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
#play-view[inert] { pointer-events: none; }
#field { width: 100%; height: 100%; display: block; touch-action: none; }
#field.engaged { cursor: none; }
.cross { position: absolute; font: 14px/1 var(--mono); color: #999; pointer-events: none; }
.cross.tl, .cross.tr { display: none; }
.bl { bottom: 12px; left: 13px; } .br { bottom: 12px; right: 13px; }
.prompt { position: absolute; bottom: 49px; inset-inline: 20px; text-align: center; pointer-events: none; margin: 0; color: #ccc; font: 500 .75rem/1.35 var(--mono); letter-spacing: .115em; text-shadow: 0 1px 3px #111; }
button { font: inherit; font-size: .88rem; font-weight: 600; border: 1px solid var(--line); color: var(--ink); background: transparent; padding: .65rem .85rem; cursor: pointer; }
button:hover { border-color: var(--accent); }
button:disabled { opacity: .65; cursor: wait; }
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
button:focus-visible, a:focus-visible, canvas:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
#result { z-index: 3; background: #000; }
#result:focus-visible { outline: 2px solid #fff; outline-offset: -4px; }
#card { width: 100%; height: 100%; display: block; object-fit: contain; }
#show-card-actions { position: absolute; z-index: 1; bottom: max(12px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); color: #fff; background: #000; padding: .4rem .8rem; font: 600 12px/1.3 var(--mono); white-space: nowrap; border: 1px solid #fff9; }
#show-card-actions:hover, #show-card-actions:focus-visible { border-color: #fff; }
#show-card-actions:focus-visible { outline-color: #fff; }
#result-actions { padding: 14px; background: var(--page); }
.actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.actions button { padding-inline: .4rem; }
#download-status { font-size: .83rem; margin: 8px 0 0; color: var(--muted); }
#download-status:empty { margin: 0; }
.print-button { display: block; margin-top: 10px; background: #151515; color: #fff; padding: .8rem 1rem; text-decoration: none; font-size: .9rem; font-weight: 700; text-align: center; }
.print-button:hover { background: #444; }
.print-description, .print-note { font-size: .83rem; color: var(--muted); margin: 10px 0 0; }
.print-note { color: #707070; font-weight: 400; text-align: center; }
.print-note span { -webkit-user-select: all; user-select: all; }
#play-view .game-hud, #play-view .cross, #play-view::after { opacity: calc(1 - var(--card-reveal, 0)); }

.game-hud { position: absolute; inset: 22px 20px auto; z-index: 1; display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; color: #fff; pointer-events: none; }
.game-brand { pointer-events: auto; }
.game-brand:focus-visible { outline-color: #fff; }
#game-logo { display: block; width: 79px; height: auto; }
.game-progress { display: grid; gap: 3px; text-align: right; font: 10px/1.3 var(--mono); letter-spacing: .04em; }
.game-progress strong { font-size: 17px; font-weight: 500; }
#game-sequence { color: #bbb; font-size: 11px; letter-spacing: 0; }
@media (max-width: 640px) {
  #page-wall { display: none; }
  .shell { --arena-width: 100%; padding: 0; }
  #arena { border: 0; }
  .stage { height: 100svh; aspect-ratio: auto; }
  #show-card-actions { min-height: 44px; }
  #result { container-type: size; }
  #result::after {
    content: "";
    position: absolute;
    inset: 0;
    margin: auto;
    width: min(100cqw, calc(100cqh * 9 / 16));
    height: min(100cqh, calc(100cqw * 16 / 9));
    pointer-events: none;
    box-shadow: inset 0 0 0 1px #fff;
  }
}

#start-game { position: absolute; z-index: 2; top: 50%; left: 50%; transform: translate(-50%, -50%); border: 0; color: #fff; background: radial-gradient(ellipse, #141414 37%, #14141400 76%); padding: 1.1rem 1.6rem; font: 700 clamp(1.5rem, 6vw, 2.25rem)/1 var(--type); text-shadow: 0 2px 12px #000; white-space: nowrap; }
#start-game:focus-visible { outline-color: #fff; }

#play-view::after { content: ""; position: absolute; z-index: 0; inset: 0; pointer-events: none; background: linear-gradient(to bottom, #090909f5, #090909bb 62px, #09090900 148px), linear-gradient(to right, #09090955, transparent 42px, transparent calc(100% - 42px), #09090955), linear-gradient(to top, #09090982, transparent 34px); }
@media (prefers-reduced-motion: no-preference) {
  #result-actions:not([hidden]) { animation: card-appear .32s ease-out both; }
}
@keyframes card-appear { from { opacity: 0; } to { opacity: 1; } }
