:root {
  color-scheme: light;
  font-family:
    "LXGW WenKai", "霞鹜文楷", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  /* Same gradient as body: the root background fills the whole viewport canvas,
     so no stale color leaks along edges the body box doesn't quite cover. */
  background: #137e8d linear-gradient(180deg, #16293f 0%, #145d73 46%, #137e8d 100%)
    no-repeat;
}

* {
  box-sizing: border-box;
}

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

body {
  display: grid;
  place-items: center;
  /* Background lives on :root so it covers the whole viewport as one layer. */
  background: transparent;
}

.game-shell {
  width: min(100vw, 1280px);
  height: min(100svh, 720px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px;
}

canvas {
  width: min(calc(100vw - 24px), calc((100svh - 24px) * 3 / 2), 1044px);
  height: auto;
  max-height: calc(100svh - 24px);
  aspect-ratio: 3 / 2;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #64d8f2;
  border: 4px solid #083f4b;
  box-shadow: 0 18px 0 rgba(2, 47, 58, 0.22);
  cursor: crosshair;
  touch-action: none;
}

.top-controls {
  position: fixed;
  top: calc(14px + env(safe-area-inset-top, 0px));
  right: calc(14px + env(safe-area-inset-right, 0px));
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ctrl-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 8px 12px;
  color: #ffe8a8;
  background: rgba(8, 22, 46, 0.82);
  border: 2px solid rgba(255, 227, 151, 0.72);
  border-radius: 8px;
  font-weight: 600;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(2, 47, 58, 0.3);
  -webkit-tap-highlight-color: transparent;
}

.ctrl-btn:active {
  transform: translateY(2px);
  box-shadow: none;
}

/* Square icon-only button */
.mute-btn {
  padding: 8px;
  min-width: 40px;
  justify-content: center;
}

.mute-btn .icon-muted {
  display: none;
}

.mute-btn.is-muted .icon-sound {
  display: none;
}

.mute-btn.is-muted .icon-muted {
  display: inline;
  color: #f4a58c;
}

/* Only shown where the Fullscreen API actually works (JS adds .fs-available).
   Hidden on iPhone Safari, which blocks element fullscreen entirely. */
.fullscreen-btn {
  display: none;
}

body.fs-available .fullscreen-btn {
  display: inline-flex;
}

.rotate-hint {
  display: none;
  margin: 0;
  padding: 7px 14px;
  color: #ffe8a8;
  background: rgba(8, 22, 46, 0.7);
  border: 1px solid rgba(255, 227, 151, 0.4);
  border-radius: 999px;
  font-size: 12px;
  white-space: nowrap;
  pointer-events: none;
}

@media (orientation: portrait) {
  .rotate-hint {
    display: block;
  }
}
