@font-face {
  font-family: GameUI;
  src: url("../fonts/GameUI.woff2") format("woff2");
  font-display: swap;
}
@font-face {
  font-family: BrushUI;
  src: url("../fonts/BrushUI.woff2") format("woff2");
  font-display: swap;
}
@font-face {
  font-family: GameJP;
  src: url("../fonts/GameJP.woff2") format("woff2");
  font-display: swap;
}
@font-face {
  font-family: BrushJP;
  src: url("../fonts/BrushJP.woff2") format("woff2");
  font-display: swap;
}
:root:lang(ja) {
  font-family: GameJP, GameUI, monospace;
}
:root {
  color-scheme: dark;
  --bg: #080c13;
  --surface: #151e2b;
  --edge: #566272;
  --ink: #eee7d4;
  --muted: #b5bfcb;
  --gold: #efc05d;
  font-family: GameUI, monospace;
  background: var(--bg);
  color: var(--ink);
}
* {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
  margin: 0;
}
body {
  display: grid;
  grid-template-rows: 44px minmax(0, 1fr) 58px;
  overflow: hidden;
}
button {
  font: inherit;
  cursor: pointer;
  min-height: 32px;
  padding: 5px 13px;
  background: var(--surface);
  color: var(--ink);
  border: 2px solid var(--edge);
  box-shadow:
    inset 2px 2px #ffffff12,
    inset -2px -2px #0008;
  border-radius: 0;
}
button:hover {
  border-color: var(--gold);
  color: var(--gold);
}
button:active {
  transform: translateY(1px);
  box-shadow: inset 2px 2px #0008;
}
button:focus-visible {
  outline: 2px solid #82d7fa;
  outline-offset: 3px;
}
button:disabled {
  opacity: 0.45;
  cursor: default;
}
button.primary {
  background: #e4b944;
  border-color: #ffdfa0;
  color: #15151b;
  box-shadow:
    inset 2px 2px #fff3,
    inset -2px -2px #7c4d28;
}
button.primary:hover {
  background: #f4cf78;
}
button[hidden],
[hidden] {
  display: none !important;
}
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid #263342;
  gap: 12px;
}
.edition {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}
.edition b {
  margin-left: 8px;
  color: var(--gold);
  font-weight: normal;
}
nav {
  display: flex;
  gap: 8px;
}
nav button {
  font-size: 12px;
  min-height: 28px;
  padding: 2px 10px;
}
kbd {
  font: inherit;
  font-size: 0.85em;
  white-space: nowrap;
  color: inherit;
  opacity: 0.75;
}
#game {
  position: relative;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  background: #080c13;
}
#game canvas {
  display: block;
  image-rendering: pixelated;
}
footer {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 16px;
  border-top: 2px solid #34404e;
  background: #0e141e;
  font-size: 13px;
}
#phaseLabel {
  color: var(--gold);
  font-size: 14px;
  white-space: nowrap;
}
#quickHint {
  margin: 0;
  min-width: 0;
  flex: 1;
  line-height: 1.4;
  color: var(--muted);
}
.command-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.command-actions .primary {
  min-width: 112px;
}
.loading {
  position: fixed;
  z-index: 10;
  inset: 44px 0 58px;
  display: grid;
  place-items: center;
  background: #080c13ed;
  padding: 24px;
}
.loading-card {
  width: min(460px, 100%);
  padding: 32px;
  border: 3px solid var(--edge);
  box-shadow: 6px 6px #000;
  background: var(--surface);
}
.eyebrow {
  color: var(--gold);
  font-size: 13px;
  letter-spacing: 2px;
}
h2 {
  font-size: 28px;
  font-weight: normal;
  margin: 20px 0 16px;
}
p {
  line-height: 1.6;
}
progress {
  display: block;
  width: 100%;
  height: 14px;
  margin: 24px 0;
  accent-color: var(--gold);
}
progress::-webkit-progress-bar {
  background: #080c13;
}
progress::-webkit-progress-value {
  background: var(--gold);
}
dialog {
  width: min(700px, calc(100vw - 32px));
  max-height: calc(100dvh - 40px);
  padding: 24px;
  background: var(--surface);
  border: 3px solid #87939f;
  color: var(--ink);
  box-shadow: 8px 8px #000;
}
dialog::backdrop {
  background: #02050bc9;
}
.dialog-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}
.dialog-heading h2 {
  margin: 0;
}
#helpContext {
  font-size: 13px;
  color: var(--muted);
  margin: 16px 0;
}
.move-list {
  margin: 0;
}
.move-list > div {
  display: grid;
  grid-template-columns: 64px 1fr;
  border-top: 1px solid #3c4655;
  padding: 12px 0;
  gap: 12px;
  font-size: 14px;
  line-height: 1.8;
}
.move-list dt {
  color: var(--gold);
}
.move-list dd {
  margin: 0;
}
.move-list kbd {
  padding: 1px 4px;
  background: #080c13;
  color: #fff;
  opacity: 1;
  border-bottom: 2px solid #667283;
}
.swatch {
  display: inline-block;
  width: 12px;
  height: 6px;
  margin: 0 4px 2px;
}
.hp {
  background: #e4b944;
}
.mp {
  background: #4c9bdc;
}
.sp {
  background: #75b87a;
}
#pauseDialog {
  text-align: center;
  width: 360px;
}
#pauseDialog p {
  color: var(--muted);
}
#pauseDialog button {
  width: 100%;
  margin-top: 12px;
}
@media (max-width: 700px) {
  body {
    grid-template-rows: 40px minmax(0, 1fr) 88px;
  }
  header {
    padding: 0 8px;
    gap: 8px;
  }
  .edition {
    font-size: 10px;
  }
  .edition b {
    display: none;
  }
  nav {
    gap: 4px;
  }
  nav button {
    font-size: 11px;
    padding: 3px 7px;
  }
  footer {
    padding: 6px 8px;
    flex-wrap: wrap;
    gap: 6px;
    font-size: 11px;
  }
  #phaseLabel {
    font-size: 11px;
  }
  #quickHint {
    flex-basis: 75%;
  }
  .command-actions {
    margin-left: auto;
  }
  .command-actions button {
    font-size: 12px;
    min-height: 30px;
  }
  .loading {
    inset: 40px 0 88px;
  }
  .move-list > div {
    grid-template-columns: 40px 1fr;
    font-size: 12px;
    gap: 8px;
  }
  dialog {
    padding: 16px;
  }
}
@media (max-height: 520px) and (min-width: 701px) {
  body {
    grid-template-rows: 32px minmax(0, 1fr) 40px;
  }
  header {
    padding: 0 8px;
  }
  footer {
    padding: 3px 8px;
    font-size: 11px;
  }
  .loading {
    inset: 32px 0 40px;
  }
  button {
    min-height: 28px;
  }
  nav button {
    min-height: 24px;
  }
}

