/* ==========================================================================
   Pen & Paper Tisch – dunkles Spieltisch-Design
   Holzrahmen, grüner/dunkler Filz, klare deutsche UI.
   ========================================================================== */

:root {
  --bg: #12100d;
  --bg-panel: #1c1915;
  --bg-panel-2: #24201a;
  --bg-input: #14120f;
  --border: #3a3227;
  --border-light: #57493a;
  --text: #f2e9d8;
  --text-dim: #b8ab93;
  --accent: #c9a227;
  --accent-2: #e6c65a;
  --wood-dark: #2b1a10;
  --wood: #4a2f1c;
  --wood-light: #6b4529;
  --felt: #14532d;
  --felt-dark: #0d3b21;
  --felt-light: #1c6b41;
  --danger: #e63946;
  --danger-dark: #b32431;
  --success: #2a9d8f;
  --warning: #e9c46a;
  --info: #48cae4;
  --radius: 10px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  --header-height: 64px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background:
    radial-gradient(ellipse at top, #1b1712 0%, var(--bg) 60%) fixed,
    var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

h1,
h2,
h3 {
  margin: 0 0 0.5em;
  font-weight: 700;
}

p {
  margin: 0 0 0.75em;
}

.hidden {
  display: none !important;
}

/* --- Basis-Formularelemente ----------------------------------------------- */

label {
  display: block;
  margin-bottom: 6px;
  color: var(--text-dim);
  font-size: 0.9rem;
}

input[type="text"],
input[type="url"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-input);
  color: var(--text);
  font: inherit;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(201, 162, 39, 0.18);
}

input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

textarea {
  resize: vertical;
  min-height: 140px;
}

button {
  font: inherit;
  color: var(--text);
  cursor: pointer;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 14px;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  background: var(--bg-panel-2);
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
}

.btn:hover {
  border-color: var(--accent);
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  border-color: #8a6d14;
  color: #241a05;
  font-weight: 700;
}

.btn-primary:hover {
  filter: brightness(1.06);
}

.btn-danger {
  background: rgba(230, 57, 70, 0.16);
  border-color: var(--danger);
  color: #ffb3ba;
}

.btn-danger:hover {
  background: rgba(230, 57, 70, 0.28);
}

.btn-small {
  padding: 6px 10px;
  font-size: 0.85rem;
}

/* --- App-Grundgerüst -------------------------------------------------------- */

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

#app-main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* --- Header ----------------------------------------------------------------- */

#app-header {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  min-height: var(--header-height);
  padding: 10px 16px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(0, 0, 0, 0.25)),
    linear-gradient(145deg, var(--wood-light), var(--wood) 45%, var(--wood-dark));
  border-bottom: 3px solid var(--wood-light);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
  color: var(--text);
  z-index: 50;
}

.header-left,
.header-center,
.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-center {
  flex: 1;
  justify-content: center;
  min-width: 0;
}

#app-logo {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 0.4px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
  white-space: nowrap;
}

.mode-badge {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}

.mode-badge.play {
  background: rgba(42, 157, 143, 0.18);
  border: 1px solid var(--success);
  color: #8fe3d8;
}

.mode-badge.combat {
  background: rgba(230, 57, 70, 0.2);
  border: 1px solid var(--danger);
  color: #ff9aa2;
  animation: mode-pulse 1.4s ease-in-out infinite;
}

@keyframes mode-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(230, 57, 70, 0.55);
  }
  50% {
    box-shadow: 0 0 0 7px rgba(230, 57, 70, 0);
  }
}

.lobby-code-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px 5px 12px;
  border: 1px solid var(--border-light);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.3);
  white-space: nowrap;
}

.lobby-code-label {
  color: var(--text-dim);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

#lobby-code {
  font-size: 1rem;
  letter-spacing: 1px;
}

#header .lobby-code-badge button,
.lobby-code-badge button {
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border-light);
  background: var(--bg-panel-2);
  font-size: 0.78rem;
}

.header-right {
  margin-left: auto;
  flex-wrap: wrap;
}

.connection-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.conn-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #777;
  flex: 0 0 auto;
}

.conn-dot.online {
  background: var(--success);
  box-shadow: 0 0 7px var(--success);
}

.conn-dot.offline {
  background: var(--danger);
  box-shadow: 0 0 7px var(--danger);
}

.conn-dot.mock {
  background: var(--warning);
  box-shadow: 0 0 7px var(--warning);
}

