/*
  ELT Lehrling Quest — dark mode.
  TeXBrain-aligned palette, system fonts. Motion is a design primitive here:
  grain, shimmer, glow-pulse, staggered mount, card-flip, typing indicator.
  Restraint is on chrome noise and color breadth, not on density.
*/

:root {
  --bg:            #0f0e0c;
  --bg-surface:    #17150f;
  --bg-card:       #141210;
  --bg-card-hi:    #1a1814;
  --bg-hover:      #201d17;
  --bg-muted:      #1c1915;
  --bg-inset:      #0a0907;

  --border:        #2b2721;
  --border-strong: #3d3830;
  --border-focus:  #d19a66;

  --text:          #f1e8d2;
  --text-secondary:#cfc3a7;
  --text-muted:    #938770;
  --text-dim:      #645b48;

  --accent:        #d19a66;
  --accent-fill:   #b15a1f;
  --accent-hover:  #e5b07c;
  --accent-dim:    rgba(209, 154, 102, 0.1);
  --accent-soft:   rgba(209, 154, 102, 0.22);
  --accent-glow:   rgba(209, 154, 102, 0.35);
  --accent-glow-strong: rgba(209, 154, 102, 0.55);

  --success:       #7eb04a;
  --success-bg:    rgba(126, 176, 74, 0.09);
  --success-glow:  rgba(126, 176, 74, 0.3);
  --warning:       #d9a94c;
  --error:         #d16855;
  --error-bg:      rgba(209, 104, 85, 0.09);
  --error-glow:    rgba(209, 104, 85, 0.3);

  --font-ui:    system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono:  ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --font-brand: ui-serif, Georgia, Cambria, "Times New Roman", serif;

  --radius-sm: 2px;
  --radius-md: 4px;
  --radius-lg: 6px;

  --shadow-sm: 0 1px 0 rgba(0,0,0,0.5), 0 2px 8px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 18px rgba(0,0,0,0.45);

  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);

  color-scheme: dark;
}

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

html, body {
  font-family: var(--font-ui);
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: clip;
  max-width: 100%;
}

.qtext, .hero-title, .hero-desc, .notice-body, .notice-meta,
.verdict, .verdict-fb, .feedback, .reveal-body,
.window.legal p, .window.legal li, .topic-title, .form-row small {
  overflow-wrap: break-word;
  word-break: break-word;
}

.form-row input { min-width: 0; }

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(1100px 600px at 50% -10%, rgba(209, 154, 102, 0.065), transparent 60%),
    radial-gradient(900px 500px at 90% 110%, rgba(209, 154, 102, 0.04), transparent 60%),
    var(--bg);
  position: relative;
}

#app { flex: 1 0 auto; }

body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image: url("data:image/svg+xml;utf8,<svg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.82 0 0 0 0 0.60 0 0 0 0 0.40 0 0 0 0.4 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  opacity: 0.05;
  mix-blend-mode: overlay;
}

body > * { position: relative; z-index: 1; }

a { color: var(--accent); text-decoration: none; transition: color 0.14s; }
a:hover { color: var(--accent-hover); }

button {
  font: inherit;
  color: inherit;
  background: transparent;
  border: none;
  cursor: pointer;
}

::selection { background: var(--accent-soft); color: var(--text); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-inset); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* ---------- keyframes ---------- */

@keyframes fade-in  { from { opacity: 0; } to { opacity: 1; } }
@keyframes slide-up { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slide-up-stagger {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes glow-pulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--accent-glow); }
  50%      { box-shadow: 0 0 0 6px rgba(209,154,102,0); }
}
@keyframes shimmer {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(240%); }
}
@keyframes blink    { 50% { opacity: 0.15; } }
@keyframes flip-in {
  0%   { opacity: 0; transform: perspective(800px) rotateX(-28deg); }
  100% { opacity: 1; transform: perspective(800px) rotateX(0); }
}
@keyframes dot-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.3; }
  40%           { transform: translateY(-5px); opacity: 1; }
}
@keyframes count-up { from { transform: translateY(4px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes pop-in   { 0% { transform: scale(0.94); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }

.slide-in { animation: slide-up 0.22s var(--ease); }

.stagger > * {
  opacity: 0;
  animation: slide-up-stagger 0.32s var(--ease) forwards;
  animation-delay: calc(var(--i, 0) * 40ms + 40ms);
}

/* ---------- topbar ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  height: 56px;
  padding: 0 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(23, 21, 15, 0.88);
  backdrop-filter: blur(10px) saturate(120%);
  -webkit-backdrop-filter: blur(10px) saturate(120%);
  position: sticky;
  top: 0;
  z-index: 30;
}
.topbar::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent-soft) 30%, var(--accent-soft) 70%, transparent);
  opacity: 0.65;
}

.brand { display: flex; align-items: baseline; gap: 10px; color: var(--text); }
.brand-name {
  font-family: var(--font-brand);
  font-style: italic;
  font-size: 22px;
  letter-spacing: -0.01em;
  color: var(--accent);
  text-shadow: 0 0 18px var(--accent-glow);
}
.brand-sub {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: lowercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.topnav { display: flex; gap: 22px; font-family: var(--font-mono); font-size: 11px; }
.topnav a {
  color: var(--text-secondary);
  padding: 4px 0;
  letter-spacing: 0.04em;
  border-bottom: 1px solid transparent;
  transition: color 0.14s, border-color 0.14s, text-shadow 0.14s;
}
.topnav a:hover { color: var(--accent); }
.topnav a.active {
  color: var(--text);
  border-bottom-color: var(--accent);
  text-shadow: 0 0 12px var(--accent-glow);
}

/* ---------- layout ---------- */

#app {
  max-width: 860px;
  margin: 0 auto;
  padding: 84px 28px 96px;
  animation: fade-in 0.24s var(--ease);
  position: relative;
  z-index: 2;
}

.site-footer { position: relative; z-index: 2; }

/* ---------- hero ---------- */

.hero { margin-bottom: 36px; }
.hero.compact { margin-bottom: 22px; }
.hero.compact .hero-title { font-size: 30px; margin-bottom: 4px; }

.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: lowercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 14px;
}
.hero-eyebrow::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent-glow-strong);
  animation: blink 1.8s ease infinite;
}

