* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', Tahoma, sans-serif;
  background: linear-gradient(135deg, #1e293b, #334155);
  color: #f1f5f9;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 24px;
}

.app { width: 100%; max-width: 780px; }

header { text-align: center; margin-bottom: 24px; }
h1 { font-size: 2.2rem; }
.subtitle { color: #94a3b8; margin-top: 6px; }

.panel {
  background: rgba(255,255,255,0.06);
  border-radius: 16px;
  padding: 28px;
  backdrop-filter: blur(8px);
  box-shadow: 0 10px 40px rgba(0,0,0,0.35);
}

.hidden { display: none !important; }

.modes { display: flex; gap: 14px; flex-wrap: wrap; margin: 18px 0; }

.mode-btn, button {
  cursor: pointer;
  border: none;
  border-radius: 10px;
  padding: 14px 20px;
  font-size: 1rem;
  font-weight: 600;
  background: #6366f1;
  color: white;
  transition: transform .15s, background .2s;
}
.mode-btn:hover, button:hover { background: #818cf8; transform: translateY(-2px); }

input {
  padding: 12px;
  border-radius: 8px;
  border: 1px solid #475569;
  background: #0f172a;
  color: #f1f5f9;
  font-size: 1rem;
  margin-right: 8px;
}

#teacherInput, #joinBox { margin-top: 16px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* Spielbereich */
.status-bar {
  display: flex;
  justify-content: space-between;
  font-size: .95rem;
  color: #cbd5e1;
  margin-bottom: 12px;
}

.stage { position: relative; display: flex; justify-content: center; }

#gallows { width: 240px; height: 260px; }
.beam, .rope { stroke: #94a3b8; stroke-width: 6; stroke-linecap: round; }
.part { stroke: #f87171; stroke-width: 6; stroke-linecap: round; fill: none; opacity: 0; transition: opacity .4s ease; }
.eye, .mouth { opacity: 0; transition: opacity .4s ease; }
.eye { fill: #f87171; }
.mouth { stroke: #f87171; stroke-width: 3; fill: none; }
.part.visible, .eye.visible, .mouth.visible { opacity: 1; }

/* Wackel-Animation beim Fehler */
@keyframes shake {
  0%,100% { transform: translateX(0); }
  25% { transform: translateX(-6px) rotate(-2deg); }
  75% { transform: translateX(6px) rotate(2deg); }
}
.shake { animation: shake .4s; }

.speech-bubble {
  position: absolute;
  top: 10px;
  right: 20px;
  background: #facc15;
  color: #1e293b;
  padding: 8px 14px;
  border-radius: 14px;
  font-weight: 700;
  font-size: .9rem;
  opacity: 0;
  transform: scale(.6);
  transition: all .3s;
  max-width: 160px;
}
.speech-bubble.show { opacity: 1; transform: scale(1); }

.word {
  text-align: center;
  font-size: 2.2rem;
  letter-spacing: 10px;
  font-family: monospace;
  margin: 22px 0 10px;
  min-height: 44px;
}

.wrong { text-align: center; color: #f87171; font-weight: 700; min-height: 26px; }

.keyboard {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(46px, 1fr));
  gap: 8px;
  margin: 20px 0;
}

.key {
  padding: 12px 0;
  border-radius: 8px;
  background: #475569;
  color: white;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  transition: background .2s;
}
.key:hover { background: #64748b; }
.key.correct { background: #22c55e; }
.key.wrong { background: #ef4444; }
.key:disabled { cursor: not-allowed; opacity: .7; }

.scoreboard { display: flex; gap: 16px; justify-content: center; margin-top: 12px; }
.score-card {
  background: #0f172a;
  border-radius: 10px;
  padding: 10px 18px;
  text-align: center;
}
.score-card.active { outline: 2px solid #6366f1; }
.score-card .name { font-size: .85rem; color: #94a3b8; }
.score-card .pts { font-size: 1.4rem; font-weight: 700; }

.result { text-align: center; font-size: 1.4rem; font-weight: 700; margin: 16px 0; }
.result.win { color: #22c55e; }
.result.lose { color: #f87171; }

#restartBtn { display: block; margin: 12px auto 0; }

.back-btn {
  background: transparent;
  border: 1px solid #64748b;
  color: #cbd5e1;
  padding: 6px 14px;
  font-size: .85rem;
  font-weight: 600;
  border-radius: 8px;
}

.back-btn:hover { background: #475569; color: white; transform: none; }

.solve-box {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin: 8px 0 20px;
}

.solve-box input {
  width: 220px;
  text-transform: uppercase;
  letter-spacing: 2px;
  text-align: center;
}

.solve-box input:focus { outline: 2px solid #6366f1; }

.solve-box.hidden { display: none !important; }