:root {
  --accent: #4cc9f0;
  --bg: #0b0f1a;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: #e8eef7;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

#game {
  position: fixed;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

/* Vor Anmeldung: keine Spielsteuerung / kein 3D sichtbar */
body.needs-login #game,
body.needs-login #hud,
body.needs-login #crosshair {
  visibility: hidden !important;
  pointer-events: none !important;
}

/* Gespeicherter Token: kein Login-Flash bis refreshMe bestätigt */
html.auth-boot #overlay {
  display: none !important;
}
html.auth-boot #app-shell.hidden {
  display: flex !important;
}
html.auth-boot body.needs-login #game,
html.auth-boot body.needs-login #hud,
html.auth-boot body.needs-login #crosshair {
  visibility: visible !important;
  pointer-events: auto !important;
}

body.logged-in #game {
  visibility: visible;
  pointer-events: auto;
}

/* HUD & Fadenkreuz nur beim aktiven Spiel */
body.logged-in.playing #hud {
  display: flex;
  left: 12px;
}
body.logged-in.playing #crosshair {
  opacity: 1;
}
body.logged-in:not(.playing) #hud,
body.logged-in:not(.playing) #crosshair {
  display: none;
}

body.playing #crosshair { opacity: 1; }

/* App-Shell: Menüleiste + Content (nach Login) */
#app-shell {
  position: fixed;
  inset: 0;
  z-index: 15;
  display: none;
  pointer-events: none;
}
#app-shell:not(.hidden) {
  display: flex;
  pointer-events: auto;
}
body.logged-in.playing #app-shell {
  display: none;
}

/* Linkes Menü */
#side-menu {
  flex: 0 0 240px;
  width: 240px;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 16px 12px;
  overflow-y: auto;
  background: rgba(11, 15, 26, 0.94);
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  font-size: 13px;
}

.side-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.side-group:first-child { padding-top: 4px; }
.side-group-bottom {
  margin-top: auto;
  border-bottom: none;
  padding-bottom: 4px;
}

.side-group-identity {
  gap: 2px;
  padding-bottom: 14px;
}
.side-user-name {
  font-size: 16px;
  font-weight: 700;
  color: #e8eef7;
  line-height: 1.3;
}
.side-user-role {
  font-size: 12px;
  color: #9fb0c7;
}

.side-group-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #7e8aa0;
  padding: 0 10px 6px;
}

.side-nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: #c7d2e0;
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.side-nav-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}
.side-nav-btn.active {
  background: rgba(76, 201, 240, 0.15);
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(76, 201, 240, 0.35);
}

.side-profile-btn {
  padding: 8px 10px;
}
.profile-avatar {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.25);
  background: rgba(0, 0, 0, 0.2);
  position: relative;
  overflow: hidden;
}
.side-nav-label { line-height: 1.3; }

/* Profil-Content */
.profile-form {
  display: flex;
  flex-direction: column;
  gap: 22px;
  max-width: 520px;
}
.profile-field { display: flex; flex-direction: column; gap: 8px; }
.profile-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #9fb0c7;
}
.profile-input {
  width: 100%;
  max-width: 320px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(0, 0, 0, 0.35);
  color: #e8eef7;
  font-size: 14px;
}
.profile-input:focus {
  outline: none;
  border-color: var(--accent);
}
.profile-hint { font-size: 12px; color: #7e8aa0; }
.profile-checks {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.profile-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: #c7d2e0;
  cursor: pointer;
}
.profile-check input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.avatar-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 10px;
  max-width: 440px;
}
.avatar-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  color: #c7d2e0;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.avatar-card:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.18);
}
.avatar-card.active {
  border-color: var(--accent);
  background: rgba(76, 201, 240, 0.12);
  box-shadow: 0 0 0 1px rgba(76, 201, 240, 0.35);
}
.avatar-card-preview {
  width: 52px;
  height: 52px;
}
.avatar-card-name { font-size: 12px; font-weight: 600; }

