/* CHESSFIGHTERS.
 *
 * Die Schriften liegen NICHT als Webfont vor -- eine blockierte Anfrage nach
 * draussen verzoegert die Anzeige, und die CSP des VPS laesst fremde Hosts
 * ohnehin nicht durch. Systemschriften, mit einer Serifenkette fuer die
 * Ueberschriften: das Brett soll nach Tafel aussehen, nicht nach Dashboard.
 */

:root {
  --tinte: #0d1220;
  --tinte-weich: rgba(13, 18, 32, 0.86);
  --gold: #e8c169;
  --gold-hell: #ffe3a3;
  --pergament: #e8dcc0;
  --rot: #c8503a;
  --gruen: #5fd3a0;
  --rand: rgba(232, 193, 105, 0.28);
  --hud-hoehe: 3.2rem;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--tinte);
  color: var(--pergament);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

h1, h2, h3 {
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  letter-spacing: 0.04em;
  margin: 0 0 0.5em;
}
h1 { font-size: clamp(2rem, 7vw, 3.6rem); color: var(--gold); text-shadow: 0 2px 18px rgba(232,193,105,.25); }
h2 { font-size: clamp(1.3rem, 4vw, 2rem); color: var(--gold); }

/* --- Buehne ------------------------------------------------------------- */
#buehne, #effekte {
  position: fixed; inset: 0; width: 100%; height: 100%; display: block;
}
/* Die Partikelebene darf keine Tipps abfangen -- sie liegt ueber dem Brett. */
#effekte { pointer-events: none; z-index: 2; }
#buehne { z-index: 1; touch-action: none; }

/* --- Schirme ------------------------------------------------------------ */
.schirm {
  position: fixed; inset: 0; z-index: 10;
  display: flex; justify-content: center;
  background: radial-gradient(circle at 50% 35%, rgba(13,18,32,.72), rgba(6,9,17,.95));
  backdrop-filter: blur(3px);
  overflow-y: auto;
  padding: 1.2rem;
  /* NICHT align-items:center: zusammen mit overflow schneidet das den oberen
   * Rand ab, sobald der Inhalt hoeher wird als der Schirm. `margin:auto` am
   * Kind zentriert und laesst trotzdem nach oben scrollen. */
}
.schirm.versteckt, .versteckt { display: none !important; }

.mitte {
  margin: auto; text-align: center; max-width: 34rem; width: 100%;
}
.mitte.breit { max-width: 62rem; }
.scrollbar { max-height: 100%; }

.unter { color: var(--gold-hell); opacity: .85; font-style: italic; margin-top: -.4em; }
.wer { opacity: .8; font-size: .95rem; }
.hinweis { min-height: 2.4em; color: var(--gold-hell); font-size: .95rem; }
.punkte { color: var(--gold); font-size: 1.4rem; font-weight: 600; }

.knopfreihe {
  display: flex; flex-wrap: wrap; gap: .6rem;
  justify-content: center; align-items: center; margin: .9rem 0;
}

/* --- Knoepfe ------------------------------------------------------------ */
.btn {
  font: inherit; color: var(--pergament); cursor: pointer;
  background: linear-gradient(180deg, rgba(232,193,105,.14), rgba(232,193,105,.05));
  border: 1px solid var(--rand); border-radius: .5rem;
  padding: .6rem 1.1rem; min-height: 2.75rem;
  transition: background .15s, border-color .15s, transform .08s;
}
.btn:hover:not(:disabled) { background: rgba(232,193,105,.22); border-color: var(--gold); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .38; cursor: not-allowed; }
.btn.big { font-size: 1.1rem; padding: .8rem 1.6rem; min-width: 10rem; }
.btn.klein { padding: .35rem .7rem; min-height: 2.1rem; font-size: .9rem; }

input {
  font: inherit; color: var(--pergament); background: rgba(0,0,0,.35);
  border: 1px solid var(--rand); border-radius: .5rem;
  padding: .6rem .8rem; min-height: 2.75rem; width: 8rem;
  text-align: center; text-transform: uppercase; letter-spacing: .2em;
}

/* --- Stufenwahl --------------------------------------------------------- */
.kachelgitter {
  display: grid; gap: .7rem; margin: 1rem 0;
  grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
}
.kachel {
  display: flex; flex-direction: column; gap: .2rem;
  text-align: left; padding: .8rem .9rem; min-height: 5.4rem;
}
.kachel b { color: var(--gold); font-size: .8rem; letter-spacing: .1em; text-transform: uppercase; }
.kachel .ktitel { font-size: 1.05rem; }
.kachel .kunter { font-size: .82rem; opacity: .7; }
.kachel.gesperrt .kunter { color: var(--rot); opacity: .85; }

