:root {
  --bg: #0f0d09;
  --panel: #1f1a12;
  --panel2: #2a2318;
  --border: #5a4a2c;
  --border-hi: #8a7040;
  --gold: #e8c065;
  --text: #efe6d2;
  --muted: #a89a7e;
  --red: #d0533f;
  --green: #5fbf5a;
  --blue: #5aa5e0;
  --side-w: 290px;
  --btn-h: 42px;
  --fs: 14px;
  --hud-h: 46px;
}

/* Größen richten sich nach der verfügbaren Fläche (Klassen setzt js/device.js laufend) */
html.touch { --btn-h: 48px; }
html.layout-regular.touch { --side-w: 310px; --fs: 15px; --hud-h: 52px; --btn-h: 50px; }
html.layout-compact { --side-w: 220px; --btn-h: 38px; --fs: 12px; --hud-h: 36px; }
html.layout-stack { --hud-h: 48px; }
@media (min-width: 1700px) { html.layout-regular { --side-w: 340px; --fs: 15px; } }

/* Hilfselement zum Auslesen der sicheren Ränder (Notch, Home-Balken) */
#safe-probe {
  position: fixed; left: 0; top: 0; width: 0; height: 0; visibility: hidden; pointer-events: none;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: var(--fs);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

.hidden { display: none !important; }

/* ------------------------------------------------------------ Layout */
#app {
  position: fixed;
  inset: 0;
  display: flex;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: radial-gradient(ellipse at 40% 30%, #1e2416 0%, #0f0d09 70%);
}

#stage {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