.profile-preview-box { margin-top: 4px; }
.avatar-preview-large {
  width: 96px;
  height: 96px;
  margin-top: 4px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.25);
}

/* CSS-Avatar-Vorschau (Sidebar + Profil) */
.avatar-preview {
  --avatar-color: #e05a5a;
  position: relative;
  width: 100%;
  height: 100%;
  display: block;
  background: rgba(0, 0, 0, 0.15);
  border-radius: inherit;
  overflow: hidden;
}
.av-shape {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  background: var(--avatar-color);
}
.avatar-classic .av-body,
.avatar-bean .av-body {
  bottom: 8%;
  width: 46%;
  height: 52%;
  border-radius: 999px;
}
.avatar-bean .av-body-wide { width: 54%; height: 48%; bottom: 10%; }
.avatar-classic .av-head {
  top: 8%;
  width: 34%;
  height: 34%;
  border-radius: 50%;
  background: #ffd6a5;
}
.avatar-bean .av-visor {
  top: 10%;
  width: 44%;
  height: 28%;
  border-radius: 999px;
  background: linear-gradient(180deg, #b8ecff 0%, #6ec8e8 100%);
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.25);
}
.avatar-blocky .av-box { border-radius: 3px; }
.avatar-blocky .av-body {
  bottom: 10%;
  width: 44%;
  height: 46%;
}
.avatar-blocky .av-head {
  top: 10%;
  width: 32%;
  height: 32%;
}
.avatar-round .av-round {
  inset: 12%;
  width: auto;
  height: auto;
  border-radius: 50%;
  transform: none;
  left: 12%;
  right: 12%;
  top: 12%;
  bottom: 12%;
}

#profile-color .player-color-label { text-align: left; margin-bottom: 0; }
#profile-color .color-palette { justify-content: flex-start; }
#profile-color .player-color { margin: 0; max-width: none; text-align: left; }

/* Map-Editor im Content */
.content-panel-fill {
  padding: 0;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}
.content-panel-fill:not(.hidden) {
  display: flex;
  flex-direction: column;
}
#app-content.content-editor-active {
  overflow: hidden;
}
#editor-root.editor-shell {
  flex: 1;
  min-height: 0;
  width: 100%;
}

