@font-face {
  font-family: "Noto Sans SC";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/noto-sans-sc-400.woff2") format("woff2");
}

@font-face {
  font-family: "Noto Sans SC";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("fonts/noto-sans-sc-700.woff2") format("woff2");
}

@font-face {
  font-family: "Share Tech Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/share-tech-mono-400.woff2") format("woff2");
}

:root {
  color-scheme: dark;
  --bg: #141710;
  --ink: #ebe6d6;
  --muted: #b7b09d;
  --brass: #e0c99a;
  --brass-ink: #241c12;
  --panel: #1c2118;
  --line: #34392d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100dvh;
  color: var(--ink);
  background:
    radial-gradient(ellipse 90% 50% at 50% -12%, rgba(214, 186, 120, 0.18), transparent 52%),
    radial-gradient(ellipse 46% 36% at 100% 100%, rgba(78, 98, 62, 0.28), transparent 60%),
    var(--bg);
  font-family: "Noto Sans SC", "PingFang SC", "Noto Sans CJK SC", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif;
  font-weight: 400;
}

button,
input {
  font: inherit;
}

.page {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 28px 16px 56px;
}

.mast h1 {
  margin: 4px 0 8px;
  font-size: clamp(40px, 7vw, 68px);
  font-weight: 700;
  letter-spacing: 0.06em;
  line-height: 1;
}

.eyebrow {
  margin: 0;
  color: var(--brass);
  font-size: 13px;
  letter-spacing: 0.28em;
}

.lede {
  margin: 0;
  max-width: 36em;
  color: #d5d0c2;
  font-size: 16px;
  line-height: 1.6;
}

.other-game {
  color: var(--brass);
  font-weight: 700;
}

.diffs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 22px 0 18px;
}

.diff {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-height: 56px;
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid #3c4336;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.diff span {
  font-size: 12px;
  color: var(--muted);
}

.diff.is-on {
  background: var(--brass);
  border-color: var(--brass);
  color: var(--brass-ink);
}

.diff.is-on span {
  color: #5c4b32;
}

.diff:focus-visible,
#face:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 2px;
}

.layout {
  display: grid;
  gap: 18px;
  align-items: start;
}

.cabinet {
  position: relative;
  min-width: 0;
  max-width: 100%;
  padding: 16px;
  border-radius: 22px;
  background: linear-gradient(180deg, #75664e 0%, #403628 36%, #2a241c 100%);
  box-shadow:
    0 24px 50px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 236, 210, 0.45);
}

.cabinet.is-lost {
  box-shadow:
    0 0 0 1px rgba(194, 65, 45, 0.7),
    0 24px 50px rgba(0, 0, 0, 0.35);
}

.cabinet.is-won {
  box-shadow:
    0 0 0 1px rgba(224, 201, 154, 0.85),
    0 24px 50px rgba(0, 0, 0, 0.35);
}

.screw {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #f3ead8, #8d7d62 46%, #3a3228 72%);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35);
}

.screw.a { top: 8px; left: 8px; }
.screw.b { top: 8px; right: 8px; }
.screw.c { bottom: 8px; left: 8px; }
.screw.d { bottom: 8px; right: 8px; }

.panel {
  background: #171b14;
  border-radius: 14px;
  padding: 12px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.45);
}

.hud {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
}

.meter {
  display: grid;
  justify-items: center;
  gap: 4px;
}

.meter span {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.18em;
}

.lcd {
  min-width: 4.8rem;
  padding: 2px 10px 4px;
  border-radius: 6px;
  background: #070907;
  color: #c6f25c;
  font-family: "Share Tech Mono", ui-monospace, monospace;
  font-size: 34px;
  line-height: 1.1;
  letter-spacing: 0.08em;
  text-align: right;
  text-shadow: 0 0 10px rgba(198, 242, 92, 0.45);
  box-shadow:
    inset 0 0 0 1px #000,
    inset 0 2px 8px rgba(0, 0, 0, 0.65);
}

.lcd.is-neg {
  color: #ffb4a8;
  text-shadow: 0 0 10px rgba(255, 140, 120, 0.35);
}

#face {
  width: 62px;
  height: 62px;
  padding: 6px;
  border: 0;
  border-radius: 10px;
  background: linear-gradient(180deg, #f3dc96, #e0b85a);
  box-shadow:
    inset 0 1px 0 #fff1c9,
    0 2px 0 #6a5428;
  cursor: pointer;
}

#face:active {
  transform: translateY(1px);
}

#face svg,
.face {
  display: block;
  width: 100%;
  height: 100%;
}

.status {
  min-height: 1.5em;
  margin: 10px 4px;
  color: #d9d3c4;
  font-size: 14px;
  text-align: center;
}