/* --- HUD ---------------------------------------------------------------- */
#hud {
  position: fixed; top: 0; left: 0; right: 0; z-index: 8;
  display: flex; align-items: center; gap: .8rem;
  min-height: var(--hud-hoehe); padding: .4rem .8rem;
  background: var(--tinte-weich);
  border-bottom: 1px solid var(--rand);
  font-size: .92rem;
  padding-top: max(.4rem, env(safe-area-inset-top));
}
.hud-links { flex: 1 1 40%; min-width: 0; display: flex; flex-direction: column; }
.hud-links > span:first-child { color: var(--gold); font-weight: 600; }
.hud-ziel { opacity: .75; font-size: .82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hud-mitte { flex: 0 1 auto; text-align: center; color: var(--gold-hell); }
.hud-rechts { flex: 1 1 auto; display: flex; gap: .4rem; justify-content: flex-end; align-items: center; }
.code { font-family: ui-monospace, Menlo, Consolas, monospace; letter-spacing: .15em; color: var(--gold); }

/* --- Assistent ---------------------------------------------------------- */
#assistent {
  position: fixed; top: var(--hud-hoehe); left: 0; right: 0; z-index: 8;
  display: flex; align-items: center; gap: .7rem;
  padding: .45rem .8rem;
  background: rgba(20, 30, 52, .92);
  border-bottom: 1px solid var(--rand);
  font-size: .95rem; color: var(--gold-hell);
}
#assistent-text { flex: 1 1 auto; }
#assistent b { color: #fff; font-family: ui-monospace, Menlo, Consolas, monospace; }

/* --- Zugliste ----------------------------------------------------------- */
#zugliste {
  position: fixed; top: calc(var(--hud-hoehe) + 3rem); right: .6rem; z-index: 7;
  width: 7.5rem; max-height: 42vh; overflow-y: auto;
  background: var(--tinte-weich); border: 1px solid var(--rand); border-radius: .5rem;
  padding: .4rem .2rem;
  font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .8rem;
}
#zugliste ol { margin: 0; padding-left: 1.9rem; }
#zugliste li.gegner { color: #9fb4d8; }
#zugliste li.eigen { color: var(--gold-hell); }

/* --- Bestenliste -------------------------------------------------------- */
table { width: 100%; border-collapse: collapse; margin: 1rem 0; }
th, td { padding: .45rem .6rem; border-bottom: 1px solid rgba(232,193,105,.14); text-align: left; }
th { color: var(--gold); font-size: .82rem; text-transform: uppercase; letter-spacing: .08em; }

#hilfe-text { text-align: left; }
#hilfe-text h3 { color: var(--gold-hell); margin-top: 1.2em; font-size: 1.05rem; }
#hilfe-text p { line-height: 1.55; opacity: .9; }

/* --- Ladebalken --------------------------------------------------------- */
.balken {
  width: min(22rem, 80vw); height: .5rem; margin: 1rem auto;
  background: rgba(255,255,255,.09); border-radius: .25rem; overflow: hidden;
}
.balken i { display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, var(--gold), var(--gold-hell));
  transition: width .25s; }

/* --- Sprachwahl (aus i18n.js) ------------------------------------------- */
.sprachwahl { display: inline-flex; gap: .25rem; }
.sprachwahl button {
  font: inherit; cursor: pointer; color: var(--pergament);
  background: transparent; border: 1px solid var(--rand);
  border-radius: .4rem; padding: .5rem .7rem; min-height: 2.75rem; min-width: 2.75rem;
}
.sprachwahl button[aria-pressed="true"] { background: rgba(232,193,105,.25); color: var(--gold-hell); }

/* --- Schmale Schirme ---------------------------------------------------- */
@media (max-width: 30rem) {
  #zugliste { width: 5.4rem; max-height: 30vh; font-size: .72rem; }
  .hud-ziel { display: none; }
  .kachelgitter { grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr)); }
}

/* --- Reglerpult (nur Heiminstanz, client/regler.js) ---------------------- */
#reglerpult {
  position: fixed; top: .6rem; left: .6rem; z-index: 20;
  width: min(23rem, 92vw); max-height: 92vh; overflow-y: auto;
  background: rgba(9, 13, 24, .95);
  border: 1px solid var(--rand); border-radius: .6rem;
  padding: .7rem .9rem; font-size: .85rem;
}
#reglerpult h3 { font-size: .95rem; margin: 0 0 .6rem; color: var(--gold); }
#reglerpult h4 {
  font-size: .78rem; text-transform: uppercase; letter-spacing: .08em;
  color: var(--gold-hell); opacity: .8; margin: .9rem 0 .3rem;
}
.reglerzeile {
  display: grid; grid-template-columns: 9.5rem 1fr 3rem;
  align-items: center; gap: .4rem; margin: .18rem 0;
}
.reglerzeile b { text-align: right; color: var(--gold); font-variant-numeric: tabular-nums; }
.reglerzeile input[type="range"] { width: 100%; min-height: 1.6rem; }
#reglerausgabe {
  width: 100%; margin-top: .7rem; font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: .8rem; background: rgba(0,0,0,.45); color: var(--pergament);
  border: 1px solid var(--rand); border-radius: .4rem; padding: .4rem;
}
