:root {
  color-scheme: dark;
  --bg-dark: #1a1a1a;
  --panel-dark: #2b2b2b;
  --panel-border: #4f4f4f;
  --text-red: #dd2d2d;
  --button-dark: #333333;
  --button-dark-hover: #3f3f3f;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: linear-gradient(180deg, #111111 0%, #1f1f1f 70%, #0a0a0a 100%);
  color: var(--text-red);
  font-family: "Press Start 2P", "VT323", "Courier New", monospace;
  letter-spacing: 0.04em;
  touch-action: none;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-user-select: none;
  user-select: none;
}

#app {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right))
    max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
}

#game-shell {
  position: relative;
  width: min(100vw, calc(100vh * 0.5625));
  max-height: 100vh;
  aspect-ratio: 9 / 16;
  border: 4px solid var(--panel-border);
  box-shadow: 0 0 0 2px #0f0f0f, 0 16px 40px rgba(0, 0, 0, 0.55);
  background: #070707;
}

#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.panel {
  background: rgba(43, 43, 43, 0.9);
  border: 2px solid var(--panel-border);
  color: var(--text-red);
  text-shadow: 1px 1px 0 #300909;
}

#hud {
  position: absolute;
  top: 16px;
  left: 14px;
  right: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0;
  pointer-events: none;
  color: #ffffff;
  text-shadow: 2px 2px 0 #101010;
  font-size: clamp(14px, 3.2vw, 20px);
  font-weight: 700;
  z-index: 2;
}

#hud.hidden {
  display: none;
}

.hud-item {
  display: inline-flex;
  gap: 10px;
  align-items: baseline;
}

.label {
  color: #ffffff;
}

.overlay {
  position: absolute;
  inset: 12% 8%;
  z-index: 3;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 14px;
  text-align: center;
  padding: 16px;
}

#gameover-screen {
  background: transparent;
  border: 0;
  box-shadow: none;
  text-shadow: 2px 2px 0 #101010;
}

#tap-retry-text {
  animation: blink-retry 0.9s steps(1, end) infinite;
}

.overlay p,
.overlay h1,
.overlay h2 {
  margin: 0;
  line-height: 1.4;
}

.overlay h1 {
  font-size: clamp(16px, 4.6vw, 24px);
}

.overlay h2 {
  font-size: clamp(15px, 4.2vw, 22px);
}

.ui-button {
  margin-top: 4px;
  border: 2px solid #5b5b5b;
  background: var(--button-dark);
  color: var(--text-red);
  padding: 10px 18px;
  font-family: inherit;
  font-size: clamp(12px, 3vw, 14px);
  cursor: pointer;
}

.ui-button:active,
.ui-button:hover {
  background: var(--button-dark-hover);
}

@keyframes blink-retry {
  0%,
  49.9% {
    opacity: 1;
  }
  50%,
  100% {
    opacity: 0;
  }
}

.hidden {
  display: none;
}

@media (hover: none) and (pointer: coarse) {
  html,
  body {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100dvh;
    min-height: 100dvh;
    overflow: hidden;
    overscroll-behavior: none;
    -webkit-overflow-scrolling: auto;
  }

  #app {
    width: 100vw;
    height: 100dvh;
    min-height: 100dvh;
    overflow: hidden;
    padding: 0;
    place-items: start stretch;
  }

  #game-shell {
    width: 100vw;
    min-width: 100vw;
    max-width: 100vw;
    aspect-ratio: 9 / 16;
    height: auto;
    max-height: none;
    border: 0;
    box-shadow: none;
  }

  #game-canvas {
    touch-action: none;
  }
}
