:root {
  color-scheme: light;
  --ink: #17222b;
  --muted: #5f6f7b;
  --line: rgba(23, 34, 43, 0.18);
  --panel: rgba(255, 255, 255, 0.82);
  --accent: #ffcf33;
  --orange: #ff7a2f;
  --blue: #1d9bf0;
  --grass: #2dbd64;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background:
    radial-gradient(circle at 18% 15%, rgba(255, 207, 51, 0.45), transparent 22%),
    linear-gradient(135deg, #8ee6ff 0%, #f5fbff 48%, #b8f07a 100%);
}

button {
  appearance: none;
  border: 0;
  border-radius: 8px;
  color: var(--ink);
  font: inherit;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 6px 0 rgba(23, 34, 43, 0.18);
  transition:
    transform 140ms ease,
    box-shadow 140ms ease,
    filter 140ms ease;
}

button:hover {
  filter: brightness(1.03);
}

button:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 rgba(23, 34, 43, 0.2);
}

.shell {
  display: grid;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  place-items: center;
  padding: 16px;
}

.game-wrap {
  position: relative;
  container-type: size;
  container-name: game-wrap;
  aspect-ratio: 3 / 2;
  width: min(980px, calc(100vw - 32px), calc((100dvh - 32px) * 1.5));
  overflow: hidden;
  border: 4px solid rgba(23, 34, 43, 0.25);
  border-radius: 8px;
  background: #7fdf6b;
  box-shadow: 0 26px 60px rgba(23, 34, 43, 0.24);
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.hud,
.top-actions {
  position: absolute;
  z-index: 3;
  display: flex;
  gap: 8px;
}

.hud {
  top: 12px;
  left: 12px;
}

.hud > div {
  min-width: 78px;
  padding: 8px 10px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  backdrop-filter: blur(8px);
}

.label {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.hud strong {
  display: block;
  font-size: 24px;
  line-height: 1;
}

.top-actions {
  top: 12px;
  right: 12px;
}

.top-actions button {
  height: 42px;
  padding: 0 12px;
  background: var(--panel);
  border: 2px solid var(--line);
  box-shadow: none;
}

.message {
  position: absolute;
  z-index: 4;
  left: 50%;
  top: 50%;
  width: min(86%, 430px);
  max-height: calc(100% - 24px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 24px;
  border: 3px solid rgba(23, 34, 43, 0.22);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 20px 50px rgba(23, 34, 43, 0.22);
  text-align: center;
  transform: translate(-50%, -50%);
}

.message.hidden {
  display: none;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--orange);
  font-size: 13px;
  font-weight: 950;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(32px, 6vw, 56px);
  line-height: 0.94;
}

.message p:not(.eyebrow) {
  margin: 14px 0 20px;
  color: var(--muted);
  font-weight: 700;
  line-height: 1.35;
}

.level-picker {
  display: grid;
  gap: 7px;
  margin: 0 auto 16px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 950;
  letter-spacing: 0;
  text-align: left;
  text-transform: uppercase;
}

.level-picker select {
  width: 100%;
  height: 44px;
  border: 2px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: white;
  font: inherit;
  font-size: 16px;
  font-weight: 900;
  text-transform: none;
}

.message button {
  width: 150px;
  height: 52px;
  background: var(--accent);
  font-size: 20px;
}

.touch-controls {
  position: absolute;
  z-index: 3;
  right: 16px;
  bottom: 16px;
  display: grid;
  grid-template-areas:
    ". up ."
    "left shoot right"
    ". down .";
  grid-template-columns: repeat(3, 58px);
  grid-template-rows: repeat(3, 58px);
  gap: 10px;
}

.touch-controls button {
  width: 58px;
  height: 58px;
  background: rgba(255, 255, 255, 0.84);
  border: 2px solid var(--line);
  font-size: 22px;
  backdrop-filter: blur(8px);
}

#shootBtn {
  grid-area: shoot;
  background: var(--accent);
}

#leftBtn {
  grid-area: left;
}

#rightBtn {
  grid-area: right;
}

#upBtn {
  grid-area: up;
}

#downBtn {
  grid-area: down;
}

#shootBtn.is-ready {
  background: var(--orange);
  color: white;
  animation: shootPulse 650ms ease-in-out infinite;
}

@keyframes shootPulse {
  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.12);
  }
}

@container game-wrap (max-width: 620px) {
  .hud {
    gap: 4px;
    max-width: calc(100% - 16px);
    flex-wrap: wrap;
  }

  .hud > div {
    min-width: 44px;
    padding: 4px 6px;
    border-width: 1px;
  }

  .label {
    font-size: 8px;
  }

  .hud strong {
    font-size: 14px;
  }

  .top-actions {
    top: auto;
    left: 8px;
    right: auto;
    bottom: 8px;
  }

  .top-actions button {
    height: 28px;
    padding: 0 7px;
    font-size: 11px;
  }

  .touch-controls {
    right: 8px;
    bottom: 8px;
    grid-template-columns: repeat(3, 42px);
    grid-template-rows: repeat(3, 42px);
    gap: 6px;
  }

  .touch-controls button {
    width: 42px;
    height: 42px;
    font-size: 16px;
  }

  .message {
    padding: 16px;
  }

  .level-picker {
    margin: 0 auto 10px;
  }

  .level-picker select {
    height: 36px;
  }

  .message button {
    width: 130px;
    height: 42px;
    font-size: 16px;
  }
}

@container game-wrap (max-height: 420px) {
  .message {
    padding: 12px;
  }

  .eyebrow {
    margin: 0 0 4px;
    font-size: 11px;
  }

  h1 {
    font-size: clamp(20px, 5vw, 32px);
  }

  .message p:not(.eyebrow) {
    margin: 6px 0 10px;
    font-size: 13px;
    line-height: 1.2;
  }

  .level-picker {
    gap: 3px;
    margin: 0 auto 6px;
    font-size: 10px;
  }

  .level-picker select {
    height: 30px;
    font-size: 13px;
  }

  .message button {
    width: 110px;
    height: 34px;
    font-size: 14px;
  }
}

@container game-wrap (max-height: 280px) {
  .message {
    padding: 8px;
  }

  .eyebrow {
    display: none;
  }

  h1 {
    font-size: clamp(15px, 4.4vw, 20px);
    line-height: 1.05;
  }

  .message p:not(.eyebrow) {
    margin: 3px 0 6px;
    font-size: 11px;
    line-height: 1.15;
  }

  .level-picker {
    gap: 2px;
    margin: 0 auto 4px;
    font-size: 9px;
  }

  .level-picker select {
    height: 24px;
    font-size: 11px;
  }

  .message button {
    width: 94px;
    height: 28px;
    font-size: 12px;
  }
}

.rotate-hint {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 50;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  background: rgba(12, 24, 20, 0.94);
  color: #fff8e7;
}

.rotate-card {
  display: grid;
  gap: 14px;
  justify-items: center;
  max-width: 320px;
}

.rotate-icon {
  font-size: 48px;
  animation: rotateHintSpin 1.8s ease-in-out infinite;
}

.rotate-card p {
  margin: 0;
  font-weight: 700;
  line-height: 1.4;
}

.rotate-card button {
  height: 44px;
  padding: 0 18px;
  background: var(--accent);
}

@keyframes rotateHintSpin {
  0%,
  100% {
    transform: rotate(0deg);
  }

  50% {
    transform: rotate(-90deg);
  }
}

@media (orientation: portrait) and (max-width: 820px) {
  .rotate-hint {
    display: flex;
  }
}

body.rotate-dismissed .rotate-hint {
  display: none;
}
