/* ==========================================================================
   3D Schach - Gestaltung
   Dunkles Holz, Messing und warmes Licht. Alles ohne fremde Schriftarten
   oder Bilder, damit die Seite auch bei langsamer Leitung sofort steht.
   ========================================================================== */

:root {
  --bg:          #14100d;
  --bg-2:        #1c1713;
  --panel:       #221c17;
  --panel-2:     #2a2219;
  --line:        #3a2f24;
  --line-soft:   #2f271e;

  --text:        #ece2d4;
  --text-dim:    #a99881;
  --text-faint:  #7a6c5a;

  --accent:      #c8a06a;
  --accent-warm: #e0b878;
  --accent-deep: #8a6636;

  --green:       #7bbf6a;
  --red:         #d15b4c;
  --blue:        #6f9fd8;
  --amber:       #e0a33e;

  --radius:      14px;
  --radius-sm:   9px;
  --shadow:      0 18px 48px rgba(0, 0, 0, .55);
  --shadow-sm:   0 4px 14px rgba(0, 0, 0, .35);

  --serif: Georgia, "Times New Roman", "Iowan Old Style", serif;
  --sans:  system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono:  ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;

  --header-h: 62px;
}

* { box-sizing: border-box; }

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

body {
  background:
    radial-gradient(1200px 700px at 15% -10%, #2a2018 0%, transparent 60%),
    radial-gradient(900px 600px at 100% 0%, #241c14 0%, transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3, h4 {
  font-family: var(--serif);
  font-weight: 600;
  letter-spacing: .01em;
  margin: 0 0 .5em;
  line-height: 1.2;
}
h1 { font-size: 2rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.1rem; }

a { color: var(--accent-warm); text-decoration: none; }
a:hover { text-decoration: underline; }

.muted  { color: var(--text-dim); }
.faint  { color: var(--text-faint); font-size: .86rem; }
.mono   { font-family: var(--mono); }
.center { text-align: center; }
.nowrap { white-space: nowrap; }

/* --------------------------------------------------------------------------
   Kopfzeile
   -------------------------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 18px;
  background: rgba(20, 16, 13, .88);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line-soft);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--serif);
  font-size: 1.16rem;
  color: var(--text);
  letter-spacing: .02em;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: 8px;
  background: linear-gradient(150deg, var(--accent-warm), var(--accent-deep));
  color: #201810;
  font-size: 19px;
  line-height: 1;
  box-shadow: 0 2px 10px rgba(200, 160, 106, .3);
}

.topbar nav {
  display: flex;
  gap: 4px;
  margin-left: auto;
  align-items: center;
}
.topbar nav a {
  padding: 7px 13px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: .92rem;
}
.topbar nav a:hover { background: var(--panel); color: var(--text); text-decoration: none; }
.topbar nav a.active { background: var(--panel-2); color: var(--accent-warm); }

.user-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 5px 12px 5px 5px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--line-soft);
  font-size: .9rem;
}
.avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: linear-gradient(150deg, var(--accent-warm), var(--accent-deep));
  color: #1d1610;
  font-weight: 700;
  font-size: .82rem;
}

/* --------------------------------------------------------------------------
   Grundgeruest
   -------------------------------------------------------------------------- */

.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 26px 18px 60px;
}
.wrap-wide { max-width: 1500px; }

.panel {
  background: linear-gradient(180deg, var(--panel) 0%, var(--bg-2) 100%);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.panel-pad { padding: 20px; }

.panel-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line-soft);
}
.panel-head h2, .panel-head h3 { margin: 0; }
.panel-head .spacer { margin-left: auto; }

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.row { display: flex; gap: 10px; align-items: center; }
.row-wrap { flex-wrap: wrap; }
.spread { justify-content: space-between; }

/* --------------------------------------------------------------------------
   Formulare
   -------------------------------------------------------------------------- */

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

input[type=text], input[type=password], input[type=email], input[type=number],
select, textarea {
  width: 100%;
  padding: 11px 13px;
  background: #17120e;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: .95rem;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent-deep);
  box-shadow: 0 0 0 3px rgba(200, 160, 106, .14);
}
input::placeholder, textarea::placeholder { color: var(--text-faint); }

