html, body {
  margin: 0;
  padding: 0;
  overflow: hidden;
  height: 100%;
  background: #0b0b10;
  color: #e8e8f0;
  font-family: system-ui, sans-serif;
}

#game-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100dvh;
  touch-action: none;
  display: block;
}

.hidden {
  display: none !important;
}

.panel {
  position: fixed;
  background: rgba(15, 15, 22, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 12px 16px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.dim {
  color: #9a9ab0;
  font-size: 0.9em;
}

#connection-banner {
  position: fixed;
  top: env(safe-area-inset-top, 0);
  left: 0;
  right: 0;
  text-align: center;
  background: #7a1f1f;
  color: white;
  padding: 6px;
  font-size: 0.9em;
  z-index: 20;
}

#lobby-wrap {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: flex-start;
  gap: 16px;
  z-index: 10;
}

/* .panel defaults to position:fixed (see above), which would pull these two
   out of #lobby-wrap's flex layout entirely — only the wrap itself needs to
   be fixed to the viewport. */
#lobby,
#lobby-role-info {
  position: static;
}

#lobby {
  min-width: 320px;
  text-align: center;
}

#lobby-role-info {
  width: 220px;
  text-align: left;
}

#lobby-role-info-title {
  font-size: 1.05em;
  margin: 0 0 8px;
  color: #5ad1a8;
}

#lobby-role-info-body {
  margin: 0;
  font-size: 0.9em;
  line-height: 1.45;
  color: #cfcfe0;
}

#lobby h1 {
  font-size: 1.3em;
  margin: 0 0 12px;
}

#lobby-roles {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.lobby-role-btn {
  padding: 10px 16px;
  font-size: 1em;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: #23232f;
  color: #e8e8f0;
  cursor: pointer;
  touch-action: manipulation;
}

.lobby-role-btn:hover:not(:disabled) {
  background: #32324a;
}

.lobby-role-btn.mine {
  border-color: #5ad1a8;
  background: #1c4a3a;
}

.lobby-role-btn.claimed:not(.mine) {
  opacity: 0.5;
  cursor: not-allowed;
}

#btn-start-game {
  width: 100%;
  margin-top: 4px;
  padding: 10px 16px;
  font-size: 1em;
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid rgba(90, 209, 168, 0.5);
  background: #1c4a3a;
  color: #5ad1a8;
  cursor: pointer;
  touch-action: manipulation;
}

#btn-start-game:hover:not(:disabled) {
  background: #23604a;
}

#btn-start-game:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  border-color: rgba(255, 255, 255, 0.2);
  background: #23232f;
  color: #9a9ab0;
}

#lobby-classes {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.lobby-class-btn {
  flex: 1;
  padding: 10px 12px;
  font-size: 0.95em;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: #23232f;
  color: #e8e8f0;
  cursor: pointer;
  touch-action: manipulation;
}

.lobby-class-btn:hover {
  background: #32324a;
}

.lobby-class-btn.mine {
  border-color: #5ad1a8;
  background: #1c4a3a;
}

#hud {
  position: fixed;
  top: env(safe-area-inset-top, 8px);
  left: 8px;
  z-index: 5;
}

#btn-godmode {
  position: fixed;
  top: env(safe-area-inset-top, 8px);
  right: 8px;
  z-index: 5;
  padding: 8px 14px;
  font-size: 0.85em;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: #23232f;
  color: #9a9ab0;
  cursor: pointer;
  touch-action: manipulation;
}

#btn-godmode:hover {
  border-color: #5ad1a8;
}

#btn-godmode.active {
  background: #4a3a1c;
  border-color: #e0c040;
  color: #e0c040;
}

#debug-panel {
  position: fixed;
  top: calc(env(safe-area-inset-top, 8px) + 40px);
  right: 8px;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

#debug-piece-picker {
  display: flex;
  gap: 4px;
}

#debug-panel button,
.debug-piece-btn {
  padding: 6px 10px;
  font-size: 0.8em;
  border-radius: 6px;
  border: 1px solid rgba(224, 192, 64, 0.4);
  background: #2a2410;
  color: #e0c040;
  cursor: pointer;
  touch-action: manipulation;
}

#debug-panel button:hover,
.debug-piece-btn:hover {
  background: #3a3018;
}

.debug-piece-btn {
  padding: 6px 8px;
  min-width: 28px;
}

#btn-return-lobby {
  position: fixed;
  bottom: env(safe-area-inset-bottom, 8px);
  left: 8px;
  z-index: 6;
  padding: 8px 14px;
  font-size: 0.85em;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: #23232f;
  color: #9a9ab0;
  cursor: pointer;
  touch-action: manipulation;
}

#btn-return-lobby:hover {
  border-color: #e05a5a;
  color: #e05a5a;
}

#levelup-overlay {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translateX(-50%);
  z-index: 25;
}

#levelup-panel {
  background: #16161f;
  border: 1px solid rgba(90, 209, 168, 0.4);
  border-radius: 10px;
  padding: 16px 24px;
  text-align: center;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}

#levelup-panel h1 {
  font-size: 1.1em;
  margin: 0 0 4px;
  color: #5ad1a8;
}

#levelup-choices {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.levelup-btn {
  padding: 10px 14px;
  font-size: 0.95em;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: #23232f;
  color: #e8e8f0;
  cursor: pointer;
  touch-action: manipulation;
}

.levelup-btn:hover {
  background: #32324a;
  border-color: #5ad1a8;
}

#game-over-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  z-index: 30;
}

#game-over-panel {
  background: #16161f;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  padding: 24px 32px;
  text-align: center;
}

#btn-reload {
  margin-top: 12px;
  padding: 8px 20px;
  font-size: 1em;
  border-radius: 6px;
  border: none;
  background: #3a5ad1;
  color: white;
  cursor: pointer;
}
