@font-face {
  font-family: 'GoetheFFClan';
  src: url('fonts/GoetheFFClan-Book.ttf') format('truetype');
  font-weight: normal;
}
@font-face {
  font-family: 'GoetheFFClan';
  src: url('fonts/GoetheFFClan-Bold.ttf') format('truetype');
  font-weight: bold;
}

:root {
  --goethe-green: #a2c617;
  --dark: #101312;
  --panel: rgba(12, 16, 14, 0.88);
}

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

body {
  background: var(--dark);
  font-family: 'GoetheFFClan', 'Helvetica Neue', Arial, sans-serif;
  color: #fff;
  overflow: hidden;
}

#stage { position: fixed; inset: 0; }

#video { display: none; }

#canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#topbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 24px;
  background: linear-gradient(rgba(0,0,0,0.55), transparent);
  z-index: 5;
}

#brand {
  font-weight: bold;
  letter-spacing: 3px;
  font-size: 20px;
  color: var(--goethe-green);
}
#brand span {
  color: #fff;
  font-weight: normal;
  letter-spacing: 1px;
  font-size: 14px;
  margin-left: 10px;
  opacity: 0.85;
}

#topRight { display: flex; align-items: center; gap: 14px; }

#langBar { display: flex; gap: 6px; }
#langBar button {
  padding: 5px 11px;
  font-family: inherit;
  font-size: 13px;
  letter-spacing: 1px;
  border: 1px solid rgba(255,255,255,0.35);
  border-radius: 20px;
  background: rgba(0,0,0,0.3);
  color: rgba(255,255,255,0.75);
  cursor: pointer;
  transition: all 0.15s;
}
#langBar button:hover { border-color: var(--goethe-green); color: #fff; }
#langBar button.active {
  background: var(--goethe-green);
  border-color: var(--goethe-green);
  color: #101312;
  font-weight: bold;
}

#settingsBtn {
  background: none;
  border: none;
  color: rgba(255,255,255,0.6);
  font-size: 22px;
  cursor: pointer;
}
#settingsBtn:hover { color: #fff; }

#maskInfo {
  position: absolute;
  bottom: 118px;
  left: 0; right: 0;
  text-align: center;
  z-index: 5;
  text-shadow: 0 2px 8px rgba(0,0,0,0.8);
  pointer-events: none;
}
#maskName { font-size: 26px; font-weight: bold; color: var(--goethe-green); }
#maskHint { font-size: 15px; opacity: 0.9; margin-top: 4px; }

#controls {
  position: absolute;
  bottom: 34px;
  left: 0; right: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 18px;
  z-index: 5;
}

.navBtn {
  width: 56px; height: 56px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.7);
  background: rgba(0,0,0,0.35);
  color: #fff;
  font-size: 30px;
  line-height: 1;
  cursor: pointer;
  transition: all 0.15s;
}
.navBtn:hover { border-color: var(--goethe-green); color: var(--goethe-green); }

#recommendBtn {
  padding: 16px 34px;
  font-size: 20px;
  font-family: inherit;
  font-weight: bold;
  border: none;
  border-radius: 40px;
  background: var(--goethe-green);
  color: #101312;
  cursor: pointer;
  box-shadow: 0 4px 24px rgba(162,198,23,0.45);
  transition: transform 0.15s;
}
#recommendBtn:hover { transform: scale(1.05); }
#recommendBtn:disabled { opacity: 0.6; transform: none; cursor: wait; }

#bookCard {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: min(720px, 92vw);
  max-height: 86vh;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid rgba(162,198,23,0.5);
  border-radius: 18px;
  padding: 28px;
  display: flex;
  gap: 26px;
  z-index: 10;
  backdrop-filter: blur(8px);
  animation: pop 0.35s ease;
}
@keyframes pop {
  from { transform: translate(-50%, -50%) scale(0.85); opacity: 0; }
  to   { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

#bookCard.hidden, #settingsPanel.hidden { display: none; }

#closeCard {
  position: absolute;
  top: 10px; right: 16px;
  background: none;
  border: none;
  color: rgba(255,255,255,0.6);
  font-size: 28px;
  cursor: pointer;
}
#closeCard:hover { color: #fff; }

#bookCover {
  width: 200px;
  flex-shrink: 0;
  align-self: flex-start;
  border-radius: 6px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.6);
}

#bookMeta { display: flex; flex-direction: column; }
#bookTitle { font-size: 24px; font-weight: bold; line-height: 1.25; }
#bookAuthor { font-size: 16px; color: var(--goethe-green); margin-top: 6px; }
#librarianText {
  margin-top: 16px;
  font-size: 16px;
  line-height: 1.55;
  opacity: 0.95;
  min-height: 60px;
  white-space: pre-wrap;
}

#againBtn {
  margin-top: auto;
  align-self: flex-start;
  margin-top: 20px;
  padding: 10px 20px;
  font-family: inherit;
  font-size: 15px;
  border: 1px solid var(--goethe-green);
  border-radius: 24px;
  background: none;
  color: var(--goethe-green);
  cursor: pointer;
}
#againBtn:hover { background: rgba(162,198,23,0.15); }

#settingsPanel {
  position: absolute;
  top: 70px; right: 24px;
  width: 340px;
  background: var(--panel);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 12px;
  padding: 20px;
  z-index: 20;
}
#settingsPanel h3 { margin-bottom: 12px; }
#settingsPanel label { font-size: 13px; opacity: 0.85; }
#settingsPanel input {
  width: 100%;
  margin-top: 6px;
  padding: 9px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.25);
  background: rgba(255,255,255,0.08);
  color: #fff;
  font-size: 13px;
}
#settingsPanel .note { font-size: 12px; opacity: 0.6; margin-top: 10px; line-height: 1.4; }
#settingsPanel button {
  margin-top: 14px;
  padding: 9px 18px;
  border: none;
  border-radius: 6px;
  background: var(--goethe-green);
  color: #101312;
  font-family: inherit;
  font-weight: bold;
  cursor: pointer;
}

#loading {
  position: absolute;
  inset: 0;
  background: var(--dark);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 18px;
  z-index: 50;
  transition: opacity 0.5s;
}
#loading.done { opacity: 0; pointer-events: none; }
.spinner {
  width: 48px; height: 48px;
  border: 4px solid rgba(162,198,23,0.25);
  border-top-color: var(--goethe-green);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 640px) {
  #bookCard { flex-direction: column; align-items: center; text-align: center; }
  #bookCover { width: 150px; }
  #againBtn { align-self: center; }
  #brand { font-size: 15px; }
  #brand span { display: none; }
}
