/* ============================================================
   WORTSPIEL — Deutsches Semantik-Ratespiel
   Dark Theme, Mobile-First
   ============================================================ */

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

:root {
  /* Farben */
  --bg:        #0F172A;
  --surface:   #1E293B;
  --surface2:  #273548;
  --border:    #334155;
  --text:      #F1F5F9;
  --text-sub:  #94A3B8;
  --text-dim:  #64748B;

  /* Rang-Farben */
  --rank-top:    #F59E0B;   /* 1–10 */
  --rank-near:   #10B981;   /* 11–100 */
  --rank-mid:    #06B6D4;   /* 101–500 */
  --rank-far:    #3B82F6;   /* 501–2000 */
  --rank-very-far: #6366F1; /* 2001+ */

  /* Akzent */
  --accent:    #F59E0B;
  --accent-dim: rgba(245, 158, 11, 0.15);

  /* Abstände */
  --gap: 12px;
  --radius: 14px;
  --radius-sm: 8px;

  /* Transitions */
  --t: 280ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light Mode */
[data-theme="light"] {
  --bg:        #F8FAFC;
  --surface:   #FFFFFF;
  --surface2:  #F1F5F9;
  --border:    #CBD5E1;
  --text:      #0F172A;
  --text-sub:  #475569;
  --text-dim:  #94A3B8;
  --accent-dim: rgba(217, 119, 6, 0.12);
}

[data-theme="light"] .header {
  background: rgba(248, 250, 252, 0.9);
  border-bottom-color: #CBD5E1;
}

[data-theme="light"] .glass {
  background: rgba(255, 255, 255, 0.85);
  border-color: rgba(0, 0, 0, 0.08);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .word-input {
  background: #F8FAFC;
  border-color: #CBD5E1;
  color: #0F172A;
}

[data-theme="light"] .modal-overlay {
  background: rgba(0, 0, 0, 0.4);
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: 'Lexend', system-ui, -apple-system, sans-serif;
  min-height: 100dvh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ---- Layout ---- */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

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

.header-left {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.logo {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  background: linear-gradient(135deg, #F59E0B 0%, #FCD34D 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.game-number {
  font-size: 0.78rem;
  color: var(--text-dim);
  font-weight: 500;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.attempt-counter {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  color: var(--text-sub);
  background: var(--surface);
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
}

.icon-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-sub);
  padding: 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  transition: color var(--t), background var(--t);
}

.icon-btn:hover {
  color: var(--text);
  background: var(--surface);
}

.icon-btn svg {
  width: 20px;
  height: 20px;
}

.main {
  max-width: 600px;
  margin: 0 auto;
  padding: 20px 16px 40px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ---- Glassmorphism ---- */
.glass {
  background: rgba(30, 41, 59, 0.7);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}

/* ---- Input Section ---- */
.input-section {
  border-radius: var(--radius);
  padding: 16px;
}

.guess-form {
  display: flex;
  gap: 10px;
  align-items: center;
}

.word-input {
  flex: 1;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: 'Lexend', sans-serif;
  font-size: 1.05rem;
  font-weight: 500;
  padding: 12px 16px;
  outline: none;
  transition: border-color var(--t), box-shadow var(--t);
}

.word-input::placeholder {
  color: var(--text-dim);
}

.word-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.15);
}

.submit-btn {
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  color: #000;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 16px;
  transition: background var(--t), transform var(--t), box-shadow var(--t);
  flex-shrink: 0;
}

.submit-btn:hover {
  background: #FCD34D;
  box-shadow: 0 0 16px rgba(245, 158, 11, 0.4);
}

.submit-btn:active {
  transform: scale(0.95);
}

.submit-btn svg {
  width: 20px;
  height: 20px;
}

.submit-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.input-hint {
  min-height: 20px;
  font-size: 0.8rem;
  color: var(--text-sub);
  margin-top: 8px;
  transition: color var(--t);
}

.input-hint.error {
  color: #F87171;
}

/* ---- Hint Button ---- */
.hint-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  cursor: pointer;
  font-family: 'Lexend', sans-serif;
  font-size: 0.8rem;
  font-weight: 500;
  margin-top: 10px;
  padding: 7px 14px;
  transition: color var(--t), border-color var(--t), background var(--t);
  width: 100%;
  justify-content: center;
}

.hint-btn:hover {
  color: var(--text-sub);
  border-color: var(--text-dim);
  background: var(--surface2);
}

.hint-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.hint-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1px 7px;
  color: var(--text-dim);
}

/* ---- Results ---- */
.results-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.results-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-sub);
}

.results-empty p {
  font-size: 1rem;
}

.hint-text {
  font-size: 0.85rem !important;
  color: var(--text-dim) !important;
  margin-top: 6px;
}

.results-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* ---- Result Item ---- */
.result-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  padding: 10px 14px;
  gap: 12px;
  position: relative;
  overflow: hidden;
  animation: slideIn 300ms cubic-bezier(0.34, 1.56, 0.64, 1) both;
  transition: transform var(--t);
}

.result-item.winner {
  border-color: var(--rank-top);
  box-shadow: 0 0 20px rgba(245, 158, 11, 0.25);
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Rang-Farbbalken links */
.result-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  border-radius: 2px 0 0 2px;
  background: var(--item-color, var(--text-dim));
}