.hero-title {
  font-size: 44px;
  font-weight: 700;
  line-height: 1.04;
  letter-spacing: -0.032em;
  color: var(--text);
  margin-bottom: 16px;
}
.hero-accent {
  font-family: var(--font-brand);
  font-style: italic;
  font-weight: 400;
  color: var(--accent);
  text-shadow: 0 0 26px var(--accent-glow);
}
.cursor {
  display: inline-block;
  width: 10px;
  height: 0.9em;
  margin-left: 4px;
  background: var(--accent);
  vertical-align: -0.08em;
  animation: blink 1s steps(2) infinite;
  box-shadow: 0 0 14px var(--accent-glow);
}
.hero-desc {
  font-size: 15px;
  line-height: 1.65;
  color: var(--text-secondary);
  max-width: 62ch;
}

/* ---------- stat tiles ---------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(135px, 1fr));
  gap: 10px;
  margin-bottom: 42px;
}
.stat-tile {
  position: relative;
  padding: 14px 14px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color 0.18s, transform 0.18s var(--ease), background-color 0.18s;
}
.stat-tile::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent-soft), transparent);
  opacity: 0.7;
}
.stat-tile:hover {
  border-color: var(--border-strong);
  background: var(--bg-card-hi);
  transform: translateY(-2px);
}
.stat-num {
  display: block;
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.025em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  animation: count-up 0.45s var(--ease);
}
.stat-label {
  display: block;
  margin-top: 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

/* ---------- section heads ---------- */

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 14px;
}
.section-head h2 {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  font-weight: 500;
}
.section-head h2::before { content: '// '; color: var(--text-dim); }
.section-head .tools { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); }
.section-head .tools a { margin-left: 14px; letter-spacing: 0.03em; }

/* ---------- topic grid ---------- */

.topic-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 36px;
}
.topic-card {
  position: relative;
  display: block;
  text-align: left;
  padding: 15px 16px 15px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  width: 100%;
  color: var(--text);
  cursor: pointer;
  overflow: hidden;
  transition: border-color 0.18s, transform 0.18s var(--ease), background-color 0.18s, box-shadow 0.18s;
}
.topic-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 2px;
  background: var(--accent);
  opacity: 0;
  transition: opacity 0.18s;
}
.topic-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
  background: var(--bg-card-hi);
  box-shadow: var(--shadow-md);
}
.topic-card:hover::before { opacity: 1; }
.topic-card:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 1px; }
.topic-card.static { cursor: default; }
.topic-card.static:hover { transform: none; box-shadow: none; background: var(--bg-card); border-color: var(--border); }
.topic-card.static::before { display: none; }

.topic-title {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 7px;
}
.topic-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: lowercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}
.topic-meta .sep { color: var(--text-dim); }

/* ---------- pills ---------- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  white-space: nowrap;
}
.pill-accent {
  color: var(--accent);
  background: var(--accent-dim);
  border-color: var(--accent-soft);
  animation: glow-pulse 2.2s ease-in-out infinite;
}
.pill-success { color: var(--success); background: var(--success-bg); border-color: rgba(126, 176, 74, 0.4); }
.pill-error   { color: var(--error);   background: var(--error-bg);   border-color: rgba(209, 104, 85, 0.45); }

/* ---------- window chrome ---------- */

