/* ─── CSS Variables ───────────────────────────────────────────── */
:root {
  --bg:           #0e0e10;
  --bg-surface:   #18181b;
  --bg-modal:     #1f1f23;
  --border:       #3a3a3d;

  --text:         #efeff1;
  --text-muted:   #adadb8;

  --accent:       #9146ff;   /* Twitch purple */
  --accent-hover: #772ce8;

  --tile-empty:   #18181b;
  --tile-filled:  #26262c;

  --correct:      #00c853;
  --present:      #f5a623;
  --absent:       #3d3d42;

  --key-bg:       #3d3d42;
  --key-text:     #efeff1;

  --radius:       6px;
  --tile-size:    clamp(48px, 11vw, 62px);
  --gap:          6px;

  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* ─── Reset ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ─── Header ──────────────────────────────────────────────────── */
header {
  width: 100%;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
}

.header-inner {
  max-width: 500px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.header-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.header-inner h1 {
  font-size: 1.6rem;
  letter-spacing: 0.18em;
  background: linear-gradient(135deg, var(--accent) 0%, #bf94ff 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-align: center;
}

#day-label {
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  text-transform: uppercase;
}

#day-number {
  color: var(--accent);
  font-weight: 700;
}

.header-right { display: flex; gap: 4px; }

.icon-btn {
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  font-size: 1.2rem;
  padding: 6px 10px;
  border-radius: var(--radius);
  transition: background 0.15s;
}
.icon-btn:hover { background: var(--border); }

/* ─── Main ────────────────────────────────────────────────────── */
main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 16px 16px;
  gap: 24px;
  width: 100%;
  max-width: 500px;
}

/* ─── Toast ───────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 1000;
  pointer-events: none;
}

.toast {
  background: var(--text);
  color: var(--bg);
  padding: 10px 20px;
  border-radius: 20px;
  font-weight: 700;
  font-size: 0.9rem;
  opacity: 0;
  transform: translateY(-8px) scale(0.95);
  transition: opacity 0.25s, transform 0.25s;
}
.toast.toast-show { opacity: 1; transform: translateY(0) scale(1); }

/* ─── Board ───────────────────────────────────────────────────── */
#board-container {
  display: flex;
  justify-content: center;
}

#board {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.row {
  display: flex;
  gap: var(--gap);
}

.tile {
  width: var(--tile-size);
  height: var(--tile-size);
  border: 2px solid var(--border);
  background: var(--tile-empty);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(1.4rem, 5vw, 2rem);
  font-weight: 800;
  letter-spacing: 0;
  border-radius: var(--radius);
  user-select: none;
  transition: border-color 0.1s;
}

.tile.filled {
  border-color: var(--text-muted);
  animation: pop 0.1s ease;
}

.tile.correct { background: var(--correct);  border-color: var(--correct);  color: #fff; }
.tile.present { background: var(--present);  border-color: var(--present);  color: #fff; }
.tile.absent  { background: var(--absent);   border-color: var(--absent);   color: var(--text-muted); }

/* Flip animation */
.tile.flip {
  animation: flipOut 0.15s ease forwards;
}

@keyframes flipOut {
  from { transform: scaleY(1); }
  to   { transform: scaleY(0); }
}

/* Pop animation */
@keyframes pop {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.12); }
  100% { transform: scale(1); }
}

/* Shake animation */
.row.shake {
  animation: shake 0.4s ease;
}

@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%      { transform: translateX(-8px); }
  40%      { transform: translateX(8px); }
  60%      { transform: translateX(-5px); }
  80%      { transform: translateX(5px); }
}

/* ─── Keyboard ────────────────────────────────────────────────── */
#keyboard {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  max-width: 480px;
}

.kb-row {
  display: flex;
  justify-content: center;
  gap: 5px;
}

.key {
  height: 58px;
  min-width: 36px;
  flex: 1;
  max-width: 44px;
  border: none;
  border-radius: var(--radius);
  background: var(--key-bg);
  color: var(--key-text);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font);
  user-select: none;
}

.key:active  { transform: scale(0.92); }
.key-wide    { min-width: 58px; max-width: 58px; font-size: 0.75rem; }

