:root {
  --bg: #0d1b1e;
  --card: rgba(255, 255, 255, 0.08);
  --text: #e7f6f2;
  --muted: #a5c3c0;
  --accent: #4fd1c5;
  --accent-2: #ff9f68;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.screen {
  position: fixed;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.screen.active {
  opacity: 1;
  pointer-events: auto;
}

#setup {
  overflow-y: auto;
}

h1 {
  margin: 0 0 0.25rem;
  font-size: clamp(1.8rem, 5vw, 3rem);
  text-align: center;
}

.subtitle {
  color: var(--muted);
  margin: 0 0 1.25rem;
  text-align: center;
  max-width: 40ch;
}

.card {
  width: min(640px, 100%);
  background: var(--card);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 18px;
  padding: clamp(1rem, 3vw, 1.75rem);
  box-shadow: var(--shadow);
}

form label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

input[type="text"],
input[type="number"] {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 10px;
  background: rgba(0,0,0,0.25);
  color: var(--text);
  font-size: 1rem;
}

input[type="color"] {
  width: 100%;
  height: 2.5rem;
  border: none;
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
}

.row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.75rem;
}

.actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}

button {
  border: none;
  border-radius: 10px;
  padding: 0.75rem 1.25rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s ease, filter 0.15s ease;
}

button:hover { filter: brightness(1.1); }
button:active { transform: scale(0.97); }

button.primary {
  background: var(--accent);
  color: #0d1b1e;
}

button.secondary {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.2);
}

button.round {
  border-radius: 50%;
  width: 64px;
  height: 64px;
  padding: 0;
  background: rgba(0,0,0,0.55);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.2);
  font-size: 0.85rem;
  user-select: none;
  touch-action: none;
}

.status {
  min-height: 1.4em;
  margin: 0.75rem 0 0;
  color: var(--accent);
  text-align: center;
}

#scene {
  padding: 0;
}

#canvas-container {
  position: absolute;
  inset: 0;
  z-index: 1;
}

#canvas-container canvas {
  display: block;
  width: 100%;
  height: 100%;
}

#hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2;
  padding: 0.75rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  pointer-events: none;
}

#hud > * { pointer-events: auto; }

.panel {
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(8px);
  border-radius: 12px;
  padding: 0.6rem 0.9rem;
  font-size: 0.85rem;
  color: var(--text);
  line-height: 1.4;
  max-width: min(55ch, 70vw);
}

kbd {
  display: inline-block;
  padding: 0.05rem 0.35rem;
  border-radius: 4px;
  background: rgba(255,255,255,0.15);
  font-family: monospace;
}

#mobile-controls {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 1rem;
}

#mobile-controls > * { pointer-events: auto; }

#joystick-area {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  position: relative;
  touch-action: none;
  user-select: none;
  display: none;
}

#joystick-knob {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 48px;
  height: 48px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: rgba(79, 209, 197, 0.65);
  pointer-events: none;
}

#action-btns {
  display: none;
  flex-direction: column;
  gap: 0.75rem;
}

@media (pointer: coarse) {
  #joystick-area, #action-btns { display: flex; }
  #instructions { display: none; }
}

@media (max-width: 640px) {
  .row { grid-template-columns: 1fr 1fr; }
  .panel { max-width: none; font-size: 0.78rem; }
}
