/* Letters – Mobile-first Grundlayout. Der Seitenhintergrund folgt dem
   aktuellen Rang über --rank-color. */
:root {
  --rank-color: #BB8FCE;      /* MAGIC als Start */
  --bg: #14121a;
  --panel: rgba(20, 18, 26, 0.82);
  --panel-solid: #1e1b28;
  --text: #f2eefa;
  --text-dim: #b3abc4;
  --accent: #ffd166;
  --danger: #ff6b6b;
  --ok: #7bd88f;
  --vowel: #ffe3a3;
  --consonant: #f5f2fb;
  --radius: 14px;
  font-size: 16px;
}

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

html, body { height: 100%; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background:
    radial-gradient(120% 90% at 50% 0%, color-mix(in srgb, var(--rank-color) 55%, var(--bg)) 0%, var(--bg) 70%);
  transition: background 0.8s ease;
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

button {
  font: inherit;
  border: none;
  border-radius: var(--radius);
  padding: 0.65rem 1rem;
  background: var(--panel-solid);
  color: var(--text);
  cursor: pointer;
}
button.primary { background: var(--accent); color: #241c00; font-weight: 700; }
button:disabled { opacity: 0.5; cursor: default; }

input, select, textarea {
  font: inherit;
  width: 100%;
  padding: 0.65rem 0.8rem;
  border-radius: 10px;
  border: 1px solid #3a3450;
  background: #241f33;
  color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); border-color: transparent; }

a { color: var(--accent); text-decoration: none; }

.hidden { display: none !important; }

/* --- Auth-Seite --- */
.auth-wrap {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  gap: 1.2rem;
}
.logo {
  font-size: 2.4rem;
  font-weight: 800;
  letter-spacing: 0.35em;
  text-shadow: 0 2px 18px rgba(0,0,0,0.4);
}
.logo .hexline { display: flex; gap: 0.3rem; justify-content: center; }
.card {
  width: min(400px, 100%);
  background: var(--panel);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius);
  padding: 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}
.card h2 { font-size: 1.1rem; font-weight: 600; }
.field label { display: block; font-size: 0.85rem; color: var(--text-dim); margin-bottom: 0.3rem; }
.msg { min-height: 1.3em; font-size: 0.9rem; }
.msg.error { color: var(--danger); }
.msg.ok { color: var(--ok); }
.switch-line { font-size: 0.9rem; color: var(--text-dim); text-align: center; }

.lang-switch { display: flex; gap: 0.4rem; justify-content: center; }
.lang-switch button {
  padding: 0.3rem 0.7rem; font-size: 0.85rem; border-radius: 999px;
  background: rgba(255,255,255,0.1);
}
.lang-switch button.active { background: var(--accent); color: #241c00; font-weight: 700; }

/* --- Spielseite --- */
.game-wrap {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 640px;
  margin: 0 auto;
}

.icon-btn {
  background: rgba(255,255,255,0.12);
  padding: 0.4rem 0.7rem;
  font-size: 1.1rem;
}

.menu-dropdown {
  position: absolute;
  top: 3.2rem;
  left: 0.6rem;
  z-index: 50;
  background: var(--panel-solid);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius);
  padding: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  min-width: 220px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.5);
}
.menu-dropdown a { padding: 0.35rem 0.2rem; color: var(--text); }
.menu-dropdown a:active { color: var(--accent); }
.menu-head { display: flex; flex-direction: column; gap: 0.15rem; padding-bottom: 0.4rem; border-bottom: 1px solid rgba(255,255,255,0.1); }
.menu-credits { color: var(--accent); font-size: 0.9rem; }

.word-bar {
  position: relative;
  min-height: 3.4rem;
  margin: 0.5rem 0.8rem 0;
  border-radius: var(--radius);
  background: var(--panel);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.3rem 0.6rem;
  cursor: pointer;
  border: 2px solid transparent;
  user-select: none;
}
.word-bar.committable {
  border-color: var(--accent);
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 209, 102, 0.35); }
  50% { box-shadow: 0 0 0 8px rgba(255, 209, 102, 0); }
}
.word-bar.shake { animation: shake 0.35s; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-7px); }
  75% { transform: translateX(7px); }
}
.word-display {
  font-size: 1.7rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  min-height: 2.1rem;
  display: flex;
}
.wletter { display: inline-block; }
.word-hint { font-size: 0.75rem; color: var(--text-dim); min-height: 1em; }
.backspace-btn {
  position: absolute;
  right: 0.45rem;
  top: 50%;
  transform: translateY(-50%);
  padding: 0.35rem 0.65rem;
  font-size: 1.05rem;
  background: rgba(255,255,255,0.12);
}

.msg-line {
  text-align: center;
  min-height: 1.4em;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
}
.msg-line.error { color: var(--danger); }
.msg-line.ok { color: var(--ok); }

.board-container {
  flex: 1;
  position: relative;
  margin: 0.2rem 0.4rem;
  min-height: 0;
}
.board-container canvas {
  position: absolute;
  inset: 0;
  touch-action: none;
}

.bottombar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 0.55rem 0.8rem calc(0.55rem + env(safe-area-inset-bottom));
}
.swap-hint { font-size: 0.75rem; color: var(--text-dim); text-align: right; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.55rem 0.8rem;
  background: var(--panel);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar .stat { font-weight: 700; }
.topbar .rank-badge {
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  background: var(--rank-color);
  color: #1c1524;
  font-weight: 800;
  font-size: 0.8rem;
  letter-spacing: 0.06em;
}

/* --- Unterseiten (Sammlung, Markt, Rangliste, …) --- */
.page-wrap {
  max-width: 640px;
  margin: 0 auto;
  padding: 0.8rem 0.8rem 2.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.page-head h1 { font-size: 1.25rem; }
.back-link { font-size: 0.9rem; white-space: nowrap; }

.tabs { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.tabs button {
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  background: rgba(255,255,255,0.1);
  font-size: 0.9rem;
}
.tabs button.active { background: var(--accent); color: #241c00; font-weight: 700; }

.list { display: flex; flex-direction: column; gap: 0.5rem; }
.list-item {
  background: var(--panel);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: var(--radius);
  padding: 0.7rem 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  flex-wrap: wrap;
}
.list-item .grow { flex: 1; min-width: 0; }
.word-chip {
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: 0.06em;
}
.meta { font-size: 0.78rem; color: var(--text-dim); }
.badge {
  display: inline-block;
  padding: 0.05rem 0.5rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  background: rgba(255,255,255,0.12);
}
.price-tag { font-weight: 800; color: var(--accent); white-space: nowrap; }
.small-btn { padding: 0.35rem 0.75rem; font-size: 0.85rem; }
.empty-note { color: var(--text-dim); text-align: center; padding: 1.5rem 0; }

.lb-row { display: flex; align-items: center; gap: 0.7rem; }
.lb-pos { width: 2.2rem; text-align: right; font-weight: 800; color: var(--text-dim); }
.lb-row.top1 .lb-pos { color: gold; }
.lb-row.top2 .lb-pos { color: silver; }
.lb-row.top3 .lb-pos { color: #cd7f32; }
.period-nav { display: flex; align-items: center; gap: 0.5rem; justify-content: center; }
.period-nav .label { min-width: 11rem; text-align: center; font-weight: 600; font-size: 0.95rem; }

.form-row { display: flex; gap: 0.5rem; align-items: end; flex-wrap: wrap; }
.form-row .field { flex: 1; min-width: 130px; }