.cabinet.is-lost .status {
  color: #ffb4a8;
}

.cabinet.is-won .status {
  color: #e7d7a8;
}

.well {
  overflow: auto;
  max-width: 100%;
  padding: 8px;
  border-radius: 8px;
  background: #0c0e0a;
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.55);
}

.well::-webkit-scrollbar {
  height: 10px;
  width: 10px;
}

.well::-webkit-scrollbar-thumb {
  background: #4a4336;
  border-radius: 99px;
}

.board {
  --cell: 44px;
  --cols: 9;
  display: grid;
  grid-template-columns: repeat(var(--cols), var(--cell));
  grid-auto-rows: var(--cell);
  gap: 3px;
  width: max-content;
  margin-inline: auto;
}

.board[data-tier="mid"] {
  --cell: 34px;
}

.board[data-tier="wide"] {
  --cell: 30px;
}

.cell {
  position: relative;
  display: grid;
  place-items: center;
  width: var(--cell);
  height: var(--cell);
  padding: 0;
  border: 0;
  border-radius: 2px;
  color: inherit;
  line-height: 1;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.cell-raised {
  background: linear-gradient(145deg, #747c66 0%, #525944 52%, #3c4236 100%);
  box-shadow:
    inset 1.5px 1.5px 0 #9aa38c,
    inset -1.5px -1.5px 0 #262b22;
}

@media (hover: hover) {
  .cell-raised:hover {
    filter: brightness(1.07);
  }
}

.cell-raised.is-down,
.cell-open,
.cell-mine {
  background: #d5ccba;
  box-shadow: inset 0 0 0 1px rgba(80, 68, 46, 0.16);
  filter: none;
}

.cell-hit {
  background: #c2412d;
  box-shadow: inset 0 0 0 1px rgba(80, 20, 12, 0.25);
}

.cell-wrong {
  background: #e7cfc3;
  box-shadow: inset 0 0 0 1px rgba(120, 50, 40, 0.18);
}

.cell:focus {
  outline: none;
}

.cell:focus-visible {
  outline: 2px solid #e6c98a;
  outline-offset: 1px;
  z-index: 1;
}

.glyph,
.cross {
  width: 68%;
  height: 68%;
  pointer-events: none;
}

.cross {
  position: absolute;
  inset: 0;
  width: 78%;
  height: 78%;
  margin: auto;
}

.num {
  font-weight: 700;
  font-size: calc(var(--cell) * 0.56);
}

.q {
  color: #8a5a12;
  font-weight: 700;
  font-size: calc(var(--cell) * 0.5);
}

.n1 { color: #1d4ed8; }
.n2 { color: #15703a; }
.n3 { color: #d12424; }
.n4 { color: #1e3a8a; }
.n5 { color: #9f1239; }
.n6 { color: #0f766e; }
.n7 { color: #292524; }
.n8 { color: #57534e; }

.aside {
  display: grid;
  gap: 14px;
}

.card {
  padding: 14px 16px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(28, 33, 24, 0.92);
}

.card h2 {
  margin: 0 0 10px;
  font-size: 15px;
  font-weight: 700;
}

.records {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.records li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
}

.records strong {
  font-weight: 700;
}

.rules {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 1.2em;
  color: #ddd6c6;
  font-size: 14px;
  line-height: 1.55;
}

.fine {
  margin: 10px 0 0;
  color: #9c9686;
  font-size: 12px;
  line-height: 1.6;
}

kbd {
  display: inline-block;
  padding: 0 5px;
  border: 1px solid #4a5144;
  border-bottom-width: 2px;
  border-radius: 4px;
  color: #f0e6d0;
  font-family: "Share Tech Mono", ui-monospace, monospace;
  font-size: 12px;
}

.noscript {
  padding: 16px;
  text-align: center;
}

@media (max-width: 720px) {
  .page {
    padding: 18px 10px 48px;
  }

  .cabinet {
    padding: 10px;
  }

  .panel {
    padding: 8px;
  }

  .well {
    padding: 6px;
  }

  .board[data-tier="small"] {
    --cell: min(40px, calc((100vw - 96px) / 9));
  }

  .board[data-tier="mid"] {
    --cell: 30px;
  }

  .board[data-tier="wide"] {
    --cell: 32px;
  }

  .lcd {
    min-width: 4.2rem;
    font-size: 28px;
  }

  #face {
    width: 54px;
    height: 54px;
  }
}

@media (min-width: 1180px) {
  .layout {
    grid-template-columns: minmax(0, 1fr) 250px;
  }
}

@media (prefers-reduced-motion: reduce) {
  #face:active {
    transform: none;
  }
}