#hud {
  flex: 0 0 var(--hud-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 8px;
  background: linear-gradient(#2a2318, #1a160f);
  border-bottom: 2px solid var(--border);
}
#hud .res { display: flex; align-items: center; gap: 6px; min-width: 0; overflow: hidden; }
#hud .ctrl { display: flex; gap: 6px; flex: 0 0 auto; }
#hud .next { color: var(--muted); font-size: 0.9em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }

.chip {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border);
  white-space: nowrap;
  font-weight: 600;
}
.chip.gold { color: #ffd65a; }
.chip.lives { color: #ff9a8a; }

#canvas-wrap {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

canvas#game {
  display: block;
  touch-action: none;
  border: 2px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 6px 30px rgba(0, 0, 0, 0.6);
  background: #3d6b2c;
}

#side {
  flex: 0 0 var(--side-w);
  width: var(--side-w);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 8px;
  background: linear-gradient(var(--panel), #14110c);
  border-left: 2px solid var(--border);
}

/* ------------------------------------------------------------ Panels */
.panel {
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  margin-bottom: 8px;
}
.panel h3 {
  margin: 0 0 6px;
  font-family: Cinzel, Georgia, serif;
  font-size: 1em;
  color: var(--gold);
  letter-spacing: 0.03em;
}
.panel h3 small { color: var(--muted); font-family: sans-serif; font-weight: normal; font-size: 0.8em; }
.panel .stats { font-size: 0.92em; line-height: 1.5; color: #ddd2bb; }
.panel .dyn { font-size: 0.85em; color: var(--muted); margin-top: 4px; min-height: 1em; }
.row { display: flex; gap: 6px; margin-top: 8px; }
.row .btn { flex: 1; }
.hint { font-size: 0.82em; color: var(--muted); margin-top: 6px; }
.hint:empty { display: none; }

/* ------------------------------------------------------------ Buttons */
.btn {
  min-height: var(--btn-h);
  padding: 0 12px;
  font: inherit;
  font-weight: 600;
  color: var(--text);
  background: linear-gradient(#3e3322, #261f15);
  border: 1px solid var(--border-hi);
  border-radius: 6px;
  cursor: pointer;
  touch-action: manipulation;
}
.btn:hover:not(:disabled) { filter: brightness(1.2); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.primary { background: linear-gradient(#7a5a1c, #4a3510); border-color: var(--gold); color: #fff3d0; }
.btn.danger { background: linear-gradient(#5a2a20, #3a1812); border-color: #8a4030; }
.btn.icon { min-width: var(--btn-h); padding: 0 8px; font-size: 1.1em; }
.btn.wide { width: 100%; margin-top: 8px; }
.btn.big { min-height: 54px; font-size: 1.15em; padding: 0 28px; }
#hud .btn { min-height: calc(var(--hud-h) - 10px); }

.key {
  display: inline-block;
  font-size: 0.7em;
  padding: 0 4px;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.45);
  color: var(--muted);
  font-weight: 600;
}
html.touch .key { display: none; }

/* Bauknöpfe */
.build-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.build-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 6px 2px 5px;
  min-height: calc(var(--btn-h) * 1.6);
  font: inherit;
  color: var(--text);
  background: linear-gradient(#352b1d, #211b12);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
}
.build-btn .ico { font-size: 1.5em; line-height: 1.1; }
.build-btn .nm { font-size: 0.72em; line-height: 1.1; text-align: center; }
.build-btn .cost { font-size: 0.75em; color: #ffd65a; }
.build-btn .key { position: absolute; top: 2px; right: 2px; }
.build-btn:disabled { opacity: 0.45; }
.build-btn.active { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold) inset, 0 0 10px rgba(232, 192, 101, 0.5); }

/* ------------------------------------------------------------ Held */
.hero-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.hero-icon {
  font-size: 1.8em;
  width: 1.7em; height: 1.7em;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--gold);
  border-radius: 6px;
}
.hero-name { font-family: Cinzel, Georgia, serif; font-weight: 800; color: var(--gold); font-size: 1.1em; word-break: break-word; }
.hero-sub { color: var(--muted); font-size: 0.85em; }

.bar {
  position: relative;
  height: 16px;
  margin: 4px 0;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid #000;
  border-radius: 4px;
  overflow: hidden;
}
.bar > div { height: 100%; transition: width 0.15s; }
.bar.hp > div { background: linear-gradient(#6fdc68, #3c9a36); }
.bar.xp { height: 12px; }
.bar.xp > div { background: linear-gradient(#b38cff, #6a44c0); }
.bar span {
  position: absolute; inset: 0;
  font-size: 10px; line-height: 14px; text-align: center;
  color: #fff; text-shadow: 0 1px 2px #000;
}
.bar.xp span { line-height: 11px; font-size: 9px; }
.hero-stats { font-size: 0.82em; color: #d8ccb0; margin: 4px 0 6px; }

.abilities { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.ab-btn {
  position: relative;
  overflow: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: calc(var(--btn-h) * 1.4);
  padding: 4px 2px;
  font: inherit;
  color: var(--text);
  background: linear-gradient(#2f3a5a, #1a2034);
  border: 1px solid #5a6a9a;
  border-radius: 6px;
  cursor: pointer;
}
.ab-btn .ico { font-size: 1.4em; line-height: 1.1; }
.ab-btn .nm { font-size: 0.68em; text-align: center; line-height: 1.1; }
.ab-btn .cdov { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: rgba(0, 0, 0, 0.65); pointer-events: none; }
.ab-btn .lock {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 1.1em; color: #fff; text-shadow: 0 1px 3px #000;
  pointer-events: none;
}
.ab-btn .key { position: absolute; top: 2px; right: 2px; }
.ab-btn.locked { filter: grayscale(1); opacity: 0.5; }
.ab-btn.locked .lock { font-size: 0.8em; background: rgba(0, 0, 0, 0.5); }

.inventory { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; margin-top: 8px; }
html.layout-compact .inventory { grid-template-columns: repeat(3, 1fr); }
.slot {
  aspect-ratio: 1;
  min-height: 34px;
  font-size: 1.3em;
  padding: 0;
  color: var(--text);
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid var(--border-hi);
  border-radius: 5px;
  cursor: pointer;
}
.slot.empty { border-style: dashed; border-color: var(--border); }
.slot.sel { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold) inset; }

.item-actions {
  margin-top: 6px;
  padding: 6px;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 6px;
  font-size: 0.88em;
}
.item-actions .it-name { font-weight: 700; color: var(--gold); }
.item-actions .it-desc { color: var(--muted); }

.help div { font-size: 0.82em; color: var(--muted); line-height: 1.6; }
.help b { color: var(--text); }

/* ------------------------------------------------------------ Meldungen */
#toasts {
  position: absolute;
  top: 8px; left: 50%;
  transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  pointer-events: none;
  width: 90%;
}
.toast {
  padding: 6px 14px;
  border-radius: 6px;
  background: rgba(20, 16, 10, 0.88);
  border: 1px solid var(--border-hi);
  font-weight: 600;
  text-align: center;
  transition: opacity 0.5s;
  max-width: 100%;
}
.toast.good { border-color: #5fbf5a; color: #b8f5b0; }
.toast.bad  { border-color: #d0533f; color: #ffb4a6; }
.toast.err  { border-color: #b08030; color: #ffd890; }
.toast.fade { opacity: 0; }

#pause-overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  font-family: Cinzel, Georgia, serif;
  font-size: 2em;
  color: var(--gold);
  text-align: center;
  cursor: pointer;
}
#pause-overlay small { display: block; font-family: sans-serif; font-size: 0.4em; color: var(--muted); margin-top: 6px; }

/* ------------------------------------------------------------ Bildschirme */
.screen {
  position: fixed; inset: 0;
  z-index: 10;
  display: flex; align-items: center; justify-content: center;
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  background: rgba(8, 6, 3, 0.82);
  overflow-y: auto;
}
#screen-start {
  background:
    radial-gradient(ellipse at 50% 0%, rgba(232, 192, 101, 0.18), transparent 60%),
    linear-gradient(#1a2214, #0c0a06);
  align-items: flex-start;
}
.screen-box {
  width: 100%;
  max-width: 900px;
  margin: auto;
  padding: 20px;
  text-align: center;
  background: linear-gradient(#262016, #18140d);
  border: 2px solid var(--border-hi);
  border-radius: 12px;
  box-shadow: 0 10px 50px rgba(0, 0, 0, 0.7);
}
.screen-box h1 {
  margin: 0;
  font-family: Cinzel, Georgia, serif;
  font-weight: 800;
  font-size: 2.6em;
  color: var(--gold);
  text-shadow: 0 2px 0 #5a3a10, 0 0 24px rgba(232, 192, 101, 0.35);
}
.screen-box h2 { font-family: Cinzel, Georgia, serif; color: var(--gold); margin: 0 0 10px; }
.tagline { color: var(--muted); margin: 4px 0 16px; font-style: italic; }
.name-label { display: block; color: var(--muted); font-size: 0.9em; margin-bottom: 4px; }
#hero-name-input {
  width: 100%;
  max-width: 320px;
  padding: 10px 12px;
  font-size: 16px; /* verhindert Auto-Zoom auf iOS */
  text-align: center;
  color: var(--text);
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid var(--border-hi);
  border-radius: 6px;
  -webkit-user-select: text;
  user-select: text;
}
#hero-name-input:focus { outline: 2px solid var(--gold); }

.class-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 16px 0; }
.class-card {
  display: flex; flex-direction: column; align-items: center;
  padding: 12px 10px;
  font: inherit;
  color: var(--text);
  text-align: center;
  background: linear-gradient(#2e261a, #1c170f);
  border: 2px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
}
.class-card .ico { font-size: 2.4em; }
.class-card .nm { font-family: Cinzel, Georgia, serif; font-weight: 800; color: var(--gold); font-size: 1.15em; margin-top: 4px; }
.class-card .role { color: #c8b890; font-size: 0.8em; margin-bottom: 6px; }
.class-card .desc { font-size: 0.82em; color: var(--muted); min-height: 3.6em; }
.class-card ul { list-style: none; padding: 0; margin: 8px 0 0; font-size: 0.82em; text-align: left; }
.class-card li { padding: 2px 0; }
.class-card li small { color: var(--muted); }
.class-card.sel { border-color: var(--gold); box-shadow: 0 0 18px rgba(232, 192, 101, 0.4); background: linear-gradient(#3e3220, #241d12); }

.best { color: #ffd65a; margin-top: 10px; min-height: 1em; }
.device { color: var(--muted); font-size: 0.82em; margin-top: 8px; }
.ios-hint { margin-top: 10px; font-size: 0.85em; color: #b8d4ff; }

/* Shop */
.modal { z-index: 20; }
.screen-box.shop { max-width: 760px; text-align: left; padding: 14px; }
.shop-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.shop-head h2 { margin: 0; flex: 1; }
.shop-items { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.shop-item {
  display: flex; align-items: center; gap: 8px;
  min-height: 52px;
  padding: 6px 8px;
  font: inherit;
  color: var(--text);
  text-align: left;
  background: linear-gradient(#352b1d, #211b12);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
}
.shop-item:hover:not(:disabled) { border-color: var(--gold); }
.shop-item:disabled { opacity: 0.45; cursor: default; }
.shop-item .ico { font-size: 1.6em; }
.shop-item .txt { flex: 1; display: flex; flex-direction: column; }
.shop-item .nm { font-weight: 700; }
.shop-item .desc { font-size: 0.8em; color: var(--muted); }
.shop-item .cost { color: #ffd65a; font-weight: 700; white-space: nowrap; }

#rotate-hint { display: none; }

/* Spielende */
.over-level { color: var(--gold); font-weight: 700; }
.over-buttons { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 14px; }

/* Levelauswahl */
.screen-box.levels { max-width: 1100px; text-align: left; padding: 14px; }
.lv-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.lv-head h2 { flex: 1; margin: 0; }
.lv-body { display: flex; gap: 14px; align-items: flex-start; }
.lv-grid { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.lv-row { display: flex; flex-direction: column; gap: 4px; }
.lv-biome { font-family: Cinzel, Georgia, serif; font-weight: 700; color: var(--gold); font-size: 0.95em; }
.lv-btns { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; }
.lv-btn {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 52px;
  padding: 2px;
  font: inherit;
  color: #fff;
  border: 1px solid rgba(0, 0, 0, 0.5);
  border-radius: 6px;
  cursor: pointer;
  text-shadow: 0 1px 2px #000;
}
.lv-btn .num { font-weight: 800; font-size: 1.15em; line-height: 1.1; }
.lv-btn .st { font-size: 0.7em; color: #ffd65a; min-height: 1em; letter-spacing: -1px; }
.lv-btn .tags { font-size: 0.65em; min-height: 1em; }
.lv-btn.biome-grass   { background: linear-gradient(#4f8a38, #2d5420); }
.lv-btn.biome-steppe  { background: linear-gradient(#9a9a52, #646430); }
.lv-btn.biome-desert  { background: linear-gradient(#d8b06a, #a07a3c); }
.lv-btn.biome-ice     { background: linear-gradient(#a9c4dc, #5e7d9a); }
.lv-btn.biome-volcano { background: linear-gradient(#6a2e1e, #2e1a16); }
.lv-btn.locked { filter: grayscale(0.85) brightness(0.55); cursor: default; }
.lv-btn.sel { outline: 3px solid var(--gold); outline-offset: 1px; z-index: 1; }
.lv-btn:hover:not(:disabled) { filter: brightness(1.15); }
.lv-detail { flex: 0 0 340px; display: flex; flex-direction: column; gap: 8px; }
#lv-preview { width: 100%; height: auto; aspect-ratio: 3 / 2; border: 2px solid var(--border-hi); border-radius: 6px; background: #111; }
.lv-info { font-size: 0.9em; line-height: 1.6; color: #ddd2bb; }
.lv-info .lv-name { font-family: Cinzel, Georgia, serif; font-weight: 800; color: var(--gold); font-size: 1.1em; }
.lv-info .lv-rec { color: #ffd65a; }
#lv-start { width: 100%; }

@media (max-width: 860px) {
  .lv-body { flex-direction: column-reverse; }
  .lv-detail { flex: none; width: 100%; flex-direction: row; flex-wrap: wrap; }
  #lv-preview { width: 45%; }
  .lv-info { flex: 1; min-width: 160px; }
}
html.layout-compact .lv-btns { grid-template-columns: repeat(10, 1fr); gap: 2px; }
html.layout-compact .lv-btn { min-height: 40px; }
html.layout-compact .lv-btn .tags { display: none; }
html.layout-compact .screen-box.levels { padding: 8px; }

/* QR-Code zum Beitreten */
.join-qr {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 14px auto 0;
  max-width: 460px;
  padding: 10px;
  text-align: left;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.join-qr .qr-img {
  flex: 0 0 132px;
  width: 132px;
  height: 132px;
  padding: 4px;
  background: #fff;   /* QR-Codes brauchen hellen Grund zum Scannen */
  border-radius: 6px;
}
.join-qr .qr-img svg { display: block; width: 100%; height: 100%; }
.join-qr .qr-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.join-qr .qr-text b { color: var(--gold); }
.join-qr .qr-text span { font-size: 0.85em; color: var(--muted); }
.join-qr .qr-url { font-size: 0.85em; color: #b8d4ff; word-break: break-all; -webkit-user-select: text; user-select: text; }
.join-qr .qr-select {
  margin-top: 4px;
  padding: 4px;
  font: inherit;
  font-size: 0.85em;
  color: var(--text);
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid var(--border-hi);
  border-radius: 4px;
}
.join-qr .qr-wait, .join-qr .qr-err { font-size: 0.85em; color: var(--muted); }
.screen-box.qr-box { max-width: 560px; text-align: left; padding: 14px; }
.qr-box .join-qr { margin: 0; max-width: none; }
.qr-box .join-qr .qr-img { flex-basis: 220px; width: 220px; height: 220px; }
html.device-phone .desktop-only { display: none; }

/* ------------------------------------------------------------ Gerätespezifisch */
html.layout-compact .screen-box { padding: 12px; }
html.layout-compact .screen-box h1 { font-size: 1.8em; }
html.layout-compact .tagline { margin-bottom: 8px; }
html.layout-compact .class-cards { gap: 6px; margin: 10px 0; }
html.layout-compact .class-card { padding: 8px 6px; }
html.layout-compact .class-card .ico { font-size: 1.8em; }
html.layout-compact .class-card .desc { display: none; }
html.layout-compact .class-card ul { font-size: 0.75em; }
html.layout-compact .shop-item { min-height: 42px; padding: 4px 6px; gap: 6px; }
html.layout-compact .shop-item .ico { font-size: 1.3em; }
html.layout-compact .screen-box.shop { padding: 8px; }
html.layout-compact .shop-head { margin-bottom: 6px; }
html.layout-compact .panel { padding: 6px; margin-bottom: 6px; }
html.layout-compact #hud { padding: 0 4px; gap: 4px; }
html.layout-compact #hud .next { display: none; }
html.layout-compact .chip { padding: 2px 6px; }
html.layout-compact #btn-next { padding: 0 8px; font-size: 0.9em; }
html.layout-compact .build-btn .nm { display: none; }
html.layout-compact .ab-btn .nm { display: none; }
html.layout-compact .bar span { font-size: 9px; }

/* Handy hochkant: bitte drehen */
html.layout-rotate #rotate-hint {
  display: flex;
  position: fixed; inset: 0;
  z-index: 50;
  align-items: center; justify-content: center;
  text-align: center;
  font-size: 1.4em;
  color: var(--gold);
  background: #0f0d09;
}
html.layout-rotate #rotate-hint div { font-size: 1.2em; line-height: 1.8; }

/* Hochkant mit genug Breite (Tablets, schmale Fenster): Karte oben, Leiste darunter */
html.layout-stack #app { flex-direction: column; }
html.layout-stack #stage {
  flex: 0 0 auto;
  height: calc(min(100vw, 1000px) * 0.6667 + var(--hud-h) + 8px);
  max-height: calc(var(--app-h, 100vh) * 0.62);
}
html.layout-stack #side {
  flex: 1 1 auto;
  width: auto;
  min-height: 0;
  border-left: 0;
  border-top: 2px solid var(--border);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  align-content: start;
}
html.layout-stack #side .panel { margin: 0; }
html.layout-stack #panel-hero { grid-row: span 3; }

/* Schmales PC-Fenster */
@media (max-width: 600px) {
  .class-cards { grid-template-columns: 1fr; }
}

/* Schmale Fenster: Seitenleiste darf nicht seitlich überlaufen */
#side { overflow-x: hidden; }
.slot { min-height: 0; }
@media (max-width: 1000px) { #hud .next { display: none; } }

/* ------------------------------------------------------------ Gegen Kollegen */
.start-buttons { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.invite-banner {
  margin: 0 auto 12px;
  max-width: 560px;
  padding: 10px 12px;
  border: 1px solid var(--gold);
  border-radius: 8px;
  background: rgba(232, 192, 101, 0.12);
  color: #ffe9b0;
  font-weight: 600;
}
.chip.opp { color: #ffb4a6; border-color: #8a4030; }

.send-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.send-btn {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto auto;
  column-gap: 6px;
  align-items: center;
  padding: 5px 6px;
  min-height: var(--btn-h);
  font: inherit;
  text-align: left;
  color: var(--text);
  background: linear-gradient(#4a2a22, #2a1712);
  border: 1px solid #8a4030;
  border-radius: 6px;
  cursor: pointer;
}
.send-btn .ico { grid-row: span 3; font-size: 1.4em; }
.send-btn .nm { font-size: 0.78em; font-weight: 700; line-height: 1.1; padding-right: 12px; }
.send-btn .cost { font-size: 0.72em; color: #ffd65a; }
.send-btn .inc { font-size: 0.68em; color: #9fe39a; }
.send-btn .key { position: absolute; top: 2px; right: 2px; }
.send-btn:disabled { opacity: 0.45; cursor: default; }
.send-btn:hover:not(:disabled) { filter: brightness(1.2); }
.send-btn:last-child { grid-column: span 2; }
html.layout-compact .send-btn .nm { font-size: 0.7em; }

.screen-box.mp { max-width: 620px; text-align: center; }
.mp .lv-head { text-align: left; }
.mp-text { color: var(--muted); font-size: 0.92em; margin: 6px 0 14px; }
.mp-text b { color: var(--text); }
.mp-or { color: var(--muted); margin: 16px 0 8px; font-size: 0.9em; }
.mp-join { display: flex; gap: 8px; justify-content: center; }
#mp-code {
  width: 9em;
  padding: 8px 10px;
  font: inherit;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-align: center;
  text-transform: uppercase;
  color: var(--gold);
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid var(--border-hi);
  border-radius: 6px;
  -webkit-user-select: text;
  user-select: text;
}
.mp-code-label { color: var(--muted); font-size: 0.85em; }
.mp-code-big {
  font-family: Cinzel, Georgia, serif;
  font-size: 2.4em;
  font-weight: 800;
  letter-spacing: 0.2em;
  color: var(--gold);
  -webkit-user-select: text;
  user-select: text;
}
#mp-qr { margin: 10px auto; }
.mp-share-row { justify-content: center; }
.mp-share-row .btn { flex: 0 1 220px; }
.mp-h { font-family: Cinzel, Georgia, serif; color: var(--gold); margin: 16px 0 6px; }
.mp-players { list-style: none; padding: 0; margin: 0 0 14px; }
.mp-players li { padding: 6px; border-bottom: 1px solid rgba(255, 255, 255, 0.06); }
.mp-players li.waiting { color: var(--muted); font-style: italic; }
.mp-error { color: #ff9a8a; margin-top: 10px; min-height: 1em; font-weight: 600; }

/* ------------------------------------------------------------ Bestenlisten */
#btn-scores { margin-top: 10px; }
.over-rank { color: #b8d4ff; min-height: 1em; }
.lv-scores { font-size: 0.88em; }
.sc-title { color: var(--gold); font-weight: 700; margin-bottom: 4px; }
.sc-empty { color: var(--muted); font-style: italic; }
.sc-list { margin: 0; padding-left: 1.6em; }
.sc-list li { padding: 2px 0; }
.sc-list li > span { display: inline-flex; }
.sc-list .sc-name { min-width: 55%; }
.sc-list .sc-val { color: #ffd65a; font-weight: 700; }
.sc-list small { color: var(--muted); font-weight: normal; margin-left: 4px; }
.screen-box.scores-box { max-width: 620px; text-align: left; padding: 14px; }
.sc-table { width: 100%; border-collapse: collapse; font-size: 0.95em; }
.sc-table th { text-align: left; color: var(--muted); font-weight: 600; padding: 6px; border-bottom: 1px solid var(--border); }
.sc-table td { padding: 7px 6px; border-bottom: 1px solid rgba(255, 255, 255, 0.06); }
.sc-table td:nth-child(3) { color: #ffd65a; font-weight: 700; }
.sc-table tr.me td { background: rgba(232, 192, 101, 0.12); }

/* ------------------------------------------------------------ Updates */
.update-banner {
  position: fixed;
  left: 50%;
  bottom: max(12px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 8px 14px;
  background: #1f2a3a;
  border: 1px solid #5a8ad0;
  border-radius: 10px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.6);
  color: #d8e8ff;
  font-weight: 600;
  max-width: calc(100% - 24px);
}
.dev-panel {
  margin: 16px auto 0;
  max-width: 460px;
  padding: 10px 12px;
  text-align: left;
  border: 1px dashed #5a8ad0;
  border-radius: 8px;
  background: rgba(40, 60, 90, 0.25);
}
.dev-panel h3 { margin: 0 0 8px; color: #9fc4ff; font-size: 0.95em; }
.dev-panel label { display: block; font-size: 0.82em; color: var(--muted); margin-bottom: 6px; }
.dev-panel input {
  display: block;
  width: 100%;
  margin-top: 2px;
  padding: 7px 8px;
  font: inherit;
  font-size: 14px;
  color: var(--text);
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid var(--border-hi);
  border-radius: 5px;
  -webkit-user-select: text;
  user-select: text;
}
.dev-status { font-size: 0.85em; color: #cfe0ff; margin: 8px 0; min-height: 1em; }
#dev-publish { width: 100%; }

/* ------------------------------------------------------------ Geräte-Info */
.device-btn {
  display: block;
  margin: 8px auto 0;
  padding: 4px 10px;
  font: inherit;
  font-size: 0.82em;
  color: var(--muted);
  background: none;
  border: 1px dashed transparent;
  border-radius: 6px;
  cursor: pointer;
}
.device-btn:hover { border-color: var(--border); color: var(--text); }
.screen-box.device-box { max-width: 620px; text-align: left; padding: 14px; }
.device-table { width: 100%; border-collapse: collapse; font-size: 0.88em; margin-bottom: 6px; }
.device-table th { text-align: left; color: var(--muted); font-weight: 600; padding: 5px 8px 5px 0; white-space: nowrap; vertical-align: top; }
.device-table td { padding: 5px 0; word-break: break-word; }
.device-table tr + tr th, .device-table tr + tr td { border-top: 1px solid rgba(255, 255, 255, 0.06); }

html.layout-compact #hud-level { display: none; }

/* Copyright im Startmenü */
.copyright {
  margin-top: 16px;
  padding-top: 10px;
  border-top: 1px solid rgba(232, 192, 101, 0.18);
  font-size: 0.8em;
  color: var(--muted);
  letter-spacing: 0.03em;
}

.dev-ablage { margin: 6px 0 10px; font-size: 0.82em; color: #cfe0ff; }
.dev-ablage #dev-ablage-info { margin-bottom: 6px; word-break: break-all; }
.dev-ablage .btn { width: 100%; }
