@font-face {
  font-family: "Obcoro Pixel";
  src: url("../../assets/fusion-pixel-12px-monospaced-zh_tw.ttf.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

:root {
  --bg: #030909;
  --panel: #040b09f7;
  --ink: #70f995;
  --bright: #9affb1;
  --muted: #599d72;
  --line: #2a6940;
  --accent: #fa785c;
  --accent-line: #d45b43;
  color-scheme: dark;
  font: 16px/1.5 "Obcoro Pixel", monospace;
  font-synthesis: none;
  color: var(--ink);
  background: var(--bg);
}

* { box-sizing: border-box; }
html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template: minmax(0, 1fr) / minmax(0, 1fr);
  place-items: center;
  padding: calc(.5rem + env(safe-area-inset-top, 0px)) calc(.5rem + env(safe-area-inset-right, 0px))
           calc(.5rem + env(safe-area-inset-bottom, 0px)) calc(.5rem + env(safe-area-inset-left, 0px));
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

main {
  display: grid;
  grid-template: auto minmax(44px, 1fr) auto / minmax(0, 1fr);
  gap: .5rem;
  width: min(100%, 45rem);
  height: 100%;
  min-width: 0;
  min-height: 0;
}
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
}
h1 {
  flex: none;
  margin: 0;
  color: var(--bright);
  font-size: clamp(1.75rem, 8vw, 2.25rem);
  font-weight: 400;
  line-height: 1.2;
}
.readout {
  display: grid;
  justify-items: end;
  min-width: 0;
  line-height: 1.35;
  text-align: right;
}
#level { color: var(--muted); white-space: nowrap; }
#status { min-height: 1.35em; margin: 0; color: var(--ink); font-size: .8125rem; }
#status.hit { color: var(--accent); }
footer {
  color: var(--muted);
  font-size: .75rem;
  line-height: 1.5;
  text-align: center;
}

#board {
  --frame: var(--line);
  --trim: var(--muted);
  appearance: none;
  position: relative;
  display: block;
  overflow: hidden;
  width: 100%;
  height: 100%;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border: 1px solid var(--frame);
  border-radius: 0;
  background: var(--panel);
  font: inherit;
  cursor: pointer;
  touch-action: none;
}
#board::before, #board::after {
  content: "";
  position: absolute;
  width: 11px;
  height: 11px;
  border: solid var(--trim);
  pointer-events: none;
  transition: transform 110ms cubic-bezier(.15, 1.4, .4, 1);
}
#board::before { left: 5px; top: 5px; border-width: 1px 0 0 1px; transform-origin: top left; }
#board::after { right: 5px; bottom: 5px; border-width: 0 1px 1px 0; transform-origin: bottom right; }
#board.pressed::before, #board.pressed::after { transform: scale(.72); transition: none; }
#board:focus-visible { outline: 2px solid var(--bright); outline-offset: 3px; }
#board.pressed { --trim: var(--bright); }
#board[data-state="won"] { --frame: var(--muted); --trim: var(--bright); }
#board[data-state="lost"] {
  --frame: var(--accent-line);
  --trim: var(--accent);
  background: #150e0c;
}
#board:disabled { cursor: default; }
#board > canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  pointer-events: none;
}
#status[data-warning="true"] { color: var(--accent); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

@media (min-width: 48rem) {
  main { max-height: 44rem; gap: .75rem; }
  .readout { display: flex; align-items: baseline; gap: .875rem; }
  #status { font-size: .875rem; }
}
@media (max-height: 28rem) {
  main { gap: .25rem; }
  h1 { font-size: 1.5rem; }
}
@media (prefers-reduced-motion: reduce) {
  #board.pressed::before, #board.pressed::after { transform: none; }
  #board::before, #board::after { transition: none; }
}