.window {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}
.window + .window { margin-top: 18px; }
.window::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(234, 222, 198, 0.12), transparent);
  pointer-events: none;
  z-index: 1;
}
.window-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 32px;
  padding: 0 14px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
}
.window-dots { display: flex; gap: 6px; }
.window-dots .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--border-strong);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.3);
}
.window-dots .dot:nth-child(1) { background: #6a4639; }
.window-dots .dot:nth-child(2) { background: #6a5939; }
.window-dots .dot:nth-child(3) { background: #3c5a39; }
.window-title { font-family: var(--font-mono); font-size: 11px; color: var(--text-secondary); }
.window-label {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}
.window-body { padding: 30px 32px; }

/* ---------- progress row ---------- */

.progress-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.progress-bar {
  flex: 1;
  min-width: 140px;
  height: 4px;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: 2px;
  position: relative;
  overflow: hidden;
}
.progress-fill {
  position: absolute;
  top: 0; left: 0; bottom: 0;
  background: linear-gradient(90deg, var(--accent-fill), var(--accent));
  box-shadow: 0 0 14px var(--accent-glow-strong);
  width: 0%;
  transition: width 0.45s var(--ease);
}
.progress-fill::after {
  content: '';
  position: absolute;
  top: 0; bottom: 0;
  left: 0;
  width: 40%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
  animation: shimmer 2.4s ease-in-out infinite;
}

/* ---------- question ---------- */

.qmeta {
  display: flex;
  gap: 10px;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: lowercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 14px;
}
.qmeta .sep { color: var(--text-dim); }

.qtext {
  font-size: 23px;
  font-weight: 600;
  line-height: 1.32;
  letter-spacing: -0.015em;
  color: var(--text);
  margin-bottom: 24px;
}

/* ---------- multiple choice ---------- */

.mc-options { list-style: none; display: flex; flex-direction: column; gap: 8px; }

.mc-option {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  text-align: left;
  padding: 13px 14px;
  background: var(--bg-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  transition: border-color 0.18s, background-color 0.18s, transform 0.14s var(--ease), box-shadow 0.18s;
}
.mc-option:hover:not(:disabled) {
  border-color: var(--accent-soft);
  background: var(--bg-hover);
  transform: translateX(3px);
  box-shadow: inset 2px 0 0 var(--accent);
}
.mc-option:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 1px; }
.mc-option:disabled { cursor: default; transform: none; }

.mc-letter {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: color 0.18s, border-color 0.18s, background-color 0.18s, box-shadow 0.18s;
}
.mc-option:hover:not(:disabled) .mc-letter {
  color: var(--accent);
  border-color: var(--accent-soft);
  box-shadow: 0 0 10px var(--accent-glow);
}
.mc-option.correct {
  border-color: var(--success);
  background: var(--success-bg);
  box-shadow: 0 0 0 1px var(--success), 0 0 28px var(--success-glow);
  animation: pop-in 0.2s var(--ease);
}
.mc-option.correct .mc-letter {
  color: var(--success);
  border-color: var(--success);
  background: rgba(126,176,74,0.1);
  box-shadow: 0 0 12px var(--success-glow);
}
.mc-option.wrong {
  border-color: var(--error);
  background: var(--error-bg);
  box-shadow: 0 0 0 1px var(--error), 0 0 28px var(--error-glow);
  animation: pop-in 0.2s var(--ease);
}
.mc-option.wrong .mc-letter {
  color: var(--error);
  border-color: var(--error);
  background: rgba(209,104,85,0.1);
  box-shadow: 0 0 12px var(--error-glow);
}

/* ---------- feedback (MC) ---------- */

.feedback {
  margin-top: 22px;
  padding: 15px 18px;
  border-left: 2px solid var(--accent);
  background: var(--bg-surface);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-secondary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  animation: slide-up 0.22s var(--ease);
}
.feedback-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}
.feedback-head strong { color: var(--text); font-weight: 600; }
.feedback.correct { border-left-color: var(--success); box-shadow: inset 4px 0 28px rgba(126,176,74,0.05); }
.feedback.correct .feedback-head strong { color: var(--success); }
.feedback.wrong   { border-left-color: var(--error);   box-shadow: inset 4px 0 28px rgba(209,104,85,0.05); }
.feedback.wrong   .feedback-head strong { color: var(--error); }

/* ---------- textarea ---------- */

.answer-input {
  display: block;
  width: 100%;
  margin-bottom: 10px;
  padding: 13px 14px;
  font-family: var(--font-ui);
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  resize: vertical;
  min-height: 86px;
  transition: border-color 0.18s, box-shadow 0.18s, background-color 0.18s;
  caret-color: var(--accent);
}
.answer-input:focus {
  outline: none;
  border-color: var(--accent-soft);
  box-shadow: 0 0 0 3px var(--accent-dim), 0 0 24px var(--accent-glow);
  background: var(--bg-card);
}
.answer-input:disabled { opacity: 0.55; }
.answer-input::placeholder { color: var(--text-dim); }

/* ---------- form ---------- */

.form { display: flex; flex-direction: column; gap: 18px; }
.form-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}
.form-row input {
  font-family: var(--font-ui);
  font-size: 14px;
  text-transform: none;
  letter-spacing: normal;
  color: var(--text);
  padding: 10px 12px;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color 0.18s, box-shadow 0.18s;
}
.form-row input:focus {
  outline: none;
  border-color: var(--accent-soft);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.form-row small {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: none;
  letter-spacing: normal;
  line-height: 1.45;
}

/* ---------- verdict (grader) ---------- */

.verdict {
  margin-top: 18px;
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-left-width: 2px;
  border-left-color: var(--accent);
  background: var(--bg-card);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-secondary);
  border-radius: var(--radius-md);
  animation: flip-in 0.45s var(--ease);
  transform-origin: top center;
}
.verdict.correct { border-left-color: var(--success); box-shadow: 0 0 28px rgba(126,176,74,0.12), var(--shadow-sm); }
.verdict.partial { border-left-color: var(--warning); box-shadow: 0 0 28px rgba(217,169,76,0.12), var(--shadow-sm); }
.verdict.wrong   { border-left-color: var(--error);   box-shadow: 0 0 28px rgba(209,104,85,0.12), var(--shadow-sm); }

.verdict-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.verdict-score {
  font-family: var(--font-mono);
  font-size: 16px;
  letter-spacing: 0.2em;
  color: var(--accent);
  text-shadow: 0 0 12px var(--accent-glow);
}
.verdict.correct .verdict-score { color: var(--success); text-shadow: 0 0 14px var(--success-glow); }
.verdict.wrong   .verdict-score { color: var(--error);   text-shadow: 0 0 14px var(--error-glow); }
.verdict-fb { color: var(--text); margin: 4px 0 10px; }
.verdict-kw { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 10px 0; }
.verdict-gate { margin-top: 4px; }

.verdict-explanation {
  margin: 14px 0 10px;
  padding: 12px 14px;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-left: 2px solid var(--accent-soft);
  border-radius: var(--radius-sm);
}
.verdict-explanation .reveal-label { margin-bottom: 6px; }
.explanation-body {
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--text);
  overflow-wrap: break-word;
}

