:root {
  color-scheme: dark;
  font-family: "Segoe UI", Arial, sans-serif;
  background: #0b1014;
  color: #f5f0e8;
}

* {
  box-sizing: border-box;
}

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

body {
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 20% 10%, rgba(240, 186, 96, 0.16), transparent 28rem),
    linear-gradient(180deg, #17232b 0%, #080c10 100%);
}

.game-shell {
  position: relative;
  width: min(100vw, 1280px);
  height: min(100vh, 720px);
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #111a20;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.hud {
  position: absolute;
  top: 14px;
  left: 14px;
  right: 14px;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  pointer-events: none;
}

.hud div {
  min-width: 0;
  padding: 9px 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(8, 12, 16, 0.66);
  backdrop-filter: blur(8px);
}

.label {
  display: block;
  margin-bottom: 2px;
  color: #b4c8ca;
  font-size: 0.7rem;
  letter-spacing: 0;
  text-transform: uppercase;
}

.hud strong {
  display: block;
  overflow: hidden;
  color: #fff7df;
  font-size: clamp(1rem, 3vw, 1.65rem);
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(180deg, rgba(5, 8, 10, 0.25), rgba(5, 8, 10, 0.68));
}

.overlay.hidden {
  display: none;
}

.panel {
  width: min(92vw, 430px);
  padding: 24px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  background: rgba(9, 14, 18, 0.82);
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.42);
  text-align: center;
}

h1 {
  margin: 0 0 12px;
  color: #fff4d6;
  font-size: clamp(2rem, 7vw, 4.4rem);
  line-height: 0.95;
}

p {
  margin: 0 0 20px;
  color: #d2dedc;
  font-size: 1rem;
  line-height: 1.45;
}

button {
  min-width: 150px;
  min-height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: 6px;
  background: #f2b84b;
  color: #16100a;
  font: 700 1rem/1 "Segoe UI", Arial, sans-serif;
  cursor: pointer;
}

button:focus-visible {
  outline: 3px solid #f8f1dc;
  outline-offset: 3px;
}

@media (max-width: 720px) {
  .game-shell {
    width: 100vw;
    height: 100dvh;
    aspect-ratio: auto;
  }

  .hud {
    top: max(8px, env(safe-area-inset-top));
    left: max(8px, env(safe-area-inset-left));
    right: max(8px, env(safe-area-inset-right));
    gap: 6px;
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .hud div {
    padding: 6px 8px;
  }

  .hud div:nth-child(-n + 3) {
    grid-column: span 2;
  }

  .hud div:nth-child(n + 4) {
    grid-column: span 3;
  }

  .label {
    font-size: 0.6rem;
  }

  .hud strong {
    font-size: 1rem;
  }

  .overlay {
    padding:
      max(16px, env(safe-area-inset-top))
      max(16px, env(safe-area-inset-right))
      max(16px, env(safe-area-inset-bottom))
      max(16px, env(safe-area-inset-left));
  }

  .panel {
    max-height: calc(100dvh - 32px);
    padding: 20px;
    overflow-y: auto;
  }

  h1 {
    font-size: clamp(2rem, 12vw, 3.4rem);
  }

  p {
    font-size: 0.95rem;
  }
}

@media (max-height: 500px) {
  .hud {
    top: max(6px, env(safe-area-inset-top));
    left: max(6px, env(safe-area-inset-left));
    right: max(6px, env(safe-area-inset-right));
    gap: 4px;
  }

  .hud div {
    padding: 5px 7px;
  }

  .overlay {
    padding: 10px max(12px, env(safe-area-inset-right)) 10px max(12px, env(safe-area-inset-left));
  }

  .panel {
    width: min(88vw, 520px);
    padding: 14px 20px;
  }

  h1 {
    margin-bottom: 7px;
    font-size: 2rem;
  }

  p {
    margin-bottom: 12px;
    font-size: 0.88rem;
    line-height: 1.3;
  }
}
