:root {
  color-scheme: dark;
  --ink: #f5f1df;
  --muted: #b9c2a9;
  --panel: rgba(19, 22, 18, 0.78);
  --edge: rgba(245, 241, 223, 0.22);
  --accent: #f2cf5b;
  --pink: #ff7eb6;
  --danger: #ff5b5b;
  --green: #78d67f;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #0f1110;
  color: var(--ink);
  font-family: ui-rounded, "PingFang TC", "Noto Sans TC", system-ui, sans-serif;
  touch-action: none;
}

button {
  border: 0;
  color: inherit;
  font: inherit;
}

.game-shell {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 20% 18%, rgba(242, 207, 91, 0.18), transparent 28%),
    radial-gradient(circle at 82% 16%, rgba(255, 126, 182, 0.12), transparent 24%),
    linear-gradient(180deg, #191c18 0%, #0c0e0d 100%);
}

canvas {
  width: 100vw;
  height: 100svh;
  min-height: 100dvh;
  display: block;
  image-rendering: auto;
}

.hud {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  left: max(12px, env(safe-area-inset-left));
  right: max(12px, env(safe-area-inset-right));
  z-index: 4;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  pointer-events: none;
}

.hud span,
.toast,
.overlay {
  border: 1px solid var(--edge);
  background: var(--panel);
  backdrop-filter: blur(14px);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.hud span {
  min-width: 82px;
  padding: 8px 10px;
  border-radius: 8px;
  text-align: center;
  font-size: 13px;
  font-weight: 800;
}

.overlay {
  position: fixed;
  z-index: 8;
  left: 50%;
  top: 50%;
  width: min(420px, calc(100vw - 32px));
  max-height: calc(100svh - 32px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  overflow: auto;
  transform: translate(-50%, -52%);
  border-radius: 8px;
  padding: 22px;
}

.overlay.hidden {
  display: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: #181208;
  letter-spacing: 0;
}

h1 {
  margin: 16px 0 8px;
  font-size: clamp(36px, 10vw, 64px);
  line-height: 0.92;
  letter-spacing: 0;
}

p {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
}

.primary,
.ghost {
  width: 100%;
  min-height: 48px;
  border-radius: 8px;
  font-weight: 900;
  cursor: pointer;
}

.primary {
  background: var(--accent);
  color: #181208;
  box-shadow: 0 0 24px rgba(242, 207, 91, 0.22);
}

.ghost {
  margin-top: 10px;
  background: rgba(245, 241, 223, 0.1);
  border: 1px solid var(--edge);
}

.toast {
  position: fixed;
  z-index: 7;
  top: calc(max(54px, env(safe-area-inset-top)) + 12px);
  left: 50%;
  max-width: calc(100vw - 32px);
  min-height: 38px;
  transform: translateX(-50%) translateY(-12px);
  border-radius: 8px;
  padding: 9px 14px;
  color: var(--ink);
  opacity: 0;
  pointer-events: none;
  text-align: center;
  font-size: 14px;
  font-weight: 800;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.touch {
  position: fixed;
  z-index: 5;
  left: max(14px, env(safe-area-inset-left));
  right: max(14px, env(safe-area-inset-right));
  bottom: max(18px, calc(env(safe-area-inset-bottom) + 10px));
  display: flex;
  justify-content: space-between;
  align-items: end;
  pointer-events: none;
}

.pad,
.actions {
  display: flex;
  gap: 10px;
  pointer-events: auto;
}

.touch button {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 1px solid rgba(245, 241, 223, 0.28);
  background: rgba(245, 241, 223, 0.13);
  color: var(--ink);
  font-size: 28px;
  font-weight: 950;
  backdrop-filter: blur(12px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 10px 25px rgba(0, 0, 0, 0.22);
}

.actions button:first-child {
  background: rgba(255, 91, 91, 0.24);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 0 22px rgba(255, 91, 91, 0.18);
}

.actions button:last-child {
  background: rgba(120, 214, 127, 0.18);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 0 22px rgba(120, 214, 127, 0.16);
}

.touch button:active,
.touch button.active {
  transform: translateY(2px) scale(0.98);
  background: rgba(242, 207, 91, 0.28);
}

@media (hover: hover) and (pointer: fine) {
  .touch {
    opacity: 0.8;
  }
}

@media (max-width: 520px) {
  .hud span {
    min-width: 68px;
    padding-inline: 8px;
    font-size: 11px;
  }

  .touch button {
    width: 56px;
    height: 56px;
    font-size: 24px;
  }
}

@media (max-height: 520px) and (orientation: landscape) {
  .hud {
    top: max(8px, env(safe-area-inset-top));
  }

  .hud span {
    min-width: 64px;
    padding: 6px 8px;
    font-size: 11px;
  }

  .touch {
    bottom: max(8px, env(safe-area-inset-bottom));
  }

  .touch button {
    width: 48px;
    height: 48px;
    font-size: 21px;
  }
}
