:root {
  color-scheme: dark;
  --amber: #f3d46b;
  --warning: #ff4136;
  --ink: #171410;
  --panel: rgba(18, 15, 9, 0.72);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: #080704;
  color: #fff7cb;
  font-family: "Arial Narrow", "Helvetica Neue", Arial, sans-serif;
  user-select: none;
}

.game-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  min-height: 100svh;
  background: #080704;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  background: #090805;
  cursor: crosshair;
  touch-action: none;
}

.hud {
  position: fixed;
  inset: 14px 14px auto 14px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  color: #fff1a5;
  font-size: clamp(13px, 1.9vw, 18px);
  letter-spacing: 0;
  text-shadow: 2px 2px 0 #100d08;
  pointer-events: none;
}

.status,
.meters {
  background: var(--panel);
  border: 1px solid rgba(255, 234, 131, 0.32);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.38);
  padding: 8px 10px;
}

.status {
  max-width: min(62vw, 560px);
}

.meters {
  display: grid;
  gap: 4px;
  justify-items: end;
  white-space: nowrap;
}

.start {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: grid;
  gap: 10px;
  min-width: min(620px, calc(100vw - 32px));
  padding: 24px 34px;
  border: 1px solid rgba(255, 237, 154, 0.62);
  border-radius: 4px;
  background: rgba(25, 20, 12, 0.86);
  color: #fff6bd;
  font: inherit;
  font-size: clamp(22px, 4.4vw, 38px);
  text-align: center;
  text-transform: uppercase;
  text-shadow: 2px 2px 0 #0d0a06;
  box-shadow: 0 0 0 2px #000, 0 14px 40px rgba(0, 0, 0, 0.55);
  cursor: pointer;
  z-index: 8;
  touch-action: manipulation;
}

.start small {
  color: #cabd7b;
  font-size: clamp(13px, 1.7vw, 17px);
  text-transform: none;
}

.start.is-hidden {
  display: none;
}

.touch-controls {
  position: fixed;
  left: 0;
  right: 0;
  bottom: max(14px, env(safe-area-inset-bottom));
  z-index: 6;
  display: none;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  padding: 0 max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
  pointer-events: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.touch-group {
  display: grid;
  gap: 10px;
  pointer-events: auto;
}

.touch-move {
  grid-template-rows: repeat(2, 1fr);
}

.touch-turn {
  grid-template-columns: repeat(2, 1fr);
}

.touch-btn {
  width: clamp(58px, 17vw, 76px);
  height: clamp(58px, 17vw, 76px);
  border: 1px solid rgba(255, 238, 166, 0.42);
  border-radius: 6px;
  background: rgba(16, 13, 8, 0.68);
  color: rgba(255, 245, 190, 0.88);
  font: inherit;
  font-size: clamp(25px, 7vw, 35px);
  line-height: 1;
  text-shadow: 2px 2px 0 #070604;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.45), inset 0 0 18px rgba(255, 235, 150, 0.05);
  appearance: none;
  -webkit-appearance: none;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.touch-btn.is-pressed {
  transform: translateY(2px);
  background: rgba(72, 61, 31, 0.82);
  color: #fff7c8;
}

.caption {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  width: min(680px, calc(100vw - 24px));
  min-height: 42px;
  padding: 10px 12px;
  color: #fff9c9;
  background: rgba(7, 6, 4, 0.74);
  border: 1px solid rgba(255, 240, 149, 0.25);
  text-align: center;
  text-shadow: 2px 2px 0 #050403;
  opacity: 0;
  transition: opacity 120ms linear;
  pointer-events: none;
}

.caption.is-visible {
  opacity: 1;
}

@media (max-width: 720px) {
  .hud {
    inset: 10px 10px auto 10px;
    display: grid;
    gap: 8px;
    font-size: clamp(12px, 3.3vw, 15px);
  }

  .status {
    max-width: calc(100vw - 20px);
  }

  .meters {
    justify-items: start;
  }

  .start {
    min-width: min(520px, calc(100vw - 28px));
    padding: 20px 18px;
    font-size: clamp(24px, 8.2vw, 34px);
  }
}

@media (pointer: coarse), (max-width: 820px) {
  body.is-playing .touch-controls {
    display: flex;
  }

  body.is-playing .caption {
    bottom: calc(104px + env(safe-area-inset-bottom));
    width: min(520px, calc(100vw - 24px));
  }
}

@media (max-height: 470px) and (orientation: landscape) {
  .touch-controls {
    bottom: max(10px, env(safe-area-inset-bottom));
  }

  .touch-btn {
    width: clamp(50px, 11vw, 62px);
    height: clamp(50px, 11vw, 62px);
    font-size: clamp(22px, 5vw, 30px);
  }

  body.is-playing .caption {
    bottom: max(10px, env(safe-area-inset-bottom));
    width: min(420px, calc(100vw - 240px));
  }
}