/* ---------- reveal ---------- */

.reveal {
  margin-top: 12px;
  padding: 12px 14px;
  background: var(--bg-inset);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
}
.reveal-label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 6px;
  cursor: pointer;
  user-select: none;
}
details.reveal > summary { list-style: none; }
details.reveal > summary::-webkit-details-marker { display: none; }
details.reveal > summary::before { content: '▸ '; color: var(--text-muted); }
details.reveal[open] > summary::before { content: '▾ '; }
.reveal-body {
  white-space: pre-wrap;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  margin-top: 8px;
}
.reveal-kw {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

/* ---------- typing indicator ---------- */

.typing {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  margin-top: 18px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 0.04em;
  animation: slide-up 0.2s var(--ease);
}
.typing-dots { display: inline-flex; gap: 3px; margin-left: 4px; }
.typing-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent-glow-strong);
  animation: dot-bounce 1s ease-in-out infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.typing-dots span:nth-child(3) { animation-delay: 0.3s; }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 20px;
  background: var(--accent);
  color: #1a1108;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: background 0.18s, transform 0.12s var(--ease), box-shadow 0.18s, color 0.18s;
}
.btn:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 0 28px var(--accent-glow-strong);
}
.btn:active { transform: translateY(0); }
.btn:disabled { background: var(--bg-surface); color: var(--text-muted); cursor: default; transform: none; box-shadow: none; }

.btn-ghost {
  padding: 10px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  font-size: 13px;
  transition: border-color 0.18s, background-color 0.18s, color 0.18s;
}
.btn-ghost:hover {
  border-color: var(--accent-soft);
  background: var(--bg-hover);
  color: var(--accent);
}

.btn-quiet {
  color: var(--text-secondary);
  padding: 7px 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: lowercase;
  transition: color 0.18s;
}
.btn-quiet:hover { color: var(--accent); }

.btn-row { display: flex; align-items: center; gap: 12px; margin-top: 20px; flex-wrap: wrap; }

/* ---------- keyboard hints ---------- */

.kbd-hints {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 28px;
  padding-top: 18px;
  border-top: 1px dashed var(--border);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
}
.kbd-hint { display: inline-flex; align-items: center; gap: 6px; }
.kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text);
  line-height: 1;
  box-shadow: 0 1px 0 rgba(0,0,0,0.4);
}

/* ---------- notice banner (home) ---------- */

