:root {
  color-scheme: dark;
  font-family: Inter, "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  background: #090c12;
  color: #f5f1e8;
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  background:
    radial-gradient(circle at 20% 0%, rgba(91, 111, 180, .17), transparent 35%),
    #090c12;
}

button { font: inherit; }

.game-shell {
  display: grid;
  grid-template-rows: auto 1fr;
  width: 100%;
  height: 100dvh;
}

.hud {
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 66px;
  padding: 10px clamp(14px, 3vw, 34px);
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  background: rgba(10, 14, 22, .9);
  backdrop-filter: blur(14px);
}

.brand { display: flex; align-items: center; gap: 11px; }
.brand-mark { color: #efcf78; font-size: 26px; filter: drop-shadow(0 0 8px #ddad3c); }
.brand strong, .brand span { display: block; }
.brand strong { letter-spacing: .08em; }
.brand span { margin-top: 2px; color: #8f9ab2; font-size: 12px; }

.coordinates { display: flex; gap: 8px; color: #909bb0; font: 12px ui-monospace, monospace; }
.coordinates span { padding: 7px 9px; border: 1px solid #273047; border-radius: 8px; background: #111724; }
.coordinates b { min-width: 3ch; color: #f4d687; font-weight: 600; }

.stage { position: relative; min-height: 0; overflow: hidden; }
#game { display: block; width: 100%; height: 100%; outline: none; touch-action: none; cursor: crosshair; }

.hint {
  position: absolute;
  top: 20px;
  left: 50%;
  display: grid;
  gap: 4px;
  padding: 10px 16px;
  border: 1px solid rgba(239, 207, 120, .24);
  border-radius: 12px;
  background: rgba(12, 17, 27, .78);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .2);
  text-align: center;
  transform: translateX(-50%);
  transition: opacity .35s, transform .35s;
  pointer-events: none;
  white-space: nowrap;
}

.hint strong { color: #f2d58e; font-size: 13px; }
.hint span { color: #9ea8bb; font-size: 12px; }
.hint.hidden { opacity: 0; transform: translate(-50%, -8px); }

.reset {
  position: absolute;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  padding: 10px 14px;
  border: 1px solid #384158;
  border-radius: 10px;
  background: rgba(16, 22, 34, .85);
  color: #cad1df;
  cursor: pointer;
}

.reset:hover { border-color: #7d8aa7; color: white; }

.joystick {
  position: absolute;
  left: max(24px, env(safe-area-inset-left));
  bottom: max(24px, env(safe-area-inset-bottom));
  display: none;
  width: 112px;
  height: 112px;
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 50%;
  background: rgba(12, 17, 27, .42);
  box-shadow: inset 0 0 30px rgba(0, 0, 0, .3);
  touch-action: none;
}

.joystick-knob {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 48px;
  height: 48px;
  border: 1px solid rgba(239, 207, 120, .55);
  border-radius: 50%;
  background: rgba(218, 180, 82, .36);
  box-shadow: 0 0 18px rgba(218, 180, 82, .18);
  transform: translate(-50%, -50%);
}

@media (hover: none), (pointer: coarse) {
  .joystick { display: block; }
  .reset { bottom: max(28px, env(safe-area-inset-bottom)); }
  .hint { top: 12px; max-width: calc(100% - 24px); white-space: normal; }
}

@media (max-width: 480px) {
  .hud { min-height: 58px; }
  .brand span { display: none; }
  .coordinates span { padding: 6px 7px; }
}