/* Content-Bereich */
#app-content {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  background: rgba(8, 12, 22, 0.88);
  backdrop-filter: blur(8px);
}
.content-panel {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  padding: 24px 28px;
}
.content-header {
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.content-title {
  font-size: 22px;
  font-weight: 700;
  color: #e8eef7;
}
.content-body {
  flex: 1;
}
.content-placeholder {
  color: #7e8aa0;
  font-size: 14px;
  line-height: 1.5;
}
.legacy-mount { display: none !important; }

.side-head {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.side-brand {
  font-size: 20px;
  font-weight: 700;
  background: linear-gradient(90deg, #4cc9f0, #b388ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.side-user { color: #9fb0c7; font-size: 12px; }
.side-play {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #06121f;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
}
.side-play:hover { filter: brightness(1.08); }
.side-quality { justify-content: flex-start; margin: 0; }
.side-nav { display: flex; flex-direction: column; gap: 6px; }
.side-link {
  display: block;
  padding: 9px 10px;
  border-radius: 8px;
  color: #c7d2e0;
  text-decoration: none;
  background: rgba(255, 255, 255, 0.05);
}
.side-link:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
.side-controls {
  margin-top: 4px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.2);
  font-size: 12px;
  color: #9fb0c7;
}
.side-controls summary { cursor: pointer; font-weight: 600; color: #c7d2e0; }
.side-controls ul { margin-top: 8px; padding-left: 0; list-style: none; }
.side-controls li { margin: 4px 0; }

/* Fadenkreuz */
#crosshair {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 22px;
  line-height: 1;
  color: rgba(255, 255, 255, 0.8);
  text-shadow: 0 0 4px rgba(0, 0, 0, 0.8);
  pointer-events: none;
  user-select: none;
  opacity: 0;
  transition: opacity 0.2s;
}
body.playing #crosshair { opacity: 1; }

/* HUD */
#hud {
  position: fixed;
  top: 12px;
  left: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  background: rgba(11, 15, 26, 0.55);
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  pointer-events: none;
  backdrop-filter: blur(6px);
}
#hud #net-status { color: var(--accent); }

.quality-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 12px 0;
  font-size: 14px;
}
.quality-row select {
  background: rgba(0,0,0,0.35);
  border: 1px solid rgba(255,255,255,0.15);
  color: inherit;
  padding: 6px 10px;
  border-radius: 8px;
}

.lobby-panel {
  margin: 16px 0;
  padding: 14px;
  background: rgba(0,0,0,0.25);
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.08);
  text-align: left;
}
.lobby-head { font-weight: 600; margin-bottom: 8px; }
.lobby-hint, .lobby-empty { font-size: 13px; opacity: 0.8; }
.lobby-form { display: flex; gap: 8px; margin-bottom: 10px; }
.lobby-form input {
  flex: 1;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(0,0,0,0.3);
  color: inherit;
}
.lobby-form button, .lobby-join {
  padding: 8px 12px;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: #0b0f1a;
  font-weight: 600;
  cursor: pointer;
}
.lobby-sessions { display: flex; flex-direction: column; gap: 6px; max-height: 140px; overflow-y: auto; }
.lobby-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  background: rgba(255,255,255,0.04);
  border-radius: 8px;
  font-size: 13px;
}
.lobby-item-info { display: flex; flex-direction: column; gap: 2px; }
.lobby-item-info span { opacity: 0.75; font-size: 12px; }
.lobby-msg { font-size: 13px; margin-bottom: 8px; }
.lobby-msg.err { color: #ff8a8a; }
.lobby-msg.ok { color: #8ae8b0; }

/* Overlay */
#overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 50% 30%, rgba(76, 201, 240, 0.12), transparent 60%),
              rgba(6, 9, 17, 0.85);
  backdrop-filter: blur(4px);
  z-index: 10;
  transition: opacity 0.3s;
}
#overlay.hidden { display: none; }

#app-content .map-info {
  text-align: left;
  margin: 0;
}

#account-panel.hidden { display: none; }

.hidden { display: none !important; }