.notice {
  position: relative;
  padding: 14px 18px 16px;
  margin: 0 0 36px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-left: 2px solid var(--accent);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
}
.notice-tag {
  display: inline-block;
  margin-bottom: 10px;
  padding: 2px 8px;
  font-family: var(--font-mono);
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  background: var(--accent-dim);
  border: 1px solid var(--accent-soft);
  border-radius: var(--radius-sm);
}
.notice-body {
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.notice-meta {
  font-size: 12px;
  line-height: 1.55;
  color: var(--text-muted);
}
.notice-meta a { color: var(--accent); }
.notice a { border-bottom: 1px dotted var(--accent-soft); }
.notice a:hover { border-bottom-color: var(--accent); }

/* ---------- legal pages ---------- */

.window.legal .window-body {
  padding: 34px 38px 38px;
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--text-secondary);
}
.window.legal h1 {
  font-family: var(--font-brand);
  font-style: italic;
  font-size: 30px;
  font-weight: 400;
  letter-spacing: -0.02em;
  color: var(--text);
  margin-bottom: 8px;
}
.window.legal .legal-sub {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: lowercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 28px;
  padding-bottom: 18px;
  border-bottom: 1px dashed var(--border);
}
.window.legal h2 {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin: 32px 0 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.window.legal h2:first-of-type { margin-top: 0; }
.window.legal h3 {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  margin: 18px 0 6px;
}
.window.legal p { margin: 0 0 12px; }
.window.legal p:last-child { margin-bottom: 0; }
.window.legal ul, .window.legal ol {
  margin: 0 0 14px 20px;
  padding: 0;
}
.window.legal li { margin-bottom: 6px; }
.window.legal strong { color: var(--text); font-weight: 600; }
.window.legal code {
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 1px 6px;
  color: var(--accent);
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.window.legal .legal-placeholder {
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 1px 6px;
  color: var(--warning);
  background: rgba(217, 169, 76, 0.07);
  border: 1px dashed rgba(217, 169, 76, 0.4);
  border-radius: var(--radius-sm);
}
.window.legal address {
  font-style: normal;
  padding: 10px 14px;
  margin: 8px 0 14px;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-left: 2px solid var(--accent-soft);
  border-radius: var(--radius-sm);
  color: var(--text);
  line-height: 1.65;
}
.window.legal .legal-meta {
  margin-top: 32px;
  padding-top: 16px;
  border-top: 1px dashed var(--border);
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: lowercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}

/* ---------- site footer ---------- */

.site-footer {
  flex-shrink: 0;
  margin-top: 40px;
  padding: 22px 28px 26px;
  border-top: 1px solid var(--border);
  background: rgba(23, 21, 15, 0.5);
}
.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}
.footer-meta {
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: lowercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  line-height: 1.55;
}
.footer-nav {
  display: flex;
  gap: 18px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
}
.footer-nav a {
  color: var(--text-secondary);
  transition: color 0.14s;
}
.footer-nav a:hover { color: var(--accent); }

.footer-sig {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  white-space: nowrap;
}
.footer-sig a {
  color: var(--text-secondary);
  transition: color 0.14s;
}
.footer-sig a:hover { color: var(--accent); }
.footer-heart {
  color: #d9536b;
  display: inline-block;
  animation: footer-heart-beat 2.4s ease-in-out infinite;
  transform-origin: center;
}
@keyframes footer-heart-beat {
  0%, 100% { transform: scale(1); }
  12%      { transform: scale(1.18); }
  24%      { transform: scale(1); }
  36%      { transform: scale(1.12); }
  48%      { transform: scale(1); }
}

/* ---------- status ---------- */

.empty, .error {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  padding: 72px 0;
  line-height: 1.7;
}
.empty a { display: inline-block; margin-top: 12px; }
.error { color: var(--error); }
.muted { color: var(--text-muted); font-size: 12px; }

/* ---------- responsive ---------- */

@media (max-width: 720px) {
  .topbar { padding: 0 18px; height: 50px; }
  #app { padding: 60px 18px 80px; }
  .hero-title { font-size: 32px; }
  .hero-desc { font-size: 14px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .topic-grid { grid-template-columns: 1fr; }
  .window-body { padding: 22px 20px; }
  .window.legal .window-body { padding: 24px 22px 28px; }
  .window.legal h1 { font-size: 24px; }
  .qtext { font-size: 19px; }
  .topnav { gap: 14px; }
  .kbd-hints { gap: 12px; row-gap: 8px; }
  .site-footer { padding: 18px 18px 22px; }
  .footer-inner { flex-direction: column; align-items: flex-start; gap: 10px; }
  .notice { padding: 13px 14px 14px; margin-bottom: 28px; }
  .verdict { padding: 14px 15px; }
  .mc-option { padding: 11px 12px; gap: 11px; font-size: 13.5px; }
  .mc-letter { width: 24px; height: 24px; }
  .progress-row { gap: 8px; }
  .section-head { flex-direction: column; align-items: flex-start; gap: 4px; }
  .section-head .tools a { margin-left: 0; margin-right: 12px; }
}

@media (max-width: 540px) {
  .topbar { padding: 0 14px; height: 48px; }
  .brand-sub { display: none; }
  .brand-name { font-size: 20px; }
  .topnav { gap: 14px; font-size: 10.5px; }
  .topnav a { letter-spacing: 0.02em; }
  #app { padding: 48px 14px 64px; }
  .hero { margin-bottom: 28px; }
  .hero-title { font-size: 28px; }
  .hero.compact .hero-title { font-size: 24px; }
  .hero-desc { font-size: 13.5px; line-height: 1.6; }
  .hero-eyebrow { font-size: 10.5px; margin-bottom: 10px; }
  .stat-tile { padding: 12px 12px 10px; }
  .stat-num { font-size: 22px; }
  .stat-label { font-size: 9.5px; }
  .window-bar { padding: 0 12px; height: 30px; gap: 10px; }
  .window-title { font-size: 10.5px; }
  .window-label { display: none; }
  .window-body { padding: 18px 16px; }
  .window.legal .window-body { padding: 20px 16px 24px; font-size: 13px; }
  .window.legal h1 { font-size: 22px; }
  .window.legal h2 { font-size: 12px; margin-top: 26px; }
  .window.legal h3 { font-size: 13px; }
  .window.legal ul, .window.legal ol { margin-left: 18px; }
  .qtext { font-size: 17.5px; margin-bottom: 18px; }
  .qmeta { flex-wrap: wrap; font-size: 10.5px; }
  .verdict { padding: 13px 14px; font-size: 13px; }
  .verdict-head { gap: 8px; }
  .verdict-score { font-size: 14px; letter-spacing: 0.15em; }
  .kbd-hints { gap: 10px; font-size: 10.5px; padding-top: 14px; margin-top: 20px; }
  .btn { padding: 9px 16px; font-size: 12.5px; }
  .btn-ghost { padding: 9px 14px; font-size: 12.5px; }
  .form { gap: 14px; }
  .form-row input { font-size: 13.5px; padding: 9px 11px; }
  .answer-input { font-size: 14px; padding: 11px 12px; }
  .site-footer { padding: 16px 14px 20px; margin-top: 28px; }
  .footer-inner { max-width: none; }
  .footer-meta { font-size: 10px; }
  .footer-nav { gap: 14px; font-size: 10.5px; }
  .notice-tag { font-size: 9px; }
  .notice-body { font-size: 13px; }
  .notice-meta { font-size: 11.5px; }
}

@media (max-width: 380px) {
  .topnav { gap: 10px; }
  .stat-grid { grid-template-columns: 1fr; }
  .hero-title { font-size: 26px; }
  .qtext { font-size: 16.5px; }
  .mc-option { padding: 10px 11px; font-size: 13px; }
}

/* ============================================================
   GAME LAYER — Werkstatt, HUD, Charaktere, Rang-Overlay
   ============================================================ */

/* ---------- workshop stage (persistent background) ---------- */

.workshop-stage {
  position: fixed;
  top: 56px;
  left: 0; right: 0; bottom: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
  contain: strict;
}
.workshop-stage > * { position: absolute; pointer-events: none; }

@keyframes lamp-flicker {
  0%, 100% { opacity: 1; }
  92%      { opacity: 1; }
  93%      { opacity: 0.7; }
  94%      { opacity: 1; }
}
@keyframes lamp-flash {
  0%   { filter: brightness(1) drop-shadow(0 0 14px rgba(209,154,102,0.5)); }
  35%  { filter: brightness(1.7) drop-shadow(0 0 36px rgba(255,216,158,0.85)); }
  100% { filter: brightness(1) drop-shadow(0 0 14px rgba(209,154,102,0.5)); }
}
@keyframes spark-fly {
  0%   { transform: translate(var(--from-x, 0), var(--from-y, 0)) scale(0.8); opacity: 0; }
  20%  { opacity: 1; }
  100% { transform: translate(var(--to-x, 0), var(--to-y, 0)) scale(0.4); opacity: 0; }
}

/* --- ceiling beam + lamps --- */

.ws-ceiling {
  top: 0; left: 0; right: 0;
  height: 210px;
}
.ws-beam {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 18px;
  background:
    linear-gradient(180deg, #1a1814 0%, #14110d 60%, #0a0907 100%);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 8px 24px rgba(0,0,0,0.55), inset 0 -1px 0 #0a0907;
}
.ws-beam::after {
  content: '';
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(234, 222, 198, 0.08), transparent);
}

.ws-lamp {
  position: absolute;
  top: 14px;
  width: 130px;
  height: 190px;
  filter: drop-shadow(0 6px 18px rgba(0,0,0,0.55));
  overflow: visible;
  opacity: 0.45;
  transition: opacity 0.5s var(--ease);
}
.ws-lamp.lit { opacity: 0.85; }
.ws-lamp.flash { opacity: 1; }
/* Lamps near the content column (2, 3, 4) recede further so titles stay readable. */
.ws-lamp[data-lamp="1"] { left: 4%; }
.ws-lamp[data-lamp="2"] { left: 24%; opacity: 0.32; }
.ws-lamp[data-lamp="2"].lit { opacity: 0.7; }
.ws-lamp[data-lamp="3"] { left: 50%; transform: translateX(-50%); opacity: 0.22; }
.ws-lamp[data-lamp="3"].lit { opacity: 0.55; }
.ws-lamp[data-lamp="3"].flash { opacity: 0.9; }
.ws-lamp[data-lamp="4"] { right: 24%; opacity: 0.32; }
.ws-lamp[data-lamp="4"].lit { opacity: 0.7; }
.ws-lamp[data-lamp="5"] { right: 4%; }

.ws-lamp img {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  transition: opacity 0.6s var(--ease);
}
.ws-lamp .ws-lamp-on  { opacity: 0; }
.ws-lamp .ws-lamp-off { opacity: 1; }
.ws-lamp.lit .ws-lamp-on  { opacity: 1; animation: lamp-flicker 7s ease-in-out infinite; }
.ws-lamp.lit .ws-lamp-off { opacity: 0; }
.ws-lamp.flash .ws-lamp-on { animation: lamp-flash 0.7s ease; }

/* --- side scenery --- */

.ws-poster {
  top: 230px;
  left: 28px;
  width: 320px;
  opacity: 0.55;
  filter: drop-shadow(0 8px 24px rgba(0,0,0,0.6));
}
.ws-poster img { width: 100%; height: auto; display: block; }

/* --- floor scenery --- */

.ws-workbench {
  bottom: 30px;
  left: 24px;
  width: 400px;
  opacity: 0.6;
  filter: drop-shadow(0 12px 28px rgba(0,0,0,0.7));
}
.ws-workbench img { width: 100%; height: auto; display: block; }

.ws-schaltschrank {
  bottom: 30px;
  right: 24px;
  width: 280px;
  opacity: 0.6;
  filter: drop-shadow(0 12px 28px rgba(0,0,0,0.7));
}
.ws-schaltschrank img { width: 100%; height: auto; display: block; }

.ws-floor {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 220px;
  background:
    linear-gradient(180deg,
      transparent 0%,
      rgba(0,0,0,0.18) 30%,
      rgba(0,0,0,0.55) 80%,
      rgba(0,0,0,0.7) 100%
    );
}
.ws-floor::before {
  content: '';
  position: absolute;
  top: 60px; left: 0; right: 0; bottom: 0;
  background-image:
    repeating-linear-gradient(90deg,
      transparent 0,
      transparent 78px,
      rgba(0,0,0,0.22) 78px,
      rgba(0,0,0,0.22) 80px
    ),
    repeating-linear-gradient(0deg,
      transparent 0,
      transparent 38px,
      rgba(0,0,0,0.16) 38px,
      rgba(0,0,0,0.16) 40px
    );
  opacity: 0.55;
  mask-image: linear-gradient(180deg, transparent 0%, rgba(0,0,0,0.6) 40%, rgba(0,0,0,0.95) 100%);
  -webkit-mask-image: linear-gradient(180deg, transparent 0%, rgba(0,0,0,0.6) 40%, rgba(0,0,0,0.95) 100%);
}

/* --- responsive workshop hides --- */

@media (max-width: 1500px), (max-height: 920px) {
  .ws-poster { display: none; }
}
@media (max-width: 1100px), (max-height: 720px) {
  .ws-workbench, .ws-schaltschrank { display: none; }
}
@media (max-width: 720px) {
  .workshop-stage { top: 50px; }
  .ws-lamp { width: 90px; height: 130px; top: 10px; }
  .ws-lamp[data-lamp="2"], .ws-lamp[data-lamp="4"] { display: none; }
  .ws-lamp[data-lamp="1"] { left: 8%; }
  .ws-lamp[data-lamp="5"] { right: 8%; }
  .ws-ceiling { height: 150px; }
  .ws-floor { height: 140px; }
}
@media (max-width: 380px) {
  .ws-lamp[data-lamp="1"], .ws-lamp[data-lamp="5"] { display: none; }
}

/* ---------- HUD (topbar game stats) ---------- */

.hud {
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.hud-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  color: var(--text);
  transition: background 0.18s, border-color 0.18s, color 0.18s, transform 0.14s var(--ease);
}
.hud-item img {
  width: 16px; height: 16px;
  display: block;
  filter: drop-shadow(0 0 6px var(--accent-glow));
}
.hud-item:hover {
  background: var(--bg-card);
  border-color: var(--border);
  transform: translateY(-1px);
}
.hud-val { letter-spacing: 0.02em; min-width: 12px; text-align: right; }

.hud-streak.cold .hud-val { color: var(--text-muted); }
.hud-streak.cold img { filter: grayscale(0.6) brightness(0.7); }

.hud-pulse { animation: count-up 0.4s var(--ease); }

/* tiny floating spark — fired when XP is granted */
.xp-burst {
  position: fixed;
  z-index: 60;
  width: 16px; height: 16px;
  pointer-events: none;
  background-image: url("../assets/game/ui/funke.svg");
  background-size: contain;
  background-repeat: no-repeat;
  animation: spark-fly 0.95s var(--ease) forwards;
}

/* ---------- character dialog ---------- */

.char-dialog {
  position: fixed;
  bottom: 26px;
  left: 26px;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  gap: 12px;
  max-width: min(420px, calc(100vw - 36px));
  animation: slide-up 0.32s var(--ease);
}
.char-dialog[hidden] { display: none; }

.char-portrait {
  flex-shrink: 0;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--accent);
  background: var(--bg-card);
  box-shadow: 0 0 0 4px var(--bg), 0 0 22px rgba(255,255,255,0.07), 0 0 28px var(--accent-glow), 0 12px 32px rgba(0,0,0,0.6);
  position: relative;
}
.char-portrait img {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 110%;
  height: auto;
  display: block;
}

.char-bubble {
  position: relative;
  flex: 1;
  background: var(--bg-card-hi);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 12px 16px 14px;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--text);
  box-shadow: 0 12px 32px rgba(0,0,0,0.55);
}
.char-bubble::before {
  content: '';
  position: absolute;
  left: -8px;
  bottom: 22px;
  width: 14px; height: 14px;
  background: var(--bg-card-hi);
  border-left: 1px solid var(--border-strong);
  border-bottom: 1px solid var(--border-strong);
  transform: rotate(45deg);
}
.char-name {
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  margin-bottom: 4px;
}
.char-text {
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text);
}

