/* =========================================================================
   Mäxchen – Optik: Bierdeckel auf dunklem Wirtshaustisch.
   Pappton als Fläche, Kugelschreiber-Blau für alles Handschriftliche,
   Rot ausschließlich für verlorene Leben.
   Nur System-Schriften, keine externen Ressourcen.
   ========================================================================= */

:root {
  --pappe:        #dbc79f;
  --pappe-hell:   #e8d8b6;
  --pappe-tief:   #c3aa7c;
  --pappe-kante:  #a98f61;
  --tisch:        #241a12;
  --tisch-hell:   #3a2a1c;

  --tinte:        #1e3c8c;
  --tinte-hell:   #385bb0;
  --tinte-blass:  rgba(30, 60, 140, 0.42);
  --rot:          #b32a20;
  --rot-blass:    rgba(179, 42, 32, 0.5);

  --hand: "Segoe Print", "Segoe Script", "Bradley Hand", "Chalkboard SE",
          "Comic Sans MS", "Ink Free", cursive;
  --druck: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
           Arial, sans-serif;

  --radius: 20px;
  --spalte: 30rem;
}

* { box-sizing: border-box; }

/* Das hidden-Attribut muss jede display-Regel schlagen. Ohne diese Zeile
   gewinnt z.B. .sichtschutz { display: grid } gegen [hidden] aus dem
   Browser-Stylesheet – der Sperrbildschirm klebt dann ueber der Seite. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--druck);
  color: var(--tinte);
  background:
    radial-gradient(120% 80% at 50% -10%, var(--tisch-hell) 0%, var(--tisch) 60%),
    var(--tisch);
  background-attachment: fixed;
}

/* Feine Körnung über dem ganzen Tisch – ein inline-SVG, kein Netzwerkzugriff. */
.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 999;
  opacity: 0.14;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