/* Login (zentral im Overlay) */
.login-title {
  font-size: 22px;
  margin: 8px 0 6px;
  color: #e8eef7;
}
.login-hint, .login-foot {
  font-size: 13px;
  color: #9fb0c7;
  margin-bottom: 14px;
}
.login-foot { margin-top: 12px; margin-bottom: 0; font-size: 12px; color: #7e8aa0; }
.login-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
}
.login-form input {
  width: 100%;
  padding: 11px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(0,0,0,0.35);
  color: #e8eef7;
  font-size: 14px;
}
.login-form input:focus {
  outline: none;
  border-color: var(--accent);
}
.login-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}
.login-submit, .login-register {
  flex: 1;
  padding: 11px 14px;
  border-radius: 10px;
  border: none;
  font-weight: 600;
  cursor: pointer;
  font-size: 14px;
}
.login-submit {
  background: var(--accent);
  color: #06121f;
}
.login-register {
  background: rgba(255,255,255,0.1);
  color: #e8eef7;
}
.login-msg {
  min-height: 1.2em;
  margin-top: 10px;
  font-size: 13px;
  text-align: center;
}
.login-msg.err { color: #ff8a8a; }
.login-msg.ok { color: #8ee6a8; }

.panel {
  text-align: center;
  max-width: 440px;
  padding: 36px 40px;
  background: rgba(17, 24, 39, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.panel h1 {
  font-size: 40px;
  letter-spacing: 1px;
  background: linear-gradient(90deg, #4cc9f0, #b388ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.subtitle { color: #9fb0c7; margin-top: 4px; margin-bottom: 22px; }

#play {
  font-size: 16px;
  font-weight: 600;
  color: #06121f;
  background: var(--accent);
  border: none;
  border-radius: 10px;
  padding: 12px 28px;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.2s;
  box-shadow: 0 6px 20px rgba(76, 201, 240, 0.35);
}
#play:hover { transform: translateY(-2px); box-shadow: 0 10px 26px rgba(76, 201, 240, 0.5); }
#play:active { transform: translateY(0); }
#play[hidden] { display: none; }

.ap-hint-login {
  margin: 0 0 10px;
  font-size: 12px;
  color: #7e8aa0;
  line-height: 1.5;
}

.controls {
  list-style: none;
  margin: 24px auto 8px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 18px;
  text-align: left;
  font-size: 14px;
  color: #c7d2e0;
}
.controls b {
  display: inline-block;
  min-width: 78px;
  color: #fff;
}
.hint {
  margin-top: 18px;
  font-size: 12px;
  color: #7e8aa0;
  line-height: 1.5;
}

.map-info {
  margin-bottom: 18px;
  font-size: 13px;
  color: #cdd8e8;
}
.map-info b { color: var(--accent); }

.player-color {
  margin: 0 auto 18px;
  max-width: 280px;
  text-align: center;
}
.player-color-label {
  font-size: 12px;
  color: #9fb0c7;
  margin-bottom: 8px;
}
.color-palette {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}
.color-swatch {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  background: var(--swatch);
  cursor: pointer;
  padding: 0;
  transition: transform 0.12s, box-shadow 0.12s;
}
.color-swatch:hover { transform: scale(1.08); }
.color-swatch.active {
  border-color: #fff;
  box-shadow: 0 0 0 2px var(--accent), 0 0 12px var(--swatch);
  transform: scale(1.1);
}

.editor-link {
  display: inline-block;
  margin-top: 14px;
  font-size: 14px;
  color: #c7d2e0;
  text-decoration: none;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.25);
  padding-bottom: 2px;
}
.editor-link:hover { color: #fff; }

/* 3D-Engine: lustiger Lade-Spot */
.engine-loading {
  position: fixed;
  inset: 0;
  z-index: 25;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(ellipse at 50% 30%, rgba(30, 50, 90, 0.55), rgba(11, 15, 26, 0.92));
  backdrop-filter: blur(8px);
}
.engine-loading.hidden { display: none; }
.engine-loading-card {
  width: min(420px, 92vw);
  padding: 28px 24px 22px;
  text-align: center;
  background: rgba(15, 22, 38, 0.88);
  border: 1px solid rgba(76, 201, 240, 0.25);
  border-radius: 20px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45), 0 0 40px rgba(76, 201, 240, 0.08);
}
.engine-loading-scene {
  position: relative;
  height: 110px;
  margin-bottom: 18px;
  overflow: hidden;
  border-radius: 12px;
  background: linear-gradient(180deg, #5b9cff 0%, #8ec5ff 38%, #c8e6ff 62%, #3d6b3a 62%, #2d5029 100%);
}
.engine-loading-sun {
  position: absolute;
  top: 12px;
  right: 18px;
  font-size: 22px;
  animation: engine-sun-pulse 2.4s ease-in-out infinite;
}
.engine-loading-cloud {
  position: absolute;
  top: 16px;
  font-size: 18px;
  opacity: 0.85;
  animation: engine-cloud-drift 5s linear infinite;
}
.engine-loading-cloud.cloud-a { left: 8%; animation-duration: 6.5s; }
.engine-loading-cloud.cloud-b { left: 42%; font-size: 14px; top: 28px; animation-duration: 8s; animation-delay: -2s; }
.engine-loading-ground {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 38%;
  background: repeating-linear-gradient(
    90deg,
    #3d6b3a 0 14px,
    #356232 14px 28px
  );
}
.engine-loading-walker {
  position: absolute;
  left: 0;
  bottom: 22%;
  width: 22px;
  height: 34px;
  animation: engine-walker-move 2.8s ease-in-out infinite;
}
.walker-head {
  position: absolute;
  top: 0;
  left: 5px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #ffcc80;
  border: 2px solid #e8a85c;
}
.walker-torso {
  position: absolute;
  top: 13px;
  left: 7px;
  width: 8px;
  height: 12px;
  border-radius: 3px;
  background: var(--accent);
}
.walker-leg {
  position: absolute;
  bottom: 0;
  width: 5px;
  height: 11px;
  border-radius: 2px;
  background: #4a5d7a;
  transform-origin: top center;
}
.walker-leg-l { left: 6px; animation: engine-leg-l 0.45s ease-in-out infinite; }
.walker-leg-r { left: 12px; animation: engine-leg-r 0.45s ease-in-out infinite; }
.engine-loading-title {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 700;
  color: #e8eef7;
}
.engine-loading-spot {
  margin: 0;
  min-height: 2.6em;
  font-size: 14px;
  line-height: 1.45;
  color: #9fb0c7;
  transition: opacity 0.25s ease;
}
.engine-loading-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 14px;
}
.engine-loading-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  animation: engine-dot-bounce 1.1s ease-in-out infinite;
}
.engine-loading-dots span:nth-child(2) { animation-delay: 0.15s; }
.engine-loading-dots span:nth-child(3) { animation-delay: 0.3s; }
.engine-loading--error .engine-loading-scene { filter: grayscale(0.7) brightness(0.7); }
.engine-loading--error .engine-loading-spot { color: #ff8a8a; }

@keyframes engine-walker-move {
  0%, 100% { left: 8%; transform: scaleX(1); }
  48% { left: calc(100% - 36px); transform: scaleX(1); }
  50% { left: calc(100% - 36px); transform: scaleX(-1); }
  98% { left: 8%; transform: scaleX(-1); }
}
@keyframes engine-leg-l {
  0%, 100% { transform: rotate(22deg); }
  50% { transform: rotate(-22deg); }
}
@keyframes engine-leg-r {
  0%, 100% { transform: rotate(-22deg); }
  50% { transform: rotate(22deg); }
}
@keyframes engine-cloud-drift {
  from { transform: translateX(-10px); }
  to { transform: translateX(30px); }
}
@keyframes engine-sun-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}
@keyframes engine-dot-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.45; }
  40% { transform: translateY(-6px); opacity: 1; }
}

/* Konto-Panel im linken Menü */
#app-content #account-panel {
  position: static;
  width: 100%;
  max-height: none;
  margin-top: auto;
  padding: 10px 0 0;
  background: transparent;
  border: none;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 0;
  box-shadow: none;
  backdrop-filter: none;
  overflow: visible;
}
body.playing #account-panel { opacity: 1; pointer-events: auto; }

