:root {
  --bg: #0e111a;
  --panel: #171c2a;
  --ink: #eaf2ff;
  --muted: #afbdd9;
  --accent: #4cc9f0;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  background: #000000;
  color: var(--ink);
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  padding:
    max(8px, env(safe-area-inset-top))
    8px
    max(8px, env(safe-area-inset-bottom));
  overflow: hidden;
  position: fixed;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
}

.exit-button {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: bold;
  color: #9fb2d3;
  cursor: pointer;
  border-radius: 2px;
  transition: all 0.2s ease;
  z-index: 10;
  line-height: 1;
}

.exit-button:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
}

.exit-button:active {
  transform: scale(0.9);
}

.game-shell {
  position: relative;
  width: min(100%, 430px);
  min-height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 8px);
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  border: 1px solid #28314a;
  border-radius: 18px;
  background: linear-gradient(180deg, #13182a 0%, var(--panel) 100%);
  box-shadow: 0 14px 45px rgba(0, 0, 0, 0.4);
}

.hud {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 0 32px; /* Left margin for exit button */
  font-size: 12px;
  align-items: center;
}

canvas {
  width: 100%;
  flex: 1;
  min-height: 0;
  display: block;
  background: linear-gradient(180deg, #0f1322 0%, #0a0d17 100%);
  border: 1px solid #2a3553;
  border-radius: 12px;
  touch-action: none;
}

kdb, kbd {
  padding: 2px 6px;
  border: 1px solid #3a4561;
  border-radius: 6px;
  background: #111729;
}

.overlay {
  position: absolute;
  inset: 38px 8px 8px 8px;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 20px;
  font-size: clamp(18px, 5.2vw, 26px);
  font-weight: 700;
  color: #f4f9ff;
  background: rgba(6, 8, 15, 0.55);
  backdrop-filter: blur(2px);
  pointer-events: auto;
  cursor: pointer;
  user-select: none;
}

.powerups-info {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
  font-size: 12px;
  font-weight: 400;
}

.powerup-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.powerup-circle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  font-size: 10px;
  font-weight: bold;
  text-align: center;
  line-height: 20px;
}

.powerup-circle.black {
  background-color: #000000;
  color: #FFFFFF;
}

.powerup-circle.gray {
  background-color: #808080;
  color: #FFFFFF;
}

.powerup-circle.white {
  background-color: #FFFFFF;
  color: #000000;
  border: 1px solid #ccc;
}

.powerup-desc {
  font-size: 12px;
  color: #f4f9ff;
}

.start-text {
  font-size: clamp(18px, 5.2vw, 26px);
  font-weight: 700;
  color: #f4f9ff;
}

.exit-hint {
  font-size: 12px;
  font-weight: 400;
  color: #9fb2d3;
  margin-top: 8px;
}

.overlay.hidden {
  display: none;
}

@media (min-width: 700px) {
  body {
    align-items: center;
  }
  .game-shell {
    min-height: min(910px, 98dvh);
  }
}