.current-player {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 600;
}

.player-color-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #888;
  border: 2px solid rgba(255, 255, 255, 0.35);
}

#btn-unlock-audio,
#btn-new-tab-player {
  padding: 7px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-light);
  background: var(--bg-panel-2);
  font-size: 0.85rem;
  white-space: nowrap;
}

#btn-new-tab-player {
  border-color: var(--warning);
  color: var(--warning);
}

/* Musik läuft, aber der Browser blockiert die Wiedergabe: auffälliger Rahmen. */
#btn-unlock-audio.highlight {
  border-color: var(--accent-2);
  color: #ffd9dd;
  animation: unlock-pulse 1.4s ease-in-out infinite;
}

@keyframes unlock-pulse {
  0%,
  100% {
    border-color: var(--accent-2);
    box-shadow: 0 0 0 0 rgba(230, 57, 70, 0.55);
  }
  50% {
    border-color: var(--danger);
    box-shadow: 0 0 14px 3px rgba(230, 57, 70, 0.35);
  }
}

#btn-unlock-audio.unlocked {
  border-color: var(--success);
  color: #8fe3d8;
}

/* --- Start-Ansicht ---------------------------------------------------------- */

#view-home {
  overflow-y: auto;
  padding: 28px 18px 90px;
}

.home-hero {
  max-width: 900px;
  margin: 0 auto 22px;
  text-align: center;
}

.home-hero h1 {
  font-size: 2rem;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}

.home-hero p {
  color: var(--text-dim);
  max-width: 640px;
  margin-left: auto;
  margin-right: auto;
}

.name-row {
  max-width: 900px;
  margin: 0 auto 20px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}

.name-row label {
  font-weight: 700;
  color: var(--text);
}

.home-cards {
  max-width: 1000px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(310px, 1fr));
  gap: 20px;
}

.card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.card h2 {
  font-size: 1.2rem;
}

.card > label,
.card .field {
  margin-top: 14px;
}

.card .btn {
  width: 100%;
  margin-top: 16px;
}

.field-label {
  display: block;
  margin-bottom: 8px;
  color: var(--text-dim);
  font-size: 0.88rem;
  font-weight: 600;
}

.role-switch {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.role-switch label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-panel-2);
  color: var(--text);
  cursor: pointer;
}

.role-switch label.disabled {
  opacity: 0.45;
  cursor: not-allowed;
  text-decoration: line-through;
}

.hint {
  margin: 8px 0 0;
  color: var(--text-dim);
  font-size: 0.82rem;
}

.join-card {
  max-width: 640px;
  margin: 20px auto 0;
  border-color: var(--accent);
}

.join-info {
  color: var(--text-dim);
}

.join-code {
  margin-left: 10px;
  font-size: 0.85rem;
}

/* --- Farbauswahl ------------------------------------------------------------ */

.color-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.color-swatch {
  position: relative;
  height: 36px;
  padding: 0;
  border: 2px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: var(--swatch, #888);
  cursor: pointer;
  transition: transform 0.1s ease, border-color 0.1s ease, box-shadow 0.1s ease;
}

.color-swatch:hover:not(:disabled) {
  transform: translateY(-1px);
}

.color-swatch.selected {
  border-color: #fff;
  box-shadow: 0 0 0 2px var(--accent);
}

.color-swatch.disabled {
  cursor: not-allowed;
  opacity: 0.3;
}

.color-swatch.disabled::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 130%;
  height: 2px;
  background: var(--danger);
  transform: translate(-50%, -50%) rotate(-22deg);
}

/* --- Lobby-Hauptansicht ----------------------------------------------------- */

#view-lobby {
  overflow: hidden;
}

.combat-bar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding: 8px 14px;
  background: linear-gradient(90deg, rgba(230, 57, 70, 0.3), rgba(230, 57, 70, 0.08));
  border-bottom: 2px solid var(--danger);
}

.combat-info {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  min-width: 0;
}

#combat-title {
  font-weight: 700;
  color: #ffb3ba;
  white-space: nowrap;
}

.combat-order-list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.combat-order-item {
  padding: 4px 10px;
  border: 1px solid var(--border-light);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
  font-size: 0.82rem;
  white-space: nowrap;
}

.combat-order-item.active {
  border-color: var(--accent);
  color: var(--accent-2);
  box-shadow: 0 0 8px rgba(201, 162, 39, 0.35);
}