.ap-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.ap-title { font-weight: 700; color: #fff; }
.ap-user { color: #c7d2e0; margin-bottom: 10px; }
.ap-user b { color: var(--accent); }

.ap-form { display: flex; flex-direction: column; gap: 8px; }
#account-panel input {
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(8, 12, 22, 0.6);
  color: #e8eef7;
  font-size: 13px;
}
#account-panel input:focus { outline: none; border-color: var(--accent); }

.ap-row { display: flex; gap: 8px; }
#account-panel button {
  flex: 1;
  padding: 8px 10px;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: #06121f;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: filter 0.15s;
}
#account-panel button:hover { filter: brightness(1.1); }
#account-panel button[data-act="register"],
#account-panel button[data-act="load-progress"] {
  background: rgba(255, 255, 255, 0.12);
  color: #e8eef7;
}
.ap-link {
  background: none !important;
  color: #9fb0c7 !important;
  border: none;
  font-size: 12px !important;
  font-weight: 500 !important;
  cursor: pointer;
  padding: 0 !important;
  flex: 0 !important;
  white-space: nowrap;
}
.ap-link:hover { color: #fff !important; filter: none; }

.ap-logout {
  width: 100%;
  margin-bottom: 10px;
  padding: 8px 10px !important;
  border-radius: 8px !important;
  border: 1px solid rgba(255, 255, 255, 0.18) !important;
  background: rgba(255, 255, 255, 0.08) !important;
  color: #e8eef7 !important;
  font-size: 13px !important;
  font-weight: 600 !important;
  cursor: pointer;
  flex: none !important;
}
.ap-logout:hover {
  background: rgba(255, 107, 107, 0.18) !important;
  border-color: rgba(255, 107, 107, 0.45) !important;
  color: #ffc9c9 !important;
  filter: none;
}

.ap-section { margin-top: 14px; border-top: 1px solid rgba(255, 255, 255, 0.08); padding-top: 10px; }
.ap-sec-title {
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 600; color: #cdd8e8; margin-bottom: 8px;
}
.ap-list { display: flex; flex-direction: column; gap: 6px; max-height: 200px; overflow-y: auto; }
.ap-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px; padding: 6px 9px;
}
.ap-item-name { color: #dbe4f0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ap-item-name i { color: #8290a6; font-style: normal; font-size: 11px; }
.ap-score { color: var(--accent); font-variant-numeric: tabular-nums; font-weight: 600; }
.ap-mini {
  flex: 0 !important; padding: 4px 10px !important; font-size: 12px !important;
}
.ap-tag {
  display: inline-block; margin-left: 4px; padding: 1px 7px;
  border-radius: 999px; font-size: 10px; font-weight: 700;
  background: rgba(179, 136, 255, 0.22); color: #cbb4ff; vertical-align: middle;
}
.ap-admin-link {
  display: block; margin-bottom: 10px; font-size: 13px; color: var(--accent);
  text-decoration: none; border-bottom: 1px dashed rgba(76, 201, 240, 0.4);
  padding-bottom: 2px; width: fit-content;
}
.ap-admin-link:hover { filter: brightness(1.15); }
.ap-account-toggle { margin-top: 10px; display: inline-block; }
.ap-account { margin-top: 10px; display: flex; flex-direction: column; gap: 10px; }
.ap-account.hidden { display: none; }
.ap-danger {
  background: rgba(255, 107, 107, 0.16) !important; color: #ff9a9a !important;
  border: 1px solid rgba(255, 107, 107, 0.4) !important;
}
.ap-empty { color: #7e8aa0; font-size: 12px; padding: 4px 2px; }
.ap-empty.err, .ap-msg.err { color: #ff8a8a; }
.ap-msg { font-size: 12px; margin-bottom: 8px; padding: 6px 9px; border-radius: 8px; background: rgba(255, 255, 255, 0.06); }
.ap-msg.ok { color: #8ee6a8; }

.ap-dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(6, 10, 18, 0.72);
  backdrop-filter: blur(4px);
  padding: 16px;
}
.ap-dialog {
  width: 100%;
  max-width: 320px;
  background: rgba(17, 24, 39, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55);
  padding: 18px 20px 16px;
  text-align: center;
}
.ap-dialog-title {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
}
.ap-dialog-map {
  margin: 0 0 18px;
  font-size: 13px;
  color: #9fb0c7;
}
.ap-dialog-map b { color: var(--accent); }
.ap-dialog-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}
.ap-dialog-actions button {
  flex: 1;
  padding: 10px 12px;
  border-radius: 8px;
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.ap-dialog-cancel {
  background: rgba(255, 255, 255, 0.1);
  color: #e8eef7;
}
.ap-dialog-cancel:hover { background: rgba(255, 255, 255, 0.16); }
.ap-dialog-ok {
  background: var(--accent);
  color: #06121f;
}
.ap-dialog-ok:hover { filter: brightness(1.08); }

@media (max-width: 640px) {
  #app-shell:not(.hidden) {
    flex-direction: column;
  }
  #side-menu {
    flex: 0 0 auto;
    width: 100%;
    max-height: 42vh;
    border-right: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  }
  #app-content {
    flex: 1;
    min-height: 0;
  }
  body.logged-in.playing #hud {
    top: auto;
    bottom: 12px;
    left: 12px;
  }
}
