:root {
  color-scheme: dark;
  font-family: "Noto Sans TC", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #000;
}

button { font: inherit; }

.game-stage {
  display: grid;
  width: 100vw;
  height: 100dvh;
  place-items: center;
  background: radial-gradient(circle at center, #1b0d08, #000 70%);
}

#canvas {
  display: block;
  width: auto;
  height: 100dvh;
  max-width: 100vw;
  image-rendering: pixelated;
  outline: none;
}

.loading {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: grid;
  place-content: center;
  gap: .65rem;
  padding: 1rem;
  text-align: center;
  color: #f4d897;
  background: #080604;
}

.loading[hidden] { display: none; }
.loading progress { width: min(24rem, 78vw); accent-color: #b64227; }

.touch-hud {
  position: fixed;
  z-index: 10;
  inset: 0;
  pointer-events: none;
  user-select: none;
}

.hud-tools {
  position: absolute;
  top: max(.65rem, env(safe-area-inset-top));
  right: max(.65rem, env(safe-area-inset-right));
  display: flex;
  gap: .45rem;
  pointer-events: auto;
}

.tool-button {
  display: grid;
  place-items: center;
  min-height: 42px;
  padding: 0 .85rem;
  border: 1px solid rgba(239, 197, 112, .55);
  border-radius: 999px;
  color: #f8dfae;
  background: rgba(26, 19, 12, .82);
  text-decoration: none;
}

.source-link { font-size: .72rem; }

.tool-button.round { width: 42px; padding: 0; }

.dpad {
  position: absolute;
  left: max(1rem, env(safe-area-inset-left));
  bottom: max(1rem, env(safe-area-inset-bottom));
  display: grid;
  grid-template: repeat(3, 3.4rem) / repeat(3, 3.4rem);
  place-items: stretch;
  padding: .35rem;
  border: 1px solid rgba(229, 190, 111, .4);
  border-radius: 50%;
  background: rgba(22, 16, 10, .68);
  pointer-events: auto;
}

.dpad button {
  border: 0;
  border-radius: .75rem;
  color: #dcc38f;
  background: rgba(106, 82, 46, .55);
  touch-action: none;
}

.dpad button:first-child { grid-area: 1 / 2; }
.dpad button:nth-child(2) { grid-area: 2 / 1; }
.dpad i { grid-area: 2 / 2; border-radius: 50%; background: #7a5a2e; }
.dpad button:nth-child(4) { grid-area: 2 / 3; }
.dpad button:last-child { grid-area: 3 / 2; }

.actions {
  position: absolute;
  right: max(1rem, env(safe-area-inset-right));
  bottom: max(1rem, env(safe-area-inset-bottom));
  width: 12rem;
  height: 10rem;
  pointer-events: none;
}

.action {
  position: absolute;
  display: grid;
  width: 4.7rem;
  height: 4.7rem;
  place-items: center;
  border: 1px solid rgba(246, 213, 143, .62);
  border-radius: 50%;
  color: #fff0cc;
  background: radial-gradient(circle at 38% 30%, #9b4a2c, #4f1c13 74%);
  pointer-events: auto;
  touch-action: none;
}

.action.confirm { right: 0; bottom: 0; width: 5.7rem; height: 5.7rem; }
.action.cancel { left: .2rem; bottom: .2rem; background: radial-gradient(circle, #73603d, #272016); }
.action.menu { right: 2.7rem; top: 0; width: 4rem; height: 4rem; background: radial-gradient(circle, #254758, #12232d); }

button.is-pressed { transform: translateY(2px) scale(.95); filter: brightness(1.3); }

@media (pointer: fine) {
  .touch-hud { display: none; }
}

@media (orientation: portrait) {
  #canvas { width: 100vw; height: auto; }
  .dpad { grid-template: repeat(3, 3rem) / repeat(3, 3rem); }
  .actions { width: 10.5rem; height: 9rem; }
}