.combat-order-item .combat-rank {
  color: var(--text-dim);
}

.combat-order-arrow {
  min-width: 22px;
  width: 22px;
  height: 22px;
  padding: 0;
  margin-left: 4px;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  background: var(--bg-panel-2, #2a2620);
  color: var(--text);
  font-size: 0.72rem;
  line-height: 1;
  cursor: pointer;
}

.combat-order-arrow:hover {
  border-color: var(--accent);
}

.combat-active-badge {
  margin-left: 4px;
  padding: 2px 6px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: rgba(201, 162, 39, 0.22);
  color: var(--accent-2);
  font-size: 0.72rem;
  font-weight: 700;
}

.combat-kept-hint {
  flex: 1 1 100%;
  padding: 2px 4px;
  color: var(--warning);
  font-size: 0.8rem;
}

.combat-controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.lobby-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr) 350px;
  gap: 14px;
  padding: 14px;
}

.side-panel {
  min-height: 0;
  overflow-y: auto;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}

.panel-header {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  background: linear-gradient(180deg, var(--bg-panel-2), var(--bg-panel));
  border-bottom: 1px solid var(--border);
}

.panel-header h2 {
  margin: 0;
  font-size: 1.05rem;
}

.sheet-close {
  display: none;
  padding: 2px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  font-size: 1.1rem;
  line-height: 1.2;
}

.panel-subheader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.panel-subheader h3 {
  margin: 0;
  font-size: 0.95rem;
}

/* --- Würfel-Panel ----------------------------------------------------------- */

.dice-container {
  padding: 14px;
  border-bottom: 1px solid var(--border);
}

.dice-toggles {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.dice-toggle {
  padding: 10px 4px;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  background: var(--bg-panel-2);
  font-weight: 700;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.dice-toggle:hover {
  border-color: var(--accent);
}

.dice-toggle.active {
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  border-color: #8a6d14;
  color: #241a05;
}

.secret-switch {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 12px 0;
  color: var(--text-dim);
  font-size: 0.85rem;
}

.switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch .slider {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  transition: background 0.15s ease;
}

.switch .slider::before {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  left: 2px;
  top: 2px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: transform 0.15s ease, background 0.15s ease;
}

.switch input:checked + .slider {
  background: rgba(230, 57, 70, 0.35);
  border-color: var(--danger);
}

.switch input:checked + .slider::before {
  transform: translateX(22px);
  background: #fff;
}

#btn-roll {
  width: 100%;
  margin-top: 4px;
}

.dice-stage {
  min-height: 74px;
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px;
  border: 1px dashed var(--border-light);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.25);
}

.dice-stage:empty::before {
  content: "Hier erscheint das Würfelergebnis";
  color: var(--text-dim);
  font-size: 0.82rem;
}

.dice-result {
  min-width: 52px;
  height: 52px;
  padding: 0 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: linear-gradient(180deg, #f7f2e7, #ddd3bf);
  color: #221d16;
  font-size: 1.05rem;
  font-weight: 800;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.45);
  animation: dice-pop 0.35s ease;
}

.dice-result.d100 {
  font-size: 0.9rem;
}

.dice-stage.rolling .dice-result {
  animation: dice-shake 0.12s linear infinite;
}

@keyframes dice-pop {
  0% {
    transform: scale(0.4) rotate(-24deg);
    opacity: 0;
  }
  100% {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
}

@keyframes dice-shake {
  0% {
    transform: translateY(-2px) rotate(-6deg);
  }
  50% {
    transform: translateY(2px) rotate(5deg);
  }
  100% {
    transform: translateY(-2px) rotate(-4deg);
  }
}

.dice-sum {
  width: 100%;
  text-align: center;
  color: var(--accent-2);
  font-weight: 700;
}

/* --- Würfelverlauf ---------------------------------------------------------- */

.clipboard-container {
  padding: 14px;
  flex: 1;
  min-height: 120px;
}

.clipboard-actions {
  display: flex;
  gap: 6px;
}

.clipboard-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.clipboard-entry {
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--entry-color, var(--border-light));
  border-radius: 8px;
  background: var(--bg-panel-2);
  font-size: 0.85rem;
}

.clipboard-entry .clipboard-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 3px;
}

.clipboard-entry .clipboard-player {
  font-weight: 700;
}

.clipboard-entry .clipboard-time {
  color: var(--text-dim);
  font-size: 0.75rem;
  white-space: nowrap;
}

