* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #05080d;
  color: #e9e2c8;
  font-family: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

#game {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.hint {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  left: 12px;
  right: 12px;
  width: fit-content;
  margin-inline: auto;
  padding: 6px 12px;
  font-size: 13px;
  letter-spacing: 0.04em;
  background: rgba(5, 8, 13, 0.55);
  border: 1px solid rgba(255, 207, 107, 0.25);
  border-radius: 4px;
  text-align: center;
  pointer-events: none;
  transition: opacity 0.8s ease;
}

.title {
  position: fixed;
  top: 22%;
  left: 0;
  right: 0;
  margin: 0;
  text-align: center;
  font-size: clamp(28px, 7vw, 56px);
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #ffcf6b;
  text-shadow: 0 0 18px rgba(255, 160, 70, 0.55), 0 3px 0 #3a1f0c;
  pointer-events: none;
  transition: opacity 1.6s ease;
}

.title.hidden,
.hint.hidden {
  opacity: 0;
}

.debug {
  position: fixed;
  top: 8px;
  left: 8px;
  margin: 0;
  padding: 6px 8px;
  font-size: 11px;
  line-height: 1.4;
  background: rgba(0, 0, 0, 0.6);
  color: #9fe0a8;
  pointer-events: none;
}

.debug[hidden] {
  display: none;
}

/* Touch controls: hidden on desktop, shown on touch devices (or ?touch=1). */
.touch-controls {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 0 max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  justify-content: space-between;
  align-items: flex-end;
  pointer-events: none;
  touch-action: none;
}

body.touch .touch-controls {
  display: flex;
}

.move-buttons {
  display: flex;
  gap: 14px;
}

.btn {
  pointer-events: auto;
  touch-action: none;
  width: 72px;
  height: 72px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid rgba(255, 207, 107, 0.35);
  background: rgba(10, 16, 26, 0.45);
  color: #e9e2c8;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.08s, transform 0.08s, border-color 0.08s;
}

.btn svg {
  width: 30px;
  height: 30px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.btn-action {
  width: 84px;
  height: 84px;
}

.btn-action .flame {
  fill: #ffcf6b;
  stroke: none;
}

.btn.active {
  background: rgba(255, 207, 107, 0.28);
  border-color: rgba(255, 207, 107, 0.85);
  transform: scale(0.94);
}

body.portrait .btn {
  width: 80px;
  height: 80px;
}

body.portrait .btn-action {
  width: 92px;
  height: 92px;
}
