* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background: #0a0a12;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: monospace;
  overflow: hidden;
  position: fixed;
  width: 100%;
  overscroll-behavior: none;
}

.cabinet {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 20px;
  background: linear-gradient(180deg, #151525, #0d0d18);
  border: 4px solid #222;
  border-radius: 8px;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.8), inset 0 0 30px rgba(0, 0, 0, 0.5);
}

#game {
  /* Fit within viewport while maintaining 800:500 (1.6:1) aspect ratio */
  width: min(100vw, 800px, calc(100dvh * 1.6));
  height: auto;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #0b1020;
  border: 3px solid #000;
  box-shadow: 0 0 20px rgba(100, 140, 255, 0.1);
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

#toggleSound {
  position: absolute;
  top: 8px;
  right: 28px;
  background: #1a1a2e;
  color: #9db2d8;
  border: 2px solid #333;
  padding: 4px 10px;
  font-family: monospace;
  font-size: 11px;
  font-weight: bold;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 1px;
  z-index: 10;
}

#toggleSound:hover {
  background: #252540;
  color: #ffd84a;
  border-color: #ffd84a;
}

#toggleSound:active {
  transform: translateY(1px);
}

/* Orientation overlay */
#orientationOverlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  z-index: 1000;
  justify-content: center;
  align-items: center;
}

.orientation-message {
  text-align: center;
  color: #ffffff;
  font-family: monospace;
  font-size: 18px;
  padding: 20px;
}

.orientation-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

@media (max-width: 840px) {
  .cabinet {
    padding: 8px;
    border-width: 2px;
  }
  #toggleSound {
    right: 16px;
    top: 4px;
  }
}

/* Touch devices: strip cabinet chrome */
@media (hover: none) and (pointer: coarse) {
  body {
    touch-action: none;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  }
  .cabinet {
    padding: 0;
    border: none;
    border-radius: 0;
    background: #0a0a12;
    box-shadow: none;
    gap: 0;
  }
  #game {
    border: none;
    box-shadow: none;
  }
}

/* Portrait orientation: show overlay on touch devices */
@media (orientation: portrait) and (hover: none) and (pointer: coarse) {
  #orientationOverlay {
    display: flex;
  }
}