@media (max-width: 700px) and (orientation: portrait) {
  #game::after {
    content: "建议横屏游玩 · 需要实体键盘";
    position: absolute;
    top: 18px;
    left: 0;
    width: 100%;
    color: var(--muted);
    text-align: center;
    font-size: 12px;
    pointer-events: none;
  }
}

.language-control {
  display: flex;
  align-items: center;
}
.language-control select {
  font: inherit;
  font-size: 12px;
  color: var(--ink);
  background: var(--surface);
  border: 2px solid var(--edge);
  border-radius: 0;
  height: 28px;
  padding: 2px 6px;
  cursor: pointer;
}
.language-control select:focus-visible {
  outline: 2px solid #82d7fa;
  outline-offset: 3px;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
@media (max-width: 700px) and (orientation: portrait) {
  html[lang="en"] #game::after {
    content: "Landscape recommended · Keyboard required";
  }
  html[lang="ja"] #game::after {
    content: "横長の画面を推奨 · キーボードが必要です";
  }
}
@media (max-width: 700px) {
  .edition {
    display: none;
  }
  header nav {
    width: 100%;
    justify-content: space-between;
  }
  .language-control select {
    font-size: 11px;
    padding: 2px 4px;
  }
  html[lang="en"] nav button,
  html[lang="ja"] nav button {
    font-size: 11px;
    padding: 3px 6px;
  }
}
