*, *::before, *::after {
      box-sizing: border-box;
    }

:root {
  /* Füge diese Variablen oben im :root Bereich hinzu, falls noch nicht vorhanden, 
     oder nutze einfach den bestehenden Block */
  --bg-color: #f4f4f4;
  --text-color: #333;
  --door-bg: #2c3e50;
  --door-text: #fff;
  --focus-bg: #ffff00;
  --focus-text: #000000;
}

/* --- NEU: HILFSKLASSE ZUM AUSBLENDEN --- */
.hidden {
  display: none !important;
}

/* --- NEU: STYLING FÜR GESCHICHTEN/TEXTE --- */
.story-container {
  font-size: 1.1rem;
  line-height: 1.8;
  text-align: left;
  background-color: #f9f9f9;
  padding: 15px;
  border-left: 5px solid #2c3e50;
  margin-bottom: 20px;
  max-height: 400px;
  overflow-y: auto; /* Scrollbalken, falls die Geschichte lang ist */
}

/* Kleine Anpassung, damit Bilder in Geschichten responsive sind (falls du welche nutzt) */
.story-container img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
}

.story-container ul, 
.story-container ol {
  margin-left: 20px;     /* Rückt die Liste etwas ein */
  margin-bottom: 15px;   /* Abstand nach unten */
  list-style-position: outside;
}

.story-container li {
  margin-bottom: 5px;    /* Kleiner Abstand zwischen den Punkten */
}

body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  line-height: 1.6;
  margin: 0;
  padding: 20px;
}

h1 {
  text-align: center;
  margin-bottom: 30px;
}

.instructions {
  text-align: center;
  margin-bottom: 20px;
}

/* Grid Layout für die Türchen */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 20px;
  max-width: 1000px;
  margin: 0 auto;
  padding: 0;
  list-style: none; /* Wichtig da wir ul nutzen */
}

.door {
  background-color: var(--door-bg);
  color: var(--door-text);
  border: 2px solid #000;
  border-radius: 8px;
  font-size: 2rem;
  font-weight: bold;
  height: 120px;
  width: 100%;
  cursor: pointer;
  position: relative;
  transition: transform 0.1s;
}

.door.solved {
  background-color: #27ae60;
  color: #fff;
}

.door.solved::after {
  content: "✓";
  position: absolute;
  top: 5px;
  right: 10px;
  font-size: 1.5rem;
}

.door:disabled {
  background-color: #ccc;
  color: #666;
  cursor: not-allowed;
  border-color: #999;
}

/* High Contrast Focus */
.door:focus-visible,
button:focus-visible,
input:focus-visible {
  background-color: var(--focus-bg) !important;
  color: var(--focus-text) !important;
  outline: 4px solid #000000;
  box-shadow: 0 0 0 4px var(--focus-bg);
  z-index: 10;
  transform: scale(1.05);
}

/* --- MODAL (DIALOG) STYLING --- */
dialog {
  border: 4px solid #333;
  border-radius: 8px;
  padding: 20px;
  max-width: 600px;
  width: 90%;
  background: #fff;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.7);
}

.board-container {
  margin: 20px auto;
  display: flex;
  justify-content: center;
}

/* --- SCHACHBRETT STYLING --- */
table.chessboard {
  border-collapse: collapse;
  border: none;
  user-select: none;
  table-layout: fixed; 
}

/* Die Spielfelder (td) */
table.chessboard td {
  width: 45px;
  height: 45px;
  padding: 0; 
  margin: 0;
  text-align: center;
  font-size: 2.2rem;
  vertical-align: middle;
  cursor: default;
  border: 1px solid #333;
}

/* Die Koordinaten (th) - Zeilen und Spaltenbeschriftung */
table.chessboard th {
  padding: 5px;
  font-weight: bold;
  font-size: 1rem;
  color: #555;
  border: none;
  background: transparent;
}

/* WICHTIG: Verhindert Emoji-Darstellung */
.chessboard span {
  font-family: "Segoe UI Symbol", "DejaVu Sans", "Symbola", serif;
  font-variant-emoji: text;
  font-weight: 400;
  display: block; 
  line-height: 45px;
}

/* --- BRETTFARBEN (KORRIGIERT) --- */
/* Jetzt: a1 (links unten) ist dunkel, h1 ist hell. */

/* Helle Felder (#ffffff) */
.chessboard tr:nth-child(odd) td:nth-child(even),
.chessboard tr:nth-child(even) td:nth-child(odd) {
  background-color: #ffffff;
  color: #000;
}

/* Dunkle Felder (#888888) */
.chessboard tr:nth-child(odd) td:nth-child(odd),
.chessboard tr:nth-child(even) td:nth-child(even) {
  background-color: #888888;
  color: #fff;
}

/* Klasse für weiße Figuren */
.piece-white {
  color: #ffffff !important;
  text-shadow:
   -1px -1px 0 #000,
    1px -1px 0 #000,
   -1px  1px 0 #000,
    1px  1px 0 #000;
}

/* Klasse für schwarze Figuren */
.piece-black {
  color: #000000 !important;
  text-shadow: 0 0 1px #ffffff; /* Leichter weißer Rand */
}

.chessboard td {
  border: none; 
}

.puzzle-controls {
  margin-top: 20px;
  text-align: center;
}

input[type="text"] {
  font-size: 1.2rem;
  padding: 8px;
  border: 2px solid #333;
  margin-right: 10px;
  width: 100px;
}

.btn-action {
  background: #2c3e50;
  color: #fff;
  border: 2px solid #000;
  padding: 8px 16px;
  font-size: 1rem;
  cursor: pointer;
  margin: 5px;
}

.feedback {
  margin-top: 15px;
  padding: 10px;
  font-weight: bold;
  border-radius: 4px;
}
.feedback.success {
  background: #d4edda;
  color: #155724;
  border: 2px solid #155724;
}
.feedback.error {
  background: #f8d7da;
  color: #721c24;
  border: 2px solid #721c24;
}

/* Hilfsklasse für Screenreader-Text */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}