* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  overflow: hidden;
  background: #070b1a;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  user-select: none;
  -webkit-user-select: none;
}

button {
  font-family: inherit;
  cursor: pointer;
}

@font-face {
  font-family: "CrayonLibre";
  src: url("CrayonLibre.woff") format("woff");
  font-weight: normal;
  font-style: normal;
}

/* ---------- Spielfläche: dunkelgrüne Tafel mit beigen Schreiblinien ---------- */
#game {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background:
    repeating-linear-gradient(
      to bottom,
      transparent 0px,
      transparent 38px,
      rgba(232, 214, 178, 0.22) 38px,
      rgba(232, 214, 178, 0.22) 40px
    ),
    linear-gradient(160deg, #1d4a38 0%, #143a2c 60%, #0e2a20 100%);
  touch-action: none;
}

#game::after {
  content: "";
  position: absolute;
  inset: 10px;
  border: 2px solid rgba(232, 214, 178, 0.35);
  border-radius: 12px;
  pointer-events: none;
  z-index: 55;
}

#words {
  position: absolute;
  inset: 0;
}

/* ---------- Fallende Wörter ---------- */
.word {
  position: absolute;
  top: 0;
  font-family: "CrayonLibre", cursive;
  font-size: clamp(34px, 6.5vw, 62px);
  font-weight: normal;
  letter-spacing: 2px;
  will-change: top;
}

.type-noun {
  color: #ffd166;
  text-shadow: 0 0 18px rgba(255, 209, 102, 0.55);
}

.type-article {
  color: #c77dff;
  text-shadow: 0 0 18px rgba(199, 125, 255, 0.55);
}

.type-pronoun {
  color: #ffa94d;
  text-shadow: 0 0 18px rgba(255, 169, 77, 0.55);
}

.type-verb {
  color: #4cc9f0;
  text-shadow: 0 0 18px rgba(76, 201, 240, 0.55);
}

/* ---------- Füller (Stift) ---------- */
#pen {
  position: absolute;
  width: 76px;
  height: 172px;
  background: url("fueller.svg") center top / contain no-repeat;
  filter: drop-shadow(0 0 14px rgba(255, 170, 200, 0.45));
  z-index: 40;
  pointer-events: none;
}

/* Tintenstrahl (Projektil) */
#projectiles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 50;
}

.projectile {
  position: absolute;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #5a6fd6, #16224e);
  box-shadow: 0 0 12px 4px rgba(90, 110, 214, 0.8);
  z-index: 50;
}

/* Tintenklecks */
.splat {
  position: absolute;
  width: 200px;
  height: 200px;
  margin: -100px 0 0 -100px;
  background: #1c3fae;
  -webkit-mask-image: url("klecks.svg");
  mask-image: url("klecks.svg");
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  filter: drop-shadow(0 0 10px rgba(28, 63, 174, 0.6));
}

.splat-drop {
  position: absolute;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border-radius: 50%;
  background: #1c3fae;
}

/* ---------- Punkte-Floaters ---------- */
#floaters {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 45;
}

.floater {
  position: absolute;
  font-size: 36px;
  font-weight: 900;
  animation: floatUp 0.85s ease-out forwards;
}

@keyframes floatUp {
  0% {
    opacity: 1;
    transform: translateY(0);
  }
  100% {
    opacity: 0;
    transform: translateY(-80px);
  }
}

/* ---------- HUD ---------- */
#hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  z-index: 60;
  pointer-events: none;
}

.hud-item {
  background: rgba(10, 15, 35, 0.65);
  border: 1px solid rgba(120, 150, 255, 0.35);
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 13px;
  letter-spacing: 2px;
  color: #9fb0d8;
}

#score {
  color: #ffffff;
  font-size: 20px;
  font-weight: 800;
}

#high {
  color: #ffd166;
}

.hud-btn {
  pointer-events: auto;
  background: rgba(20, 30, 60, 0.8);
  border: 1px solid rgba(120, 150, 255, 0.45);
  color: #cdd8f5;
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
}

.hud-btn:hover {
  background: rgba(40, 55, 100, 0.9);
}