.result-word {
  font-family: 'Lexend', sans-serif;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text);
  padding-left: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.result-rank-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.result-bar-wrap {
  width: 80px;
  height: 6px;
  background: var(--surface2);
  border-radius: 3px;
  overflow: hidden;
}

.result-bar {
  height: 100%;
  border-radius: 3px;
  background: var(--item-color, var(--text-dim));
  transition: width 500ms cubic-bezier(0.4, 0, 0.2, 1);
}

.result-rank {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--item-color, var(--text-sub));
  min-width: 40px;
  text-align: right;
}

/* ---- Modals ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn 200ms ease both;
}

.modal-overlay[hidden] {
  display: none;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  border-radius: 20px;
  padding: 28px 24px;
  width: 100%;
  max-width: 420px;
  position: relative;
  animation: modalIn 300ms cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: var(--surface2);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  color: var(--text-sub);
  padding: 6px;
  display: flex;
  transition: color var(--t), background var(--t);
}

.modal-close:hover {
  color: var(--text);
  background: var(--border);
}

.modal-close svg {
  width: 18px;
  height: 18px;
}

.modal h2 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 16px;
}

/* Won Modal */
.modal-confetti {
  position: absolute;
  inset: 0;
  border-radius: 20px;
  overflow: hidden;
  pointer-events: none;
}

.confetti-particle {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  animation: confettiFall linear both;
}

@keyframes confettiFall {
  0% {
    opacity: 1;
    transform: translateY(-20px) rotate(0deg);
  }
  100% {
    opacity: 0;
    transform: translateY(300px) rotate(720deg);
  }
}

.modal-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.modal-emoji {
  font-size: 2rem;
}

.modal-subtitle {
  color: var(--text-sub);
  margin-bottom: 24px;
  font-size: 1rem;
}

.modal-subtitle strong {
  color: var(--accent);
  font-weight: 600;
}

.modal-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.stat-box {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 8px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-number {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
}

.stat-label {
  font-size: 0.72rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.modal-actions {
  display: flex;
  gap: 10px;
}

.btn {
  flex: 1;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: 'Lexend', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background var(--t), transform var(--t), box-shadow var(--t);
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--accent);
  color: #000;
}

.btn-primary:hover {
  background: #FCD34D;
  box-shadow: 0 0 16px rgba(245, 158, 11, 0.35);
}

.btn-primary svg {
  width: 18px;
  height: 18px;
}

.btn-secondary {
  background: var(--surface2);
  color: var(--text-sub);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  color: var(--text);
  background: var(--border);
}

.next-game-hint {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.8rem;
  margin-top: 16px;
}

/* Info Modal */
.info-content p {
  color: var(--text-sub);
  margin-bottom: 16px;
  line-height: 1.6;
}

.info-step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.info-step-num {
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.info-step p {
  margin-bottom: 0;
  padding-top: 4px;
  font-size: 0.9rem;
}

.info-divider {
  height: 1px;
  background: var(--border);
  margin: 16px 0;
}

.info-note {
  font-size: 0.85rem !important;
}

.rank-legend {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  color: var(--text-sub);
}

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
}

/* Stats Modal */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

/* Archive Modal */
.archive-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 400px;
  overflow-y: auto;
}

.archive-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  cursor: pointer;
  transition: background var(--t);
  text-decoration: none;
  color: var(--text);
}

.archive-item:hover {
  background: var(--border);
}

.archive-item-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.archive-item-date {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
}

.archive-item-today .archive-item-date {
  color: var(--accent);
}

.archive-item-status {
  font-size: 0.8rem;
  color: var(--text-sub);
}

.archive-badge {
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 20px;
}

.archive-badge.won {
  background: rgba(16, 185, 129, 0.15);
  color: #10B981;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.archive-badge.in-progress {
  background: rgba(245, 158, 11, 0.15);
  color: var(--accent);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 10px 20px;
  font-size: 0.9rem;
  color: var(--text);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  z-index: 300;
  opacity: 0;
  transition: opacity var(--t), transform var(--t);
  pointer-events: none;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

/* ---- Utilities ---- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

/* ---- Responsive ---- */
@media (max-width: 480px) {
  .header-inner {
    padding: 12px;
  }

  .main {
    padding: 16px 12px 32px;
  }

  .modal {
    padding: 22px 18px;
  }

  .modal-stats {
    gap: 8px;
  }

  .result-bar-wrap {
    width: 60px;
  }
}

/* Settings Modal */
.settings-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.settings-row:last-child {
  border-bottom: none;
}

.settings-row-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.settings-row-label {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.settings-row-sub {
  font-size: 0.78rem;
  color: var(--text-dim);
}

.theme-toggle {
  display: flex;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 3px;
  flex-shrink: 0;
}

.theme-option {
  display: flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-dim);
  font-family: 'Lexend', sans-serif;
  font-size: 0.82rem;
  font-weight: 500;
  padding: 6px 12px;
  transition: background var(--t), color var(--t);
  white-space: nowrap;
}

.theme-option:hover {
  color: var(--text-sub);
}

.theme-option.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .theme-option.active {
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