.clipboard-entry .clipboard-values {
  color: var(--text);
}

.clipboard-entry .clipboard-label {
  display: block;
  margin-top: 3px;
  color: var(--text-dim);
  font-style: italic;
}

.clipboard-entry.secret {
  color: var(--text-dim);
  font-style: italic;
}

/* --- Spieltisch ------------------------------------------------------------- */

#table-center {
  min-width: 0;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  align-content: center;
  padding: 10px;
  overflow: auto;
}

.game-table {
  width: 100%;
  max-width: 920px;
  aspect-ratio: 16 / 10;
  min-height: 320px;
}

.table-wood {
  width: 100%;
  height: 100%;
  padding: 20px;
  border-radius: 30px;
  background:
    linear-gradient(145deg, var(--wood-light) 0%, var(--wood) 45%, var(--wood-dark) 100%);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.12),
    inset 0 -3px 8px rgba(0, 0, 0, 0.5),
    0 14px 34px rgba(0, 0, 0, 0.6);
}

.table-felt {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 20px;
  border: 2px solid rgba(0, 0, 0, 0.45);
  overflow: hidden;
  background:
    radial-gradient(ellipse at center, var(--felt-light) 0%, var(--felt) 48%, var(--felt-dark) 100%);
  box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.55);
}

.seat {
  position: absolute;
  transform: translate(-50%, -50%);
  min-width: 104px;
  max-width: 160px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.42);
  border: 2px solid var(--seat-color, #888);
  color: #fff;
  text-align: center;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}

.seat .seat-name {
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.seat .seat-hp {
  margin-top: 2px;
  font-size: 0.82rem;
  color: #ffd9dc;
}

.seat .seat-online {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-left: 5px;
  border-radius: 50%;
  background: #666;
  vertical-align: middle;
}

.seat .seat-online.online {
  background: var(--success);
  box-shadow: 0 0 5px var(--success);
}

.seat-gm {
  top: 11%;
  left: 50%;
  border-color: var(--accent);
  background: rgba(60, 44, 8, 0.5);
}

.seat-gm .seat-name {
  color: var(--accent-2);
}

.seat.player-seat {
  /* Positionen werden von table.js gesetzt */
  pointer-events: auto;
}

.seat-head {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  flex-wrap: wrap;
}

.seat-avatar {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--seat-color, #888);
  border: 1px solid rgba(255, 255, 255, 0.4);
}

.seat-self-badge {
  color: var(--accent-2);
  font-size: 0.72rem;
  font-weight: 700;
}

.seat-turn-badge {
  margin-top: 4px;
  padding: 2px 6px;
  border: 1px solid var(--danger);
  border-radius: 999px;
  background: rgba(230, 57, 70, 0.25);
  color: #ffb3ba;
  font-size: 0.72rem;
  font-weight: 700;
}

.seat.active-turn {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 2px var(--accent), 0 0 14px rgba(201, 162, 39, 0.55);
}

.seat-hp .hp-bar {
  height: 7px;
  margin-top: 5px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

.hp-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--success);
  transition: width 0.2s ease, background-color 0.2s ease;
}

.hp-text {
  margin-top: 2px;
  font-size: 0.78rem;
}

.seat-gm-controls {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  pointer-events: auto;
}

.hp-btn-row,
.hp-inputs {
  display: flex;
  gap: 4px;
  justify-content: center;
  align-items: center;
}

.hp-btn {
  min-width: 34px;
  padding: 2px 6px;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  background: var(--bg-panel-2);
  color: var(--text);
  font-size: 0.78rem;
  line-height: 1.2;
}

.hp-btn:hover {
  border-color: var(--accent);
}

.hp-inputs input[type="number"] {
  width: 48px;
  padding: 2px 4px;
  font-size: 0.78rem;
  text-align: center;
}

.gm-badge {
  display: inline-block;
  margin-bottom: 2px;
  padding: 1px 8px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: rgba(201, 162, 39, 0.2);
  color: var(--accent-2);
  font-size: 0.72rem;
  font-weight: 700;
}

.seat-gm.vacant {
  border-color: var(--border-light);
  background: rgba(0, 0, 0, 0.25);
  opacity: 0.55;
}

.seat-gm.vacant .seat-name {
  color: var(--text-dim);
}

.seat-gm.vacant .seat-online {
  display: none;
}