select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-dim) 50%),
                    linear-gradient(135deg, var(--text-dim) 50%, transparent 50%);
  background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 34px;
}

.field { margin-bottom: 15px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  color: var(--text);
  font-family: inherit;
  font-size: .93rem;
  font-weight: 500;
  cursor: pointer;
  transition: transform .12s, background .15s, border-color .15s, opacity .15s;
  user-select: none;
  white-space: nowrap;
}
.btn:hover { background: #332a1f; border-color: var(--accent-deep); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[disabled] { opacity: .42; cursor: not-allowed; transform: none; }

.btn-primary {
  background: linear-gradient(160deg, var(--accent-warm), var(--accent-deep));
  border-color: var(--accent-deep);
  color: #1d1509;
  font-weight: 700;
}
.btn-primary:hover { background: linear-gradient(160deg, #eec98c, #9a743e); }

.btn-danger { border-color: #5e2f28; color: #eaa79c; }
.btn-danger:hover { background: #3a221d; border-color: var(--red); }

.btn-ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn-ghost:hover { background: var(--panel); color: var(--text); }

.btn-sm { padding: 6px 12px; font-size: .85rem; }
.btn-block { width: 100%; }
.btn-icon { padding: 9px 11px; }

.btn-group { display: inline-flex; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--line); }
.btn-group .btn { border: none; border-radius: 0; background: var(--panel); }
.btn-group .btn + .btn { border-left: 1px solid var(--line); }
.btn-group .btn.on { background: var(--accent-deep); color: #1d1509; font-weight: 700; }

/* Auswahlkarten (Farbe, Gegner, Stufe) */
.choices { display: flex; gap: 8px; flex-wrap: wrap; }
.choice {
  flex: 1 1 90px;
  padding: 11px 8px;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #17120e;
  cursor: pointer;
  font-size: .88rem;
  transition: all .15s;
}
.choice:hover { border-color: var(--accent-deep); }
.choice.on {
  border-color: var(--accent);
  background: linear-gradient(180deg, rgba(200,160,106,.18), rgba(200,160,106,.06));
  color: var(--accent-warm);
  font-weight: 600;
}
.choice small { display: block; color: var(--text-faint); font-size: .75rem; margin-top: 2px; }
.choice.on small { color: var(--text-dim); }

/* --------------------------------------------------------------------------
   Hinweise
   -------------------------------------------------------------------------- */

.alert {
  padding: 11px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--panel);
  font-size: .9rem;
  margin: 0 0 14px;
}
.alert-error { border-color: #5e2f28; background: #2b1a17; color: #f0b3a8; }
.alert-ok    { border-color: #2f5228; background: #1a2617; color: #b9e2ac; }
.alert-warn  { border-color: #5e4a1e; background: #2b2415; color: #ecd39a; }
.alert-info  { border-color: #2b4358; background: #16222b; color: #b0d3ea; }

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: .74rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  border: 1px solid var(--line);
  color: var(--text-dim);
}
.badge-live   { border-color: #2f5228; background: #16250f; color: #9fd88c; }
.badge-wait   { border-color: #5e4a1e; background: #2b2415; color: #e5c479; }
.badge-done   { border-color: var(--line); background: var(--panel); color: var(--text-faint); }
.badge-admin  { border-color: var(--accent-deep); background: rgba(200,160,106,.14); color: var(--accent-warm); }

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--text-faint); }
.dot.on { background: var(--green); box-shadow: 0 0 8px rgba(123,191,106,.7); }

/* --------------------------------------------------------------------------
   Anmeldung
   -------------------------------------------------------------------------- */

.page-plain { display: grid; place-items: center; min-height: 100vh; padding: 24px; }

.auth-card, .setup-card {
  width: 100%;
  max-width: 430px;
  background: linear-gradient(180deg, var(--panel) 0%, var(--bg-2) 100%);
  border: 1px solid var(--line-soft);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 34px 30px;
}
.setup-card { max-width: 620px; }
.setup-log { font-family: var(--mono); font-size: .84rem; color: var(--text-dim); padding-left: 18px; }
.setup-log li { margin: 3px 0; }

.auth-logo {
  width: 60px; height: 60px;
  margin: 0 auto 16px;
  border-radius: 16px;
  display: grid; place-items: center;
  font-size: 34px;
  background: linear-gradient(150deg, var(--accent-warm), var(--accent-deep));
  color: #1d1509;
  box-shadow: 0 8px 24px rgba(200,160,106,.28);
}

.tabs { display: flex; gap: 4px; margin-bottom: 22px; background: #17120e; padding: 4px; border-radius: 11px; }
.tabs button {
  flex: 1;
  padding: 9px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-dim);
  font-family: inherit;
  font-size: .92rem;
  cursor: pointer;
  transition: all .15s;
}
.tabs button.on { background: var(--panel-2); color: var(--text); box-shadow: var(--shadow-sm); }

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

.hero {
  position: relative;
  padding: 30px 28px;
  border-radius: var(--radius);
  background:
    radial-gradient(700px 300px at 88% 0%, rgba(224,163,62,.16), transparent 65%),
    linear-gradient(160deg, #2a2118, #1a1410);
  border: 1px solid var(--line-soft);
  overflow: hidden;
  margin-bottom: 22px;
}
.hero h1 { margin-bottom: 6px; }
.hero p { color: var(--text-dim); margin: 0 0 18px; max-width: 56ch; }

.stat-row { display: flex; gap: 26px; flex-wrap: wrap; }
.stat { min-width: 74px; }
.stat b { display: block; font-family: var(--serif); font-size: 1.65rem; color: var(--accent-warm); line-height: 1.1; }
.stat span { font-size: .78rem; color: var(--text-faint); text-transform: uppercase; letter-spacing: .07em; }

.game-list { display: flex; flex-direction: column; gap: 1px; background: var(--line-soft); border-radius: var(--radius); overflow: hidden; }
.game-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  background: var(--panel);
  transition: background .15s;
}
.game-item:hover { background: var(--panel-2); }
.game-item .who { flex: 1; min-width: 0; }
.game-item .who b { display: block; font-weight: 600; }
.game-item .who span { font-size: .82rem; color: var(--text-faint); }

.empty {
  padding: 44px 20px;
  text-align: center;
  color: var(--text-faint);
  background: var(--panel);
  border-radius: var(--radius);
  border: 1px dashed var(--line);
}
.empty-icon { font-size: 34px; opacity: .5; display: block; margin-bottom: 8px; }

table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data th {
  text-align: left;
  padding: 10px 12px;
  color: var(--text-faint);
  font-size: .74rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  border-bottom: 1px solid var(--line-soft);
  font-weight: 600;
}
table.data td { padding: 11px 12px; border-bottom: 1px solid var(--line-soft); }
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: rgba(255,255,255,.02); }

/* --------------------------------------------------------------------------
   Spielseite
   -------------------------------------------------------------------------- */

.game-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 0;
  height: calc(100vh - var(--header-h));
}

.board-area { position: relative; background: #0b0806; overflow: hidden; }
.board3d-canvas { display: block; width: 100%; height: 100%; touch-action: none; }

.board-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 14px;
}
.board-overlay > * { pointer-events: auto; }

.player-strip {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(20,16,13,.82);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line-soft);
  align-self: flex-start;
  max-width: 100%;
}
.player-strip.turn { border-color: var(--accent); box-shadow: 0 0 0 1px rgba(200,160,106,.28), 0 0 22px rgba(200,160,106,.18); }
.player-strip .name { font-weight: 600; font-size: .93rem; }
.player-strip .clock {
  font-family: var(--mono);
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
  padding: 2px 9px;
  border-radius: 7px;
  background: #17120e;
}
.player-strip .clock.low { color: #f0a396; background: #2e1a16; }
.player-strip .taken { font-size: 1rem; letter-spacing: -2px; color: var(--text-dim); }

/* Werkzeugleiste am rechten Rand.
   Frueher stand sie mittig ueber dem Brett und verdeckte die Figuren. */
.board-toolbar {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 5px;
  border-radius: 14px;
  background: rgba(20, 16, 13, .8);
  backdrop-filter: blur(12px);
  border: 1px solid var(--line-soft);
  box-shadow: var(--shadow-sm);
  z-index: 6;
}

.werkzeug-liste {
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow: hidden;
  max-height: 60vh;
  /* Ohne min-height: 0 schrumpft ein Flex-Element nie unter seinen Inhalt -
     das Einklappen bliebe wirkungslos. */
  min-height: 0;
  flex-shrink: 1;
  transition: max-height .25s ease, opacity .2s ease;
}
.board-toolbar.zu .werkzeug-liste {
  max-height: 0;
  opacity: 0;
  pointer-events: none;
}

.board-toolbar .btn {
  flex-direction: column;
  gap: 2px;
  width: 62px;
  min-height: 50px;
  padding: 7px 3px;
  font-size: .67rem;
  font-weight: 500;
  line-height: 1.15;
  background: transparent;
  border-color: transparent;
  white-space: normal;
}
.board-toolbar .btn:hover {
  background: var(--panel-2);
  border-color: var(--line);
}
.board-toolbar .btn .icon {
  font-size: 1.16rem;
  line-height: 1;
}
.board-toolbar .btn-danger { color: #e0a094; }
.board-toolbar .btn-danger:hover { background: #3a221d; border-color: var(--red); }

/* Der Einklapp-Knopf bleibt immer sichtbar */
.werkzeug-schalter {
  min-height: 38px !important;
  border-bottom: 1px solid var(--line-soft) !important;
  border-radius: 9px 9px 0 0 !important;
  margin-bottom: 2px;
  opacity: .75;
}
.werkzeug-schalter:hover { opacity: 1; }
.board-toolbar.zu .werkzeug-schalter {
  border-bottom-color: transparent !important;
  border-radius: 9px !important;
  margin-bottom: 0;
}

.board-toast {
  position: absolute;
  left: 50%;
  top: 18%;
  transform: translateX(-50%);
  padding: 13px 24px;
  border-radius: 12px;
  background: rgba(20,16,13,.94);
  border: 1px solid var(--accent-deep);
  font-family: var(--serif);
  font-size: 1.15rem;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: opacity .3s, transform .3s;
  pointer-events: none;
  text-align: center;
}
.board-toast.show { opacity: 1; transform: translateX(-50%) translateY(6px); }

/* --------------------------------------------------------------------------
   Zug-Coach
   -------------------------------------------------------------------------- */

.coach {
  position: absolute;
  left: 14px;
  bottom: 74px;
  z-index: 7;
  width: min(330px, calc(100% - 96px));
  padding: 12px 14px;
  border-radius: var(--radius);
  background: rgba(20, 16, 13, .93);
  backdrop-filter: blur(12px);
  border: 1px solid var(--accent-deep);
  box-shadow: var(--shadow);
  font-size: .87rem;
  animation: coachRein .28s ease;
}
.coach[hidden] { display: none; }

@keyframes coachRein {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

.coach-kopf { display: flex; align-items: center; margin-bottom: 7px; }
.coach-titel {
  font-family: var(--serif);
  font-size: 1rem;
  color: var(--accent-warm);
}
.coach-zu {
  margin-left: auto;
  width: 26px; height: 26px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--text-faint);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}
.coach-zu:hover { background: var(--panel-2); color: var(--text); }

.coach-zuege {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  margin-bottom: 6px;
  font-family: var(--mono);
}
.coach-gespielt { color: #e9a294; text-decoration: line-through; }
.coach-pfeil    { color: var(--text-faint); }
.coach-besser   { color: #9fd88c; font-weight: 700; }
.coach-verlust  { margin-left: auto; color: var(--text-faint); font-size: .78rem; }

.coach-variante {
  font-family: var(--mono);
  font-size: .8rem;
  color: var(--text-dim);
  background: #17120e;
  border-radius: 7px;
  padding: 6px 9px;
  margin-bottom: 7px;
  word-spacing: 4px;
}
.coach-text { color: var(--text-dim); line-height: 1.45; }
.coach-text.laedt { color: var(--text-faint); font-style: italic; }

@media (max-width: 700px) {
  .coach {
    left: 9px; right: 9px; bottom: 62px;
    width: auto;
    font-size: .82rem;
  }
}

/* Seitenspalte */
.side {
  display: flex;
  flex-direction: column;
  background: var(--bg-2);
  border-left: 1px solid var(--line-soft);
  min-height: 0;
}

/* Kacheln der Videobilder: eine eigene plus je eine pro Gegenstelle.
   Ab drei Teilnehmern wird automatisch zweispaltig umgebrochen. */
.cam-stack {
  padding: 10px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}
.cam-stack.mehrere { grid-template-columns: 1fr 1fr; }

.besucher-hinweis {
  margin: 10px 10px 0;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: rgba(111, 159, 216, .12);
  border: 1px solid #2b4358;
  color: #b0d3ea;
  font-size: .84rem;
  line-height: 1.4;
}

.cam-box .cam-rolle {
  position: absolute;
  right: 7px; top: 7px;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(0, 0, 0, .6);
  font-size: .68rem;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.cam-box .cam-rolle.besucher { background: rgba(111, 159, 216, .8); color: #0d1b26; font-weight: 700; }

.teilnehmer-zeile {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 4px 2px;
  font-size: .84rem;
}
.teilnehmer-zeile .rolle { margin-left: auto; color: var(--text-faint); font-size: .74rem; }
.cam-box {
  position: relative;
  border-radius: 11px;
  overflow: hidden;
  background: #0d0a08;
  border: 1px solid var(--line-soft);
  aspect-ratio: 4 / 3;
}
.cam-box video { width: 100%; height: 100%; object-fit: cover; display: block; background: #0d0a08; }
.cam-box.self video { transform: scaleX(-1); }
.cam-label {
  position: absolute;
  left: 7px; bottom: 7px;
  padding: 3px 9px;
  border-radius: 6px;
  background: rgba(0,0,0,.62);
  font-size: .74rem;
  letter-spacing: .03em;
}
.cam-placeholder {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  text-align: center;
  color: var(--text-faint);
  font-size: .84rem;
  padding: 14px;
}
.cam-controls { display: flex; gap: 6px; }
.cam-controls .btn { flex: 1; padding: 7px; font-size: .8rem; }
.cam-controls .btn.off { color: var(--red); border-color: #5e2f28; }

.side-tabs {
  display: flex;
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
}
.side-tabs button {
  flex: 1;
  padding: 10px 6px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-family: inherit;
  font-size: .86rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}
.side-tabs button.on { color: var(--accent-warm); border-bottom-color: var(--accent); background: rgba(200,160,106,.05); }

.side-panel { flex: 1; min-height: 0; display: none; flex-direction: column; }
.side-panel.on { display: flex; }

.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}
.msg { max-width: 88%; }
.msg .bubble {
  padding: 7px 12px;
  border-radius: 13px;
  background: var(--panel);
  border: 1px solid var(--line-soft);
  font-size: .9rem;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.msg .meta { font-size: .7rem; color: var(--text-faint); margin: 3px 4px 0; }
.msg.mine { align-self: flex-end; }
.msg.mine .bubble { background: linear-gradient(160deg, #43341f, #322718); border-color: var(--accent-deep); }
.msg.mine .meta { text-align: right; }
.msg.system { align-self: center; max-width: 100%; }
.msg.system .bubble {
  background: transparent;
  border: none;
  color: var(--text-faint);
  font-size: .8rem;
  font-style: italic;
  text-align: center;
  padding: 2px;
}

.chat-input { display: flex; gap: 7px; padding: 10px; border-top: 1px solid var(--line-soft); }
.chat-input input { flex: 1; }

.move-list { flex: 1; overflow-y: auto; padding: 8px; min-height: 0; }
.move-row { display: grid; grid-template-columns: 34px 1fr 1fr; gap: 4px; align-items: center; }
.move-row .num { color: var(--text-faint); font-size: .78rem; font-family: var(--mono); text-align: right; padding-right: 6px; }
.move-row span.san {
  padding: 4px 8px;
  border-radius: 6px;
  font-family: var(--mono);
  font-size: .87rem;
  cursor: default;
}
.move-row span.san.last { background: rgba(111,159,216,.16); color: #b9d5f2; }

.side-foot { padding: 10px; border-top: 1px solid var(--line-soft); display: flex; flex-direction: column; gap: 7px; }

.settings-panel { padding: 14px; overflow-y: auto; }
.settings-panel .field:last-child { margin-bottom: 0; }
.thumb-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 7px; }
.thumb {
  padding: 10px 8px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #17120e;
  cursor: pointer;
  font-size: .82rem;
  text-align: center;
  transition: all .15s;
}
.thumb:hover { border-color: var(--accent-deep); }
.thumb.on { border-color: var(--accent); background: rgba(200,160,106,.13); color: var(--accent-warm); }
.thumb i { display: block; height: 26px; border-radius: 5px; margin-bottom: 6px; }

/* --------------------------------------------------------------------------
   Dialoge
   -------------------------------------------------------------------------- */

.modal-back {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(8, 6, 4, .74);
  backdrop-filter: blur(5px);
  display: grid;
  place-items: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}
.modal-back.on { opacity: 1; pointer-events: auto; }
.modal {
  width: 100%;
  max-width: 420px;
  background: linear-gradient(180deg, var(--panel) 0%, var(--bg-2) 100%);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 26px;
  transform: translateY(12px) scale(.98);
  transition: transform .2s;
}
.modal-back.on .modal { transform: none; }
.modal h3 { margin-bottom: 8px; }
.modal p { color: var(--text-dim); margin: 0 0 18px; }
.modal-actions { display: flex; gap: 9px; justify-content: flex-end; flex-wrap: wrap; }

.promo-pick { display: flex; gap: 10px; justify-content: center; }
.promo-pick button {
  width: 68px; height: 78px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: #17120e;
  color: var(--text);
  font-size: 34px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all .15s;
}
.promo-pick button:hover { border-color: var(--accent); background: rgba(200,160,106,.13); transform: translateY(-2px); }

.ladebalken {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--bg);
  z-index: 30;
  transition: opacity .5s;
  text-align: center;
}
.ladebalken.weg { opacity: 0; pointer-events: none; }
.spinner {
  width: 42px; height: 42px;
  margin: 0 auto 16px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: dreh .9s linear infinite;
}
@keyframes dreh { to { transform: rotate(360deg); } }

/* --------------------------------------------------------------------------
   Kleine Bildschirme
   -------------------------------------------------------------------------- */

@media (max-width: 1000px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .game-layout {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(46vh, 1fr) auto;
    height: auto;
    min-height: calc(100vh - var(--header-h));
  }
  .board-area { min-height: 46vh; }
  .side {
    border-left: none;
    border-top: 1px solid var(--line-soft);
    max-height: 54vh;
  }
  .cam-stack { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 700px) {
  :root { --header-h: 54px; }
  body { font-size: 14px; }
  h1 { font-size: 1.55rem; }
  .wrap { padding: 16px 12px 40px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .hero { padding: 22px 18px; }
  .topbar { gap: 10px; padding: 0 12px; }
  .topbar nav a { padding: 6px 9px; font-size: .85rem; }
  .user-chip span.uname { display: none; }
  .board-overlay { padding: 9px; }
  .player-strip { padding: 6px 11px; gap: 8px; font-size: .85rem; }
  .player-strip .clock { font-size: .95rem; }
  /* Mindestens 44 px - darunter trifft man mit dem Daumen daneben. */
  .board-toolbar { right: 8px; }
  .board-toolbar .btn { width: 46px; min-height: 44px; padding: 6px 2px; font-size: .58rem; }
  .board-toolbar .btn .icon { font-size: 1.05rem; }
  .cam-controls .btn { min-height: 42px; }
  .chat-input input, .chat-input .btn { min-height: 42px; }
  .modal { padding: 20px; }
}

@media (max-width: 430px) {
  /* Auch auf schmalen Geraeten bleibt die Beschriftung stehen: reine
     Zeichen sind fuer Gelegenheitsspieler schwer zu deuten, und auf dem
     Handy gibt es keine Kurzhinweise beim Darueberfahren. */
  .board-toolbar .btn { width: 52px; min-height: 46px; padding: 6px 2px; font-size: .53rem; }
  .board-toolbar .btn .icon { font-size: 1rem; }
}

/* Bewegungen zuruecknehmen, wenn der Nutzer das so eingestellt hat */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent-deep); }