.char-close {
  position: absolute;
  top: -10px;
  right: -10px;
  z-index: 3;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--bg-card);
  color: var(--text-muted);
  font-size: 18px;
  line-height: 1;
  border: 1px solid var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color 0.18s, border-color 0.18s, transform 0.14s var(--ease);
}
.char-close:hover {
  color: var(--accent);
  border-color: var(--accent-soft);
  transform: scale(1.08);
}

@media (max-width: 540px) {
  .char-dialog { left: 12px; bottom: 16px; max-width: calc(100vw - 24px); }
  .char-portrait { width: 60px; height: 60px; }
  .char-bubble { font-size: 12.5px; padding: 10px 14px 12px; }
}

/* ---------- rank-up overlay ---------- */

.rank-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(10, 9, 7, 0.86);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fade-in 0.28s var(--ease);
}
.rank-overlay[hidden] { display: none; }

.rank-card {
  width: min(440px, 100%);
  background: linear-gradient(180deg, var(--bg-card-hi), var(--bg-card));
  border: 1px solid var(--accent-soft);
  border-radius: var(--radius-lg);
  padding: 32px 28px 26px;
  text-align: center;
  box-shadow: 0 0 80px var(--accent-glow), 0 30px 80px rgba(0,0,0,0.7);
  animation: pop-in 0.4s var(--ease);
}
.rank-eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: lowercase;
  letter-spacing: 0.16em;
  color: var(--accent);
  margin-bottom: 6px;
}
.rank-name {
  font-family: var(--font-brand);
  font-style: italic;
  font-size: 36px;
  line-height: 1.1;
  color: var(--text);
  margin-bottom: 18px;
  text-shadow: 0 0 24px var(--accent-glow);
}
.rank-progress-bar {
  height: 5px;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 22px;
  position: relative;
}
.rank-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-fill), var(--accent));
  box-shadow: 0 0 14px var(--accent-glow-strong);
  width: 0%;
  transition: width 1.2s var(--ease);
}
.rank-portraits {
  display: flex;
  justify-content: center;
  gap: -8px;
  margin-bottom: 18px;
}
.rank-portraits img {
  width: 78px; height: 78px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  background: var(--bg);
  box-shadow: 0 0 18px rgba(255,255,255,0.08), 0 0 24px var(--accent-glow), 0 8px 20px rgba(0,0,0,0.6);
  object-fit: cover;
  object-position: center bottom;
}
.rank-portraits img:first-child { transform: rotate(-3deg) translateX(8px); }
.rank-portraits img:last-child  { transform: rotate(3deg)  translateX(-8px); }
.rank-quote {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-secondary);
  margin-bottom: 22px;
  font-style: italic;
}
.rank-card .btn { width: 100%; justify-content: center; }

