* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  overscroll-behavior: none;
  touch-action: none;
}

body {
  display: grid;
  place-items: center;
  min-height: 100svh;
  padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  background:
    radial-gradient(circle at center 8%, rgba(255, 214, 10, 0.15), transparent 34%),
    linear-gradient(180deg, #141018 0%, #08090e 100%);
  color: #f7f1d1;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.arcade {
  width: min(100%, 820px);
}

.cabinet {
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  overflow: hidden;
  background: #11131e;
  box-shadow: 0 26px 90px rgba(0, 0, 0, 0.42);
}

.topbar,
.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
}

.topbar {
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

h1 {
  margin: 0;
  font-size: clamp(1.35rem, 6vw, 2rem);
  line-height: 1;
  letter-spacing: 0;
}

p {
  margin: 5px 0 0;
  color: #b7b4c7;
  font-size: 0.9rem;
}

.stats {
  display: flex;
  gap: 18px;
  text-align: right;
}

.stats span {
  display: block;
  color: #b7b4c7;
  font-size: 0.78rem;
  text-transform: uppercase;
}

.stats strong {
  display: block;
  min-width: 46px;
  color: #ffd60a;
  font-size: clamp(1.1rem, 4.5vw, 1.5rem);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.screen-wrap {
  position: relative;
  display: grid;
  place-items: center;
  padding: 10px;
  background: #05060a;
}

canvas {
  display: block;
  width: min(100%, 672px, calc((100svh - 238px) * 0.903));
  max-height: calc(100svh - 238px);
  height: auto;
  image-rendering: crisp-edges;
  background: #02030a;
}

.overlay {
  position: absolute;
  inset: 10px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  pointer-events: none;
  color: #fff3b0;
  text-align: center;
  text-shadow: 0 3px 0 #000;
}

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

.overlay strong {
  font-size: clamp(2rem, 6vw, 4.4rem);
  line-height: 1;
}

.overlay span {
  color: #f7f1d1;
  font-size: clamp(1rem, 2vw, 1.35rem);
}

.controls {
  display: grid;
  grid-template-columns: minmax(116px, 140px) 1fr;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  color: #b7b4c7;
}

button {
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 6px;
  min-height: 44px;
  padding: 9px 12px;
  background: #22263a;
  color: #f7f1d1;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

button:hover {
  background: #303650;
}

.joystick-panel {
  display: grid;
  place-items: center;
}

.joystick {
  position: relative;
  width: 116px;
  aspect-ratio: 1;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 214, 10, 0.18), transparent 32%),
    #171b2a;
  box-shadow: inset 0 0 0 8px rgba(255, 255, 255, 0.04);
  touch-action: none;
}

.joystick::before,
.joystick::after {
  content: "";
  position: absolute;
  inset: 50% auto auto 50%;
  width: 72%;
  height: 2px;
  background: rgba(255, 255, 255, 0.13);
  transform: translate(-50%, -50%);
}

.joystick::after {
  width: 2px;
  height: 72%;
}

.joystick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 48px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #ffd60a;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.42), inset 0 -5px 0 rgba(0, 0, 0, 0.18);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.action-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

@media (max-width: 760px) {
  body {
    align-items: start;
  }

  .topbar {
    align-items: center;
  }

  .stats {
    gap: 8px;
  }

  .stats span {
    font-size: 0.68rem;
  }
}

@media (max-width: 430px) {
  .topbar {
    padding-inline: 10px;
  }

  .controls {
    grid-template-columns: 108px 1fr;
    padding: 10px;
  }

  .joystick {
    width: 104px;
  }

  .joystick-knob {
    width: 44px;
  }

  button {
    min-height: 42px;
    padding-inline: 8px;
    font-size: 0.9rem;
  }
}