.enemy-token {
  position: absolute;
  transform: translate(-50%, -50%);
  min-width: 110px;
  max-width: 170px;
  padding: 7px 10px;
  border-radius: 12px;
  background: rgba(45, 14, 18, 0.88);
  border: 2px solid var(--enemy-color, var(--danger));
  color: #fff;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 700;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}

.enemy-token .enemy-hp {
  display: block;
  font-size: 0.72rem;
  color: #ffc2c7;
}

.enemy-token.active-turn {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 2px var(--accent), 0 0 14px rgba(201, 162, 39, 0.55);
}

.enemy-turn-badge {
  margin-top: 4px;
  padding: 2px 6px;
  border: 1px solid var(--danger);
  border-radius: 999px;
  background: rgba(230, 57, 70, 0.25);
  color: #ffb3ba;
  font-size: 0.72rem;
  font-weight: 700;
}

.enemy-token-controls {
  display: flex;
  gap: 4px;
  justify-content: center;
  align-items: center;
  margin-top: 5px;
}

.enemy-hp-input {
  width: 44px;
  padding: 2px 4px;
  font-size: 0.75rem;
  text-align: center;
}

/* --- Lobby-Steuerleiste ----------------------------------------------------- */

.lobby-bar {
  width: 100%;
  max-width: 920px;
  margin-top: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  background: rgba(12, 10, 8, 0.82);
  box-shadow: var(--shadow);
}

.lobby-bar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.lobby-bar-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
}

.lobby-bar-name {
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
  color: var(--accent-2);
}

.lobby-bar-role {
  padding: 3px 9px;
  border: 1px solid var(--border-light);
  border-radius: 999px;
  background: var(--bg-panel-2);
  color: var(--text-dim);
  font-size: 0.78rem;
  white-space: nowrap;
}

.lobby-bar-role.gm {
  border-color: var(--accent);
  color: var(--accent-2);
}

.lobby-bar-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.lobby-bar-players {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.lobby-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  border: 1px solid var(--chip-color, var(--border-light));
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.3);
  font-size: 0.82rem;
  white-space: nowrap;
}

.lobby-chip-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #666;
  flex: 0 0 auto;
}

.lobby-chip-dot.online {
  background: var(--success);
  box-shadow: 0 0 6px var(--success);
}