/* ---------- /werkstatt route ---------- */

.werkstatt-hero {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 24px;
  align-items: end;
  margin-bottom: 28px;
  padding-bottom: 22px;
  border-bottom: 1px dashed var(--border);
}
.wk-rank {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: lowercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.wk-rank-name {
  font-family: var(--font-brand);
  font-style: italic;
  font-size: 32px;
  line-height: 1.1;
  color: var(--text);
  text-shadow: 0 0 22px var(--accent-glow);
  margin-bottom: 10px;
}
.wk-rank-name .ord { color: var(--accent); }
.wk-rank-bar {
  height: 6px;
  width: 100%;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}
.wk-rank-bar-fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: linear-gradient(90deg, var(--accent-fill), var(--accent));
  box-shadow: 0 0 14px var(--accent-glow-strong);
  transition: width 0.6s var(--ease);
}
.wk-rank-bar-fill::after {
  content: '';
  position: absolute;
  top: 0; bottom: 0; left: 0;
  width: 40%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.45), transparent);
  animation: shimmer 2.4s ease-in-out infinite;
}
.wk-rank-meta {
  margin-top: 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

.wk-portraits {
  display: flex;
  gap: 8px;
}
.wk-portraits .wk-port {
  width: 68px; height: 68px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  background: var(--bg-card);
  overflow: hidden;
  position: relative;
  cursor: pointer;
  box-shadow: 0 0 16px rgba(255,255,255,0.06);
  transition: border-color 0.18s, transform 0.14s var(--ease), box-shadow 0.18s;
}
.wk-portraits .wk-port img {
  position: absolute;
  bottom: 0; left: 50%;
  transform: translateX(-50%);
  width: 110%; height: auto;
}
.wk-portraits .wk-port:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 0 20px rgba(255,255,255,0.09), 0 0 28px var(--accent-glow);
}