.key.correct { background: var(--correct); color: #fff; }
.key.present { background: var(--present); color: #fff; }
.key.absent  { background: #2a2a2e; color: var(--text-muted); }

/* ─── Footer ──────────────────────────────────────────────────── */
footer {
  width: 100%;
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  justify-content: center;
  gap: 24px;
  flex-wrap: wrap;
  font-size: 0.8rem;
  color: var(--text-muted);
}

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

/* ─── Modal ───────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 100;
}
.modal-overlay.open { display: block; }

.modal {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -48%);
  z-index: 200;
  width: min(420px, 92vw);
  background: var(--bg-modal);
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: 0 16px 48px rgba(0,0,0,0.5);
  max-height: 90dvh;
  overflow-y: auto;
}
.modal.open { display: block; animation: slideIn 0.2s ease; }

@keyframes slideIn {
  from { opacity: 0; transform: translate(-50%, -45%); }
  to   { opacity: 1; transform: translate(-50%, -48%); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  font-size: 1rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text);
}

.close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
}
.close-btn:hover { color: var(--text); background: var(--border); }

.modal-body {
  padding: 16px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text-muted);
}

.modal-body p { color: var(--text); }
.modal-body hr { border: none; border-top: 1px solid var(--border); }
.modal-body strong { color: var(--text); }
.modal-body h3 {
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 4px;
}
.modal-body a { color: var(--accent); }

/* Example tiles in help modal */
.example-row {
  display: flex;
  gap: 4px;
  margin: 4px 0;
}

.example-tile {
  width: 42px;
  height: 42px;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.1rem;
  border-radius: var(--radius);
}
.example-tile.correct { background: var(--correct); border-color: var(--correct); color: #fff; }
.example-tile.present { background: var(--present); border-color: var(--present); color: #fff; }
.example-tile.absent  { background: var(--absent);  border-color: var(--absent);  }

.stream-note { font-size: 0.85rem; color: var(--text-muted); text-align: center; margin-top: 4px; }

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  text-align: center;
}

.stat-box { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.stat-number { font-size: 2rem; font-weight: 800; color: var(--text); }
.stat-label  { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }

/* Distribution */
#distribution { display: flex; flex-direction: column; gap: 5px; }

.dist-row { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; }
.dist-label { width: 14px; text-align: right; color: var(--text-muted); flex-shrink: 0; }
.dist-bar-wrap { flex: 1; }
.dist-bar {
  background: var(--absent);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 3px 8px;
  border-radius: 3px;
  font-weight: 700;
  font-size: 0.8rem;
  min-width: 28px;
  transition: width 0.5s ease;
}
.dist-bar.active { background: var(--accent); }

/* Share area */
#share-area { display: flex; flex-direction: column; gap: 10px; align-items: center; margin-top: 8px; width: 100%; }
#share-area.hidden { display: none; }

#share-preview-wrap {
  width: 100%;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #0e0e10;
}
#share-preview { width: 100%; display: block; }

.share-buttons { display: flex; gap: 8px; width: 100%; }

.share-btn {
  flex: 1;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 10px 6px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  font-family: var(--font);
  transition: background 0.15s, border-color 0.15s;
}
.share-btn:hover { background: var(--border); border-color: var(--accent); }
.share-btn.hidden { display: none; }

#next-word-timer { font-size: 0.82rem; color: var(--text-muted); }
#timer { font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }

#stream-callout {
  display: block;
  width: 100%;
  background: linear-gradient(135deg, #6441a5 0%, #9146ff 100%);
  color: #fff;
  text-decoration: none;
  border-radius: var(--radius);
  padding: 14px 16px;
  text-align: center;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.5;
  transition: opacity 0.15s, transform 0.15s;
  box-shadow: 0 4px 16px rgba(145, 70, 255, 0.3);
}
#stream-callout:hover { opacity: 0.9; transform: translateY(-1px); }
#stream-callout-msg { font-size: 1rem; font-weight: 800; display: block; margin-bottom: 2px; }

/* ─── End screen ──────────────────────────────────────────────── */
.end-screen {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 40px 20px;
}
.end-screen h2 { font-size: 2rem; color: var(--accent); }
.end-screen a {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  padding: 12px 28px;
  border-radius: var(--radius);
  text-decoration: none;
  font-weight: 700;
}

/* ─── Impressum / Datenschutz pages ──────────────────────────── */
.legal-page {
  max-width: 680px;
  margin: 0 auto;
  padding: 32px 20px;
  line-height: 1.8;
  color: var(--text-muted);
}

.legal-page h1 { font-size: 1.6rem; color: var(--text); margin-bottom: 24px; }
.legal-page h2 { font-size: 1.1rem; color: var(--text); margin: 24px 0 8px; }
.legal-page p  { margin-bottom: 12px; }
.legal-page a  { color: var(--accent); }

.back-link {
  display: inline-block;
  color: var(--accent);
  text-decoration: none;
  margin-bottom: 24px;
  font-size: 0.9rem;
}

/* ─── Responsive ──────────────────────────────────────────────── */
@media (max-width: 360px) {
  .key { min-width: 30px; font-size: 0.78rem; }
  .key-wide { min-width: 48px; max-width: 48px; }
}