.spalte {
  width: 100%;
  max-width: var(--spalte);
  margin: 0 auto;
  padding: max(1rem, env(safe-area-inset-top)) 1rem
           calc(1.5rem + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* -------------------------------------------------------------------------
   Der Bierdeckel
   ------------------------------------------------------------------------- */

.deckel {
  position: relative;
  padding: 1.35rem 1.25rem;
  border-radius: var(--radius);
  background:
    radial-gradient(90% 70% at 25% 15%, rgba(255,255,255,0.30), transparent 60%),
    radial-gradient(70% 60% at 85% 95%, rgba(120,90,50,0.20), transparent 65%),
    linear-gradient(160deg, var(--pappe-hell), var(--pappe) 45%, var(--pappe-tief));
  box-shadow:
    0 1px 0 rgba(255,255,255,0.35) inset,
    0 -2px 0 var(--pappe-kante) inset,
    0 10px 22px -8px rgba(0,0,0,0.65),
    0 2px 0 var(--pappe-kante);
}

/* Aufgedruckter Doppelrand, wie auf echten Deckeln */
.deckel__rand {
  position: absolute;
  inset: 7px;
  border: 1px solid var(--tinte-blass);
  border-radius: calc(var(--radius) - 6px);
  pointer-events: none;
}
.deckel__rand::after {
  content: "";
  position: absolute;
  inset: 3px;
  border: 2px dashed rgba(30, 60, 140, 0.16);
  border-radius: calc(var(--radius) - 9px);
}

.deckel--kopf { text-align: center; padding: 1.1rem 1.25rem 1rem; }
.deckel--tafel { padding: 1rem 1.1rem; }
.deckel--buehne { min-height: 15rem; display: flex; flex-direction: column; }
.deckel--log { padding: 0.9rem 1.1rem 1rem; }

/* -------------------------------------------------------------------------
   Schrift
   ------------------------------------------------------------------------- */

.titel {
  font-family: var(--hand);
  font-size: clamp(2.4rem, 12vw, 3.2rem);
  line-height: 1;
  margin: 0.1rem 0 0.2rem;
  color: var(--tinte);
  transform: rotate(-1.6deg);
  text-shadow: 0 1px 0 rgba(255,255,255,0.4);
}

.untertitel {
  font-family: var(--hand);
  margin: 0;
  font-size: 1rem;
  color: var(--tinte-hell);
  transform: rotate(0.8deg);
}

.kapitel {
  font-family: var(--druck);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.7rem;
  font-weight: 700;
  color: rgba(30,60,140,0.62);
  margin: 0 0 0.7rem;
}
.kapitel--klein { margin-bottom: 0.45rem; }

.label {
  display: block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-weight: 700;
  color: rgba(30,60,140,0.6);
  margin-bottom: 0.3rem;
}

.hinweis {
  font-family: var(--hand);
  font-size: 1.05rem;
  margin: 0.4rem 0 0.8rem;
  color: var(--tinte);
}

.fussnote {
  font-size: 0.76rem;
  line-height: 1.45;
  color: rgba(30,60,140,0.72);
  margin: 0.5rem 0 0.9rem;
}

/* Raumcode-Stempel */
.stempel {
  display: inline-flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-top: 0.7rem;
  padding: 0.3rem 0.8rem 0.35rem;
  border: 2px solid var(--tinte-blass);
  border-radius: 6px;
  transform: rotate(-2.4deg);
}
.stempel__label {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-weight: 700;
  color: rgba(30,60,140,0.62);
}
.stempel__code {
  font-family: var(--hand);
  font-size: 1.6rem;
  letter-spacing: 0.22em;
  line-height: 1;
  color: var(--tinte);
}

/* -------------------------------------------------------------------------
   Eingaben und Knöpfe
   ------------------------------------------------------------------------- */

.feld { margin-bottom: 0.9rem; }
.feld--reihe { display: flex; gap: 0.5rem; align-items: stretch; }
.feld--reihe .eingabe { flex: 1; min-width: 0; }

.eingabe {
  width: 100%;
  font-family: var(--hand);
  font-size: 1.2rem;
  color: var(--tinte);
  background: transparent;
  border: none;
  border-bottom: 2px solid var(--tinte-blass);
  border-radius: 0;
  padding: 0.45rem 0.2rem;
  outline-offset: 4px;
}
.eingabe::placeholder { color: rgba(30,60,140,0.32); }
.eingabe:focus-visible { outline: 2px solid var(--tinte-hell); }

.eingabe--code {
  text-align: center;
  font-size: 2.1rem;
  letter-spacing: 0.5em;
  text-indent: 0.5em;
}

.knopf {
  display: block;
  width: 100%;
  font-family: var(--hand);
  font-size: 1.15rem;
  color: var(--pappe-hell);
  background: linear-gradient(175deg, var(--tinte-hell), var(--tinte));
  border: none;
  border-radius: 12px;
  padding: 0.72rem 1rem;
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(16,32,76,0.9), 0 6px 14px -6px rgba(0,0,0,0.6);
  transition: transform 0.08s ease, box-shadow 0.08s ease, opacity 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.knopf:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: 0 1px 0 rgba(16,32,76,0.9);
}
.knopf:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: 0 3px 0 rgba(16,32,76,0.5);
}
.knopf--gross { font-size: 1.35rem; padding: 0.9rem 1rem; margin-top: 0.4rem; }
.knopf--klein { width: auto; font-size: 1rem; padding: 0.5rem 0.9rem; white-space: nowrap; }

.knopf--umriss {
  color: var(--tinte);
  background: transparent;
  border: 2px solid var(--tinte);
  box-shadow: 0 3px 0 rgba(30,60,140,0.28);
}

.knopf--rot {
  background: linear-gradient(175deg, #cc3a2e, var(--rot));
  box-shadow: 0 3px 0 #7d1a13, 0 6px 14px -6px rgba(0,0,0,0.6);
}
.knopf--rot:active:not(:disabled) { box-shadow: 0 1px 0 #7d1a13; }

.knopfreihe { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; margin-top: 0.9rem; }

.link {
  background: none;
  border: none;
  font-family: var(--druck);
  font-size: 0.75rem;
  color: rgba(219,199,159,0.6);
  text-decoration: underline;
  cursor: pointer;
  padding: 0.2rem;
}

.trenner {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin: 1.1rem 0 0.9rem;
  color: rgba(30,60,140,0.5);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
}
.trenner::before, .trenner::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--tinte-blass);
}

/* -------------------------------------------------------------------------
   Sitze und Strichliste
   ------------------------------------------------------------------------- */

.sitze { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.55rem; }

.sitz {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0.55rem;
  border-radius: 10px;
  background: rgba(255,255,255,0.16);
  box-shadow: 0 1px 0 rgba(255,255,255,0.3) inset;
}
.sitz--dran {
  background: rgba(30,60,140,0.13);
  box-shadow: 0 0 0 2px var(--tinte-blass) inset;
}
.sitz--aus { opacity: 0.45; }

.sitz__name {
  font-family: var(--hand);
  font-size: 1.2rem;
  line-height: 1.1;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sitz__marke {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 700;
  padding: 0.12rem 0.35rem;
  border: 1px solid var(--tinte-blass);
  border-radius: 4px;
  color: rgba(30,60,140,0.7);
  flex: none;
}
.sitz__marke--offline { color: var(--rot-blass); border-color: var(--rot-blass); }
.sitz__marke--aus { color: var(--rot); border-color: var(--rot); }

/* Strichliste: gezählte Leben als Kugelschreiber-Striche */
.striche { display: flex; align-items: flex-end; gap: 5px; flex: none; height: 30px; }
.strich {
  position: relative;
  width: 4px;
  height: 26px;
  border-radius: 2px;
  background: var(--tinte);
  box-shadow: 0 0 1px rgba(30,60,140,0.6);
}
.strich:nth-child(1) { transform: rotate(-7deg); }
.strich:nth-child(2) { transform: rotate(4deg)  translateY(-1px); }
.strich:nth-child(3) { transform: rotate(-3deg) translateY(1px); }
.strich:nth-child(4) { transform: rotate(6deg); }

.strich--weg { background: var(--rot-blass); }
.strich--weg::after {
  content: "";
  position: absolute;
  left: -8px;
  right: -8px;
  top: 50%;
  height: 3px;
  border-radius: 2px;
  background: var(--rot);
  transform: rotate(-38deg);
}

/* -------------------------------------------------------------------------
   Tafel oben im Spiel
   ------------------------------------------------------------------------- */

.tafel__kopf {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.7rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--tinte-blass);
}
.rundenzahl {
  font-family: var(--hand);
  font-size: 1.15rem;
}
.ansagenschild {
  font-family: var(--druck);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
  color: rgba(30,60,140,0.62);
  text-align: right;
}
.ansagenschild b {
  font-family: var(--hand);
  font-size: 1.3rem;
  letter-spacing: 0;
  color: var(--tinte);
  margin-left: 0.3rem;
  text-transform: none;
}

.sitze--kompakt .sitz { padding: 0.3rem 0.45rem; }
.sitze--kompakt .sitz__name { font-size: 1.05rem; }
.sitze--kompakt .striche { height: 24px; }
.sitze--kompakt .strich { height: 21px; }

/* -------------------------------------------------------------------------
   Bühne: der wechselnde Hauptbereich
   ------------------------------------------------------------------------- */

.szene {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.5rem;
  flex: 1;
  justify-content: center;
  padding: 0.3rem 0;
}

.szene__dran {
  font-family: var(--hand);
  font-size: 1.85rem;
  line-height: 1.1;
  margin: 0;
  transform: rotate(-1deg);
}
.szene__zeile {
  font-family: var(--hand);
  font-size: 1.1rem;
  margin: 0;
  color: var(--tinte-hell);
  max-width: 22rem;
}
.szene__zeile--klein { font-size: 0.95rem; color: rgba(30,60,140,0.7); }

.wartepunkte::after {
  content: "…";
  animation: punkte 1.4s steps(4, end) infinite;
}
@keyframes punkte { 0% { content: "."; } 33% { content: ".."; } 66% { content: "…"; } }

/* Würfel – reine CSS-Augen */
.wuerfelpaar { display: flex; gap: 0.7rem; margin: 0.5rem 0 0.3rem; }

.wuerfel {
  --kante: 3.6rem;
  width: var(--kante);
  height: var(--kante);
  display: grid;
  grid-template: repeat(3, 1fr) / repeat(3, 1fr);
  gap: 8%;
  padding: 12%;
  border-radius: 18%;
  background: linear-gradient(150deg, #fffdf6, #ece2cd 70%, #d9cbb0);
  box-shadow:
    0 1px 0 #fff inset,
    0 -3px 6px rgba(120,95,55,0.28) inset,
    0 6px 12px -4px rgba(0,0,0,0.5);
}
.wuerfel--gross { --kante: 5.6rem; }
.wuerfel--klein { --kante: 2rem; gap: 10%; padding: 14%; }

.auge {
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #4a4a4a, #14181f 70%);
  box-shadow: 0 1px 1px rgba(255,255,255,0.5);
}
.auge--leer { background: none; box-shadow: none; }

.wuerfel--wurf { animation: kullern 0.45s ease-out; }
@keyframes kullern {
  0%   { transform: rotate(-24deg) scale(0.7); opacity: 0; }
  60%  { transform: rotate(9deg)  scale(1.06); opacity: 1; }
  100% { transform: rotate(0)     scale(1); }
}

.wurfwert {
  font-family: var(--hand);
  font-size: 2.4rem;
  line-height: 1;
  margin: 0.1rem 0 0;
}
.wurfwert small {
  display: block;
  font-family: var(--druck);
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-weight: 700;
  color: rgba(30,60,140,0.6);
  margin-bottom: 0.15rem;
}

/* Becher-Knopf zum Würfeln */
.becher {
  width: 100%;
  border: none;
  background: none;
  cursor: pointer;
  padding: 0.4rem 0;
  -webkit-tap-highlight-color: transparent;
}
.becher__form {
  width: 5.4rem;
  height: 5.4rem;
  margin: 0 auto 0.6rem;
  border-radius: 14% 14% 40% 40% / 10% 10% 26% 26%;
  background: linear-gradient(160deg, #3c5fb4, #16306f);
  box-shadow:
    0 2px 0 rgba(255,255,255,0.22) inset,
    0 -10px 16px rgba(0,0,0,0.35) inset,
    0 8px 16px -6px rgba(0,0,0,0.6);
  display: grid;
  place-items: center;
  transition: transform 0.12s ease;
}
.becher:active .becher__form { transform: translateY(3px) rotate(-6deg); }
.becher__form span {
  font-family: var(--hand);
  font-size: 1.5rem;
  color: var(--pappe-hell);
}

/* Ansage-Auswahl */
.ansagen { width: 100%; margin-top: 0.6rem; }
.ansagen__gruppe { margin-bottom: 0.7rem; }
.ansagen__titel {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-weight: 700;
  color: rgba(30,60,140,0.55);
  margin: 0 0 0.35rem;
  text-align: left;
}
.ansagen__reihe {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(3.6rem, 1fr));
  gap: 0.4rem;
}
.chip {
  font-family: var(--hand);
  font-size: 1.3rem;
  line-height: 1;
  color: var(--tinte);
  background: rgba(255,255,255,0.35);
  border: 1.5px solid var(--tinte-blass);
  border-radius: 9px;
  padding: 0.5rem 0.2rem;
  cursor: pointer;
  transition: transform 0.08s, background 0.12s;
  -webkit-tap-highlight-color: transparent;
}
.chip:active { transform: translateY(2px); background: rgba(30,60,140,0.14); }
.chip--pasch { border-style: double; border-width: 3px; }
.chip--maexchen {
  grid-column: 1 / -1;
  background: linear-gradient(175deg, var(--tinte-hell), var(--tinte));
  color: var(--pappe-hell);
  border-color: var(--tinte);
  font-size: 1.5rem;
  letter-spacing: 0.05em;
}

/* -------------------------------------------------------------------------
   Der Aufdecken-Moment
   ------------------------------------------------------------------------- */

.aufloesung { width: 100%; }

.aufloesung__kopf {
  font-family: var(--druck);
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-weight: 700;
  color: rgba(30,60,140,0.6);
  text-align: center;
  margin: 0 0 0.7rem;
}

.gegenueber {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.9rem;
}

.gegenueber__wurf { display: flex; gap: 0.5rem; }

.gegenueber__vs {
  font-family: var(--hand);
  font-size: 1.1rem;
  color: rgba(30,60,140,0.6);
  flex: none;
}

.gegenueber__ansage { text-align: left; flex: none; }
.gegenueber__ansage small {
  display: block;
  font-family: var(--druck);
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-weight: 700;
  color: rgba(30,60,140,0.6);
}
.gegenueber__ansage b {
  font-family: var(--hand);
  font-size: 2.6rem;
  line-height: 1;
  display: block;
}

.urteil {
  font-family: var(--hand);
  font-size: 1.9rem;
  line-height: 1.15;
  text-align: center;
  margin: 0.9rem 0 0.2rem;
  transform: rotate(-1.2deg);
}
.urteil--luege { color: var(--rot); }

.begruendung {
  font-family: var(--hand);
  font-size: 1.05rem;
  text-align: center;
  margin: 0.1rem 0 0.4rem;
  color: var(--tinte-hell);
}

.verlust {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  margin: 0.7rem auto 0;
  padding: 0.5rem 0.8rem;
  border: 2px solid var(--rot-blass);
  border-radius: 12px;
  width: fit-content;
  max-width: 100%;
}
.verlust__name { font-family: var(--hand); font-size: 1.25rem; color: var(--rot); }

.ausgeschieden {
  font-family: var(--hand);
  font-size: 1.15rem;
  color: var(--rot);
  text-align: center;
  margin: 0.6rem 0 0;
}

/* Sieger */
.sieger { text-align: center; }
.sieger__krone { font-size: 2.6rem; line-height: 1; }
.sieger__name {
  font-family: var(--hand);
  font-size: 2.4rem;
  line-height: 1.1;
  margin: 0.2rem 0 0.1rem;
  transform: rotate(-1.5deg);
}
.sieger__zeile { font-family: var(--hand); font-size: 1.1rem; color: var(--tinte-hell); margin: 0; }

/* -------------------------------------------------------------------------
   Mitschrift
   ------------------------------------------------------------------------- */

.log { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.18rem; }
.log li {
  font-family: var(--hand);
  font-size: 0.95rem;
  line-height: 1.35;
  color: rgba(30,60,140,0.78);
  padding-left: 0.9rem;
  position: relative;
}
.log li::before {
  content: "–";
  position: absolute;
  left: 0;
  color: var(--tinte-blass);
}
.log li:last-child { color: var(--tinte); }

/* -------------------------------------------------------------------------
   Regeln, Fuß, Sichtschutz, Toast
   ------------------------------------------------------------------------- */

.regeln { margin-top: 1.2rem; border-top: 1px solid var(--tinte-blass); padding-top: 0.7rem; }
.regeln summary {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-weight: 700;
  color: rgba(30,60,140,0.62);
  cursor: pointer;
}
.regeln__text p { font-size: 0.84rem; line-height: 1.5; margin: 0.6rem 0; }
.regeln__text b { color: var(--tinte); }
.rangzeile {
  font-family: var(--hand);
  font-size: 1rem !important;
  line-height: 1.6 !important;
  word-spacing: 0.2em;
}
.regeln__variante {
  font-size: 0.76rem !important;
  color: rgba(30,60,140,0.62);
  border-left: 2px solid var(--tinte-blass);
  padding-left: 0.6rem;
}

.fuss {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.2rem 0.4rem;
  font-size: 0.72rem;
  color: rgba(219,199,159,0.5);
  min-height: 1.4rem;
}

.sichtschutz {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: grid;
  place-items: center;
  padding: 1.2rem;
  background: rgba(20, 14, 9, 0.94);
  backdrop-filter: blur(3px);
}
.deckel--schutz { width: 100%; max-width: 22rem; text-align: center; padding: 2rem 1.4rem 1.6rem; }
.schutz__zeile { font-family: var(--hand); font-size: 1.15rem; margin: 0; color: var(--tinte-hell); }
.schutz__zeile--klein { font-size: 0.9rem; color: rgba(30,60,140,0.65); margin-top: 0.6rem; }
.schutz__name {
  font-family: var(--hand);
  font-size: 2.5rem;
  line-height: 1.1;
  margin: 0.3rem 0 0;
  transform: rotate(-1.5deg);
}
.deckel--schutz .knopf { margin-top: 1.3rem; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(1.2rem + env(safe-area-inset-bottom));
  transform: translate(-50%, 140%);
  z-index: 1000;
  max-width: min(26rem, calc(100vw - 2rem));
  padding: 0.65rem 1rem;
  border-radius: 10px;
  background: var(--rot);
  color: #fff4ef;
  font-family: var(--hand);
  font-size: 1.05rem;
  text-align: center;
  box-shadow: 0 10px 24px -8px rgba(0,0,0,0.8);
  opacity: 0;
  transition: transform 0.25s ease, opacity 0.25s ease;
  pointer-events: none;
}
.toast--sichtbar { transform: translate(-50%, 0); opacity: 1; }

@media (max-width: 360px) {
  .spalte { padding-left: 0.7rem; padding-right: 0.7rem; }
  .deckel { padding: 1.1rem 0.9rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001s !important; transition-duration: 0.001s !important; }
}