.wk-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 28px;
}
.wk-card {
  position: relative;
  padding: 16px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.wk-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent-soft), transparent);
}
.wk-card-label {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.wk-card-label img { width: 14px; height: 14px; filter: drop-shadow(0 0 4px var(--accent-glow)); }
.wk-card-num {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.wk-card-sub {
  margin-top: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

.wk-lamps-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}
.wk-lamp-pip {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--bg-inset);
  border: 1px solid var(--border-strong);
  transition: background 0.3s var(--ease), box-shadow 0.3s var(--ease);
}
.wk-lamp-pip.lit {
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow-strong);
}

.wk-section {
  margin-top: 28px;
}
.wk-section-head {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.wk-section-head::before { content: '// '; color: var(--text-dim); }

.wk-rank-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.wk-rank-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-secondary);
}
.wk-rank-row.achieved {
  border-left: 2px solid var(--success);
  color: var(--text);
}
.wk-rank-row.current {
  border-left: 2px solid var(--accent);
  background: var(--bg-card-hi);
  color: var(--text);
  box-shadow: 0 0 24px var(--accent-glow);
}
.wk-rank-row.locked { color: var(--text-muted); opacity: 0.6; }
.wk-rank-row .wk-rank-ord {
  flex-shrink: 0;
  width: 24px; height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-inset);
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  font-size: 10px;
  color: var(--text-muted);
}
.wk-rank-row.achieved .wk-rank-ord { color: var(--success); border-color: var(--success); }
.wk-rank-row.current .wk-rank-ord { color: var(--accent); border-color: var(--accent); }
.wk-rank-row .wk-rank-row-name { flex: 1; font-family: var(--font-ui); font-size: 13.5px; }
.wk-rank-row .wk-rank-row-th { color: var(--text-muted); font-size: 11px; }

@media (max-width: 720px) {
  .werkstatt-hero { grid-template-columns: 1fr; align-items: start; }
  .wk-rank-name { font-size: 26px; }
}

/* ---------- HUD responsive ---------- */

@media (max-width: 720px) {
  .hud { gap: 2px; }
  .hud-item { padding: 5px 7px; gap: 4px; }
  .hud-item img { width: 14px; height: 14px; }
  .hud { font-size: 11.5px; }
}
@media (max-width: 540px) {
  .topnav { display: none; }
  .topbar { gap: 12px; }
  .hud-item { padding: 4px 6px; }
  .hud { font-size: 11px; }
}
@media (max-width: 380px) {
  .hud-item { padding: 3px 5px; }
}

/* mobile fallback nav (if topnav hidden, content needs route access) */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 25;
  background: rgba(23, 21, 15, 0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 0));
  justify-content: space-around;
  font-family: var(--font-mono);
  font-size: 11px;
}
.mobile-nav a {
  flex: 1;
  text-align: center;
  padding: 8px 4px;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  transition: color 0.18s, background 0.18s;
}
.mobile-nav a.active { color: var(--accent); background: var(--accent-dim); }

@media (max-width: 540px) {
  .mobile-nav { display: flex; }
  .site-footer { padding-bottom: 60px; }
  .char-dialog { bottom: 70px; }
}

/* ---------- session-end celebration tweak ---------- */

.session-celebration {
  text-align: center;
  padding: 20px 0 8px;
}
.session-celebration img {
  width: 70px; height: 70px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  box-shadow: 0 0 24px var(--accent-glow);
  margin: 0 6px;
  background: var(--bg);
  object-fit: cover;
  object-position: center bottom;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.08s !important;
  }
  .progress-fill::after, .pill-accent, .cursor, .hero-eyebrow::before,
  .ws-lamp.lit .ws-lamp-on, .wk-rank-bar-fill::after { animation: none; }
}