.lobby-chip-color {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--chip-color, #888);
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.lobby-chip-name {
  font-weight: 600;
}

.lobby-chip-role {
  color: var(--text-dim);
  font-size: 0.75rem;
}

.lobby-chip-kick {
  padding: 0 1px;
  border: none;
  background: transparent;
  color: var(--danger);
  font-size: 1.05rem;
  line-height: 1;
}

.lobby-chip-kick:hover {
  color: #ff9aa2;
}

.lobby-color-popover {
  padding: 10px;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  background: var(--bg-panel-2);
}

.lobby-color-popover .color-grid {
  grid-template-columns: repeat(10, 1fr);
  max-width: 480px;
}

.lobby-color-popover .color-swatch {
  height: 28px;
}

/* --- Notizheft -------------------------------------------------------------- */

.notebook-container {
  padding: 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.notebook-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.notebook-toolbar label {
  margin: 0;
  font-size: 0.82rem;
}

.notebook-toolbar select {
  flex: 1;
  min-width: 140px;
}

.notebook-tabs-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.notebook-tabs {
  flex: 1;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.notebook-tab {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px 8px 0 0;
  background: var(--bg-panel-2);
  white-space: nowrap;
  font-size: 0.82rem;
}

.notebook-tab.active {
  border-color: var(--accent);
  color: var(--accent-2);
  background: rgba(201, 162, 39, 0.12);
}

.notebook-page-toolbar {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.notebook-page-toolbar input {
  flex: 1;
  min-width: 120px;
}

#notebook-text {
  flex: 1;
  min-height: 200px;
  resize: vertical;
}

.notebook-saved {
  min-height: 18px;
  color: var(--success);
  font-size: 0.78rem;
  text-align: right;
  opacity: 0.75;
}

.notebook-saved.dirty {
  color: var(--warning);
}

/* --- Musik ------------------------------------------------------------------ */

.music-container {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.music-status {
  display: flex;
  flex-direction: column;
  gap: 2px;
  color: var(--text-dim);
  font-size: 0.85rem;
}

#music-title {
  color: var(--text);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.music-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.music-controls label {
  margin: 0;
  white-space: nowrap;
}

.music-controls input[type="range"] {
  flex: 1;
  accent-color: var(--accent);
}

.music-gm-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.music-buttons {
  display: flex;
  gap: 8px;
}

.music-buttons .btn {
  flex: 1;
}

#yt-hidden-player {
  position: fixed;
  left: -20px;
  top: -20px;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
}

/* --- Mobile Navigation ------------------------------------------------------ */

.mobile-nav {
  display: none;
}

/* --- Toasts ----------------------------------------------------------------- */

.toast-container {
  position: fixed;
  left: 50%;
  bottom: 78px;
  transform: translateX(-50%);
  z-index: 120;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: min(480px, calc(100vw - 32px));
  pointer-events: none;
}

.toast {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border-light);
  border-left: 5px solid var(--info);
  border-radius: 8px;
  background: rgba(20, 18, 15, 0.96);
  color: var(--text);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: auto;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast-success {
  border-left-color: var(--success);
}

.toast-error {
  border-left-color: var(--danger);
}

.toast-warning {
  border-left-color: var(--warning);
}

.toast-info {
  border-left-color: var(--info);
}

/* --- Modal ------------------------------------------------------------------ */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 130;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(2px);
}

.modal-overlay[hidden] {
  display: none;
}

.modal-box {
  width: min(460px, 100%);
  padding: 20px;
  border: 1px solid var(--border-light);
  border-radius: 12px;
  background: var(--bg-panel);
  box-shadow: var(--shadow);
}

.modal-box h3 {
  margin-bottom: 8px;
}

.modal-box p {
  color: var(--text-dim);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
  flex-wrap: wrap;
}

/* --- Lade-Anzeige ----------------------------------------------------------- */

.app-loading {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  color: var(--text-dim);
}

.app-loading.hidden {
  display: none;
}

.loading-inner {
  text-align: center;
}

.loading-dice {
  font-size: 2.4rem;
  margin-bottom: 10px;
  animation: dice-shake 0.9s linear infinite;
}

/* --- Responsive: Mobile Bottom-Sheets -------------------------------------- */

@media (max-width: 960px) {
  body {
    font-size: 14px;
  }

  #app-header {
    gap: 8px;
    padding: 8px 10px;
  }

  #app-logo {
    font-size: 0.98rem;
  }

  .header-center {
    order: 3;
    flex-basis: 100%;
    justify-content: flex-start;
  }

  .lobby-grid {
    grid-template-columns: 1fr;
    padding: 8px;
    gap: 8px;
  }

  .side-panel {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 58px;
    top: auto;
    height: min(72vh, 560px);
    z-index: 90;
    border-radius: 16px 16px 0 0;
    border: 1px solid var(--border-light);
    transform: translateY(110%);
    transition: transform 0.25s ease;
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.55);
  }

  .side-panel.open {
    transform: translateY(0);
  }

  .sheet-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  #view-lobby[data-mobile-section="notebook"] #music-container {
    display: none;
  }

  #view-lobby[data-mobile-section="music"] #notebook-container {
    display: none;
  }

  #table-center {
    padding: 6px;
  }

  .game-table {
    min-height: 260px;
  }

  .mobile-nav {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 100;
    background: var(--bg-panel);
    border-top: 1px solid var(--border-light);
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.5);
  }

  .mobile-nav button {
    flex: 1;
    padding: 12px 4px;
    border: none;
    border-top: 2px solid transparent;
    background: transparent;
    color: var(--text-dim);
    font-size: 0.8rem;
  }

  .mobile-nav button.active {
    border-top-color: var(--accent);
    color: var(--accent-2);
  }

  .toast-container {
    bottom: 68px;
  }

  .color-grid {
    grid-template-columns: repeat(5, 1fr);
  }

  .home-hero h1 {
    font-size: 1.5rem;
  }
}

/* --- Responsive: sehr kleine Bildschirme ----------------------------------- */

@media (max-width: 480px) {
  .dice-toggles {
    grid-template-columns: repeat(2, 1fr);
  }

  .combat-controls,
  .clipboard-actions,
  .music-buttons {
    width: 100%;
  }

  .combat-controls .btn,
  .clipboard-actions .btn,
  .music-buttons .btn {
    flex: 1;
  }

  .modal-actions {
    flex-direction: column-reverse;
  }

  .modal-actions .btn {
    width: 100%;
  }
}

/* --- Reduzierte Bewegung ---------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