/* ---------- Startbildschirm ---------- */
#startScreen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(1000px 700px at 50% 0%, #1b2a5a 0%, #0b1026 60%, #05070f 100%);
  z-index: 100;
  padding: 20px;
}

#startScreen.hidden {
  display: none;
}

.card {
  background: rgba(12, 18, 42, 0.9);
  border: 1px solid rgba(120, 150, 255, 0.35);
  border-radius: 28px;
  padding: 44px 60px;
  text-align: center;
  box-shadow: 0 0 60px rgba(60, 80, 200, 0.35);
  max-width: 760px;
  max-height: 94vh;
  overflow-y: auto;
}

.card h1 {
  font-size: 52px;
  margin-bottom: 14px;
  color: #e7a259;
}

.pen-emoji {
  font-size: 90px;
  vertical-align: middle;
}

.subtitle {
  color: #9fb0d8;
  font-size: 26px;
  line-height: 1.6;
  margin-bottom: 18px;
}

.desc {
  background: rgba(20, 30, 60, 0.6);
  border: 1px solid rgba(120, 150, 255, 0.25);
  border-radius: 16px;
  padding: 14px 18px;
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
}

.desc-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #cdd8f5;
  font-size: 16px;
  flex-wrap: wrap;
}

.desc-row .key {
  background: rgba(60, 80, 160, 0.5);
  border: 1px solid rgba(140, 165, 255, 0.45);
  border-radius: 8px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 700;
  color: #ffffff;
  white-space: nowrap;
}

.label {
  color: #cdd8f5;
  font-size: 15px;
  letter-spacing: 1px;
  margin-bottom: 12px;
}

#typeOptions {
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.type-option {
  padding: 14px 30px;
  font-size: 20px;
  font-weight: 800;
  color: #cdd8f5;
  background: rgba(20, 30, 60, 0.8);
  border: 2px solid rgba(120, 150, 255, 0.35);
  border-radius: 16px;
  transition: all 0.2s ease;
}

.type-option:hover {
  transform: translateY(-2px);
  border-color: rgba(140, 165, 255, 0.8);
}

.type-option.selected {
  background: linear-gradient(135deg, #3b5bff, #7b2ff7);
  color: #ffffff;
  border-color: #8fa5ff;
  box-shadow: 0 0 24px rgba(90, 110, 255, 0.6);
}

.hidden {
  display: none !important;
}

.start-btn {
  margin-top: 8px;
  background: linear-gradient(135deg, #3b5bff, #7b2ff7);
  border: none;
  color: #ffffff;
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 2px;
  padding: 16px 54px;
  border-radius: 999px;
  box-shadow: 0 0 30px rgba(90, 110, 255, 0.65);
  transition: transform 0.15s ease;
}

.start-btn:hover {
  transform: scale(1.05);
}

/* ---------- Zeitscheibe am Rand ---------- */
#timerDisc {
  position: absolute;
  right: 18px;
  top: 50%;
  transform: translateY(-50%);
  width: 104px;
  height: 104px;
  z-index: 60;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

#timerDisc svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.timer-bg {
  fill: rgba(10, 15, 35, 0.55);
  stroke: rgba(255, 255, 255, 0.16);
  stroke-width: 9;
}

.timer-arc {
  fill: none;
  stroke: #7cffb2;
  stroke-width: 9;
  stroke-linecap: round;
  stroke-dasharray: 263.9;
  stroke-dashoffset: 0;
}

#timerText {
  position: relative;
  z-index: 1;
  font-size: 26px;
  font-weight: 900;
  color: #ffffff;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}

/* ---------- Endbildschirm im Spielfeld ---------- */
#endScreen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  background: rgba(4, 7, 18, 0.78);
  backdrop-filter: blur(5px);
  z-index: 70;
  opacity: 0;
  animation: endFadeIn 0.5s ease forwards;
}

@keyframes endFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.end-score {
  display: flex;
  align-items: baseline;
  gap: 16px;
  color: #ffd166;
}

.end-score #endScore {
  font-size: 96px;
  font-weight: 900;
  text-shadow: 0 0 30px rgba(255, 209, 102, 0.6);
}

