* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: #0a0a1a;
  color: #fff;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

body.light {
  background: #f0f0f8;
  color: #1a1a2e;
}

.game-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  padding: 6px;
  gap: 6px;
}

.top-bar {
  display: flex;
  justify-content: flex-end;
  width: 100%;
  max-width: 640px;
}

#theme-toggle {
  background: none;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 6px;
  color: #fff;
  padding: 4px 12px;
  cursor: pointer;
  font-size: 13px;
  touch-action: manipulation;
}

body.light #theme-toggle {
  border-color: rgba(0,0,0,0.2);
  color: #1a1a2e;
}

.canvas-wrap {
  position: relative;
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 0 40px rgba(0,240,240,0.12);
  line-height: 0;
}

body.light .canvas-wrap {
  box-shadow: 0 0 40px rgba(0,136,160,0.12);
}

#game-canvas {
  display: block;
  background: #0a0a1a;
  width: 640px;
  height: 360px;
}

body.light #game-canvas {
  background: #f0f0f8;
}

.touch-controls {
  display: none;
  gap: 6px;
  max-width: 320px;
  width: 100%;
  flex-direction: column;
  align-items: center;
}

.touch-row {
  display: flex;
  gap: 6px;
  justify-content: center;
}

.touch-btn {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 10px;
  color: #fff;
  font-size: 22px;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

body.light .touch-btn {
  background: rgba(0,0,0,0.05);
  border-color: rgba(0,0,0,0.12);
  color: #1a1a2e;
}

.touch-btn:active {
  background: rgba(255,255,255,0.18);
  transform: scale(0.93);
}

body.light .touch-btn:active {
  background: rgba(0,0,0,0.1);
}

.touch-btn.wide { width: 118px; }

@media (hover: none) and (pointer: coarse) {
  .touch-controls { display: flex; }
}

@media (max-height: 500px) {
  .touch-btn { width: 48px; height: 48px; font-size: 18px; }
  .touch-btn.wide { width: 102px; }
  .game-wrapper { padding: 3px; gap: 3px; }
}