.end-unit {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: 2px;
  color: #cdd8f5;
}

.end-restart {
  background: linear-gradient(135deg, #3b5bff, #7b2ff7);
  border: none;
  color: #ffffff;
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 2px;
  padding: 14px 40px;
  border-radius: 999px;
  box-shadow: 0 0 24px rgba(90, 110, 255, 0.6);
  transition: transform 0.15s ease;
}

.end-restart:hover {
  transform: scale(1.05);
}

/* ---------- Ladefehler ---------- */
.load-error {
  color: #ff6b81;
  font-weight: 700;
  margin: 10px 0 0;
  font-size: 15px;
}

/* ---------- Schwierigkeits-Slider ---------- */
.difficulty {
  margin: 14px 0 6px;
}

.difficulty-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.difficulty-head label {
  font-size: 14px;
  letter-spacing: 2px;
  color: #9fb0d8;
  font-weight: 700;
}

.difficulty-names {
  display: flex;
  gap: 14px;
}

.diff-name {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #6b7aa8;
  transition: color 0.15s ease;
}

.diff-name.active {
  color: #e7a259;
  text-shadow: 0 0 12px rgba(231, 162, 89, 0.45);
}

#difficulty {
  width: 100%;
  accent-color: #e7a259;
  cursor: pointer;
}

.difficulty-desc {
  margin: 8px 0 0;
  font-size: 13px;
  line-height: 1.45;
  color: #9fb0d8;
  text-align: center;
  min-height: 36px;
}

/* ---------- Sprachflags & Sprach-Auswahl ---------- */
.lang-flags {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 44px 0 14px;
}

.flag-btn {
  position: relative;
  background: rgba(20, 30, 60, 0.6);
  border: 2px solid rgba(120, 150, 255, 0.25);
  border-radius: 12px;
  width: 52px;
  height: 44px;
  font-size: 26px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease;
}

.flag-btn img {
  height: 34px;
  width: auto;
}

.flag-btn:hover {
  transform: translateY(-2px);
  border-color: rgba(140, 165, 255, 0.6);
}

/* sofortiger Tooltip beim Hovern (kein nativer title-Delay) */
.flag-btn::after {
  z-index: 50;
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: #05070f;
  border: 1px solid rgba(120, 150, 255, 0.45);
  color: #ffffff;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.4px;
  padding: 5px 11px;
  border-radius: 8px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
}

.flag-btn:hover::after,
.flag-btn:focus-visible::after {
  opacity: 1;
}

.flag-btn.selected {
  border-color: #e7a259;
  box-shadow: 0 0 16px rgba(231, 162, 89, 0.5);
  transform: scale(1.08);
}

.flag-btn.disabled {
  filter: grayscale(1);
  cursor: not-allowed;
}

.flag-btn.disabled:hover {
  transform: none;
  border-color: rgba(120, 150, 255, 0.25);
  box-shadow: none;
}

/* ---------- Schwierigkeit „mittel" & „schwer": weiße Tafel, schwarze Linien ---------- */
#game[data-difficulty="mittel"], #game[data-difficulty="schwer"] {
  background:
    repeating-linear-gradient(
      to bottom,
      transparent 0px,
      transparent 38px,
      rgba(0, 0, 0, 0.25) 38px,
      rgba(0, 0, 0, 0.25) 40px
    ),
    linear-gradient(160deg, #ffffff 0%, #f6f3ec 60%, #ede9df 100%);
}

#game[data-difficulty="mittel"]::after, #game[data-difficulty="schwer"]::after {
  border-color: rgba(0, 0, 0, 0.35);
}

/* bunte Buchstaben: Glow der Wortarten abschalten, Farbe kommt vom Inline-Style */
#game[data-difficulty="mittel"] .word, #game[data-difficulty="schwer"] .word {
  text-shadow: none;
}

/* Punktezahlen auf weißer Tafel lesbar halten */
#game[data-difficulty="mittel"] .floater, #game[data-difficulty="schwer"] .floater {
  text-shadow: 0 1px 5px rgba(0, 0, 0, 0.6);
}
