/* =============================================================
   styles.css – Zahlenraten
   Mobile-First, Hell-/Dunkelmodus, WCAG 2.1 AA
   ============================================================= */

/* -------------------------------------------------------------
   1. Design-Tokens (CSS Custom Properties)
   ------------------------------------------------------------- */
:root {
  /* Farben – Hellmodus */
  --c-bg:         #f1f5f9;
  --c-surface:    #ffffff;
  --c-surface-2:  #f8fafc;
  --c-border:     #e2e8f0;
  --c-text:       #1e293b;
  --c-muted:      #64748b;
  --c-primary:    #6366f1;
  --c-primary-h:  #4f46e5;   /* hover */
  --c-primary-fg: #ffffff;
  --c-secondary:  #e2e8f0;
  --c-secondary-h:#cbd5e1;
  --c-secondary-fg:#1e293b;
  --c-success:    #22c55e;
  --c-warning:    #f59e0b;
  --c-error:      #ef4444;
  --c-higher:     #ef4444;
  --c-lower:      #3b82f6;

  /* Feedback-Hintergründe (semi-transparent) */
  --c-higher-bg:  rgba(239,68,68,.10);
  --c-higher-bd:  rgba(239,68,68,.35);
  --c-lower-bg:   rgba(59,130,246,.10);
  --c-lower-bd:   rgba(59,130,246,.35);
  --c-ok-bg:      rgba(34,197,94,.10);
  --c-ok-bd:      rgba(34,197,94,.35);
  --c-hint-bg:    rgba(245,158,11,.10);
  --c-hint-bd:    rgba(245,158,11,.35);
  --c-primary-bg: rgba(99,102,241,.12);
  --c-primary-bd: rgba(99,102,241,.35);

  /* Schatten */
  --shadow-sm: 0 1px 2px rgba(0,0,0,.06),0 1px 3px rgba(0,0,0,.10);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07),0 2px 4px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,.08),0 4px 6px rgba(0,0,0,.05);
  --shadow-xl: 0 20px 25px rgba(0,0,0,.10),0 10px 10px rgba(0,0,0,.04);

  /* Layout */
  --max-w: 480px;
  --hdr-h: 60px;

  /* Abstände */
  --sp-1:.25rem; --sp-2:.5rem; --sp-3:.75rem; --sp-4:1rem;
  --sp-5:1.25rem; --sp-6:1.5rem; --sp-8:2rem;

  /* Radien */
  --r-sm:6px; --r-md:10px; --r-lg:16px; --r-xl:24px; --r-full:9999px;

  /* Typografie */
  --font: system-ui,-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;
  --mono: ui-monospace,'Cascadia Code','Source Code Pro',monospace;

  /* Übergänge */
  --t-fast:150ms ease;
  --t-base:250ms ease;
}

/* Dunkelmodus über System-Einstellung (nur wenn kein manuelles Override) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --c-bg:         #0f172a;
    --c-surface:    #1e293b;
    --c-surface-2:  #243044;
    --c-border:     #334155;
    --c-text:       #f1f5f9;
    --c-muted:      #94a3b8;
    --c-primary:    #818cf8;
    --c-primary-h:  #6366f1;
    --c-secondary:  #334155;
    --c-secondary-h:#475569;
    --c-secondary-fg:#f1f5f9;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.30);
    --shadow-md: 0 4px 6px rgba(0,0,0,.35);
    --shadow-lg: 0 10px 15px rgba(0,0,0,.40);
    --shadow-xl: 0 20px 25px rgba(0,0,0,.50);
  }
}

/* Dunkelmodus über manuelles Toggle */
[data-theme="dark"] {
  --c-bg:         #0f172a;
  --c-surface:    #1e293b;
  --c-surface-2:  #243044;
  --c-border:     #334155;
  --c-text:       #f1f5f9;
  --c-muted:      #94a3b8;
  --c-primary:    #818cf8;
  --c-primary-h:  #6366f1;
  --c-secondary:  #334155;
  --c-secondary-h:#475569;
  --c-secondary-fg:#f1f5f9;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.30);
  --shadow-md: 0 4px 6px rgba(0,0,0,.35);
  --shadow-lg: 0 10px 15px rgba(0,0,0,.40);
  --shadow-xl: 0 20px 25px rgba(0,0,0,.50);
}

/* Hellmodus-Override (wenn manuell gesetzt) */
[data-theme="light"] {
  --c-bg:         #f1f5f9;
  --c-surface:    #ffffff;
  --c-surface-2:  #f8fafc;
  --c-border:     #e2e8f0;
  --c-text:       #1e293b;
  --c-muted:      #64748b;
  --c-primary:    #6366f1;
  --c-primary-h:  #4f46e5;
  --c-secondary:  #e2e8f0;
  --c-secondary-h:#cbd5e1;
  --c-secondary-fg:#1e293b;
}

/* -------------------------------------------------------------
   2. Reduzierte Bewegung
   ------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--c-text);
  background-color: var(--c-bg);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  transition: background-color var(--t-base), color var(--t-base);
}

/* -------------------------------------------------------------
   4. Utility-Klassen
   ------------------------------------------------------------- */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* Skip-Link (WCAG 2.4.1) */
.skip-link {
  position: absolute;
  top: -100%;
  left: var(--sp-4);
  z-index: 9999;
  padding: var(--sp-2) var(--sp-4);
  background: var(--c-primary);
  color: var(--c-primary-fg);
  font-weight: 600;
  font-size: .875rem;
  border-radius: var(--r-sm);
  text-decoration: none;
  transition: top var(--t-fast);
}
.skip-link:focus { top: var(--sp-2); }

/* Fokus-Indikator (WCAG 2.4.7) */
:focus-visible {
  outline: 3px solid var(--c-primary);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* -------------------------------------------------------------
   5. Header
   ------------------------------------------------------------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  box-shadow: var(--shadow-sm);
  transition: background-color var(--t-base), border-color var(--t-base);
}

.header-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 var(--sp-4);
  height: var(--hdr-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
}

.app-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--c-primary);
  letter-spacing: -.025em;
  flex-shrink: 0;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

/* Icon-Buttons im Header */
.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: var(--sp-2);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  background: var(--c-surface-2);
  color: var(--c-text);
  cursor: pointer;
  font-size: .875rem;
  font-weight: 600;
  font-family: var(--font);
  transition: background-color var(--t-fast), transform var(--t-fast), border-color var(--t-fast);
  -webkit-tap-highlight-color: transparent;
}
.icon-btn:hover { background: var(--c-secondary-h); transform: translateY(-1px); }
.icon-btn:active { transform: scale(.95); }

/* Mond/Sonne wechseln je nach Modus */
.icon-sun  { display: none; }
.icon-moon { display: block; }

[data-theme="dark"] .icon-sun          { display: block; }
[data-theme="dark"] .icon-moon         { display: none; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-sun  { display: block; }
  :root:not([data-theme="light"]) .icon-moon { display: none; }
}

/* -------------------------------------------------------------
   6. Haupt-Layout
   ------------------------------------------------------------- */
.app-main {
  flex: 1;
  max-width: var(--max-w);
  width: 100%;
  margin: 0 auto;
  padding: var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

/* Statistik-Leiste */
.stats-bar {
  display: flex;
  gap: var(--sp-2);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  padding: var(--sp-3) var(--sp-4);
  box-shadow: var(--shadow-sm);
}

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

.stat-label {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  font-weight: 600;
  color: var(--c-muted);
}

.stat-value {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--c-primary);
  font-variant-numeric: tabular-nums;
}

/* -------------------------------------------------------------
   7. Cards & Screens
   ------------------------------------------------------------- */
.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-xl);
  padding: var(--sp-6);
  box-shadow: var(--shadow-md);
  transition: background-color var(--t-base), border-color var(--t-base);
}

.screen {
  animation: fadeUp var(--t-base) ease-out both;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Setup-Screen */
.card-title {
  font-size: 1.375rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: var(--sp-2);
}

.card-desc {
  text-align: center;
  color: var(--c-muted);
  font-size: .9rem;
  margin-bottom: var(--sp-5);
}

/* Schwierigkeitsgrade */
.difficulty-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-3);
  margin-bottom: var(--sp-6);
}

.diff-card { cursor: pointer; }

.diff-card-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-4) var(--sp-2);
  border: 2px solid var(--c-border);
  border-radius: var(--r-lg);
  background: var(--c-surface-2);
  transition: border-color var(--t-fast), background var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
  min-height: 96px;
  justify-content: center;
}

.diff-card:hover .diff-card-inner {
  border-color: var(--c-primary);
  background: var(--c-primary-bg);
  transform: translateY(-2px);
}

/* Ausgewählte Karte – über :has() wenn verfügbar, sonst per JS-Klasse */
.diff-card:has(input:checked) .diff-card-inner,
.diff-card.is-selected .diff-card-inner {
  border-color: var(--c-primary);
  background: var(--c-primary-bg);
  box-shadow: 0 0 0 3px var(--c-primary-bd);
}

.diff-icon { font-size: 1.375rem; }

.diff-name {
  font-weight: 700;
  font-size: .875rem;
  color: var(--c-text);
}

.diff-desc {
  font-size: .7rem;
  color: var(--c-muted);
  text-align: center;
  line-height: 1.3;
}

/* -------------------------------------------------------------
   8. Buttons
   ------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-5);
  border: none;
  border-radius: var(--r-md);
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast), opacity var(--t-fast);
  min-height: 44px;
  text-decoration: none;
  user-select: none;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}

.btn:disabled {
  opacity: .45;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

.btn-primary {
  background: var(--c-primary);
  color: var(--c-primary-fg);
}
.btn-primary:hover:not(:disabled) {
  background: var(--c-primary-h);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.btn-primary:active:not(:disabled) { transform: scale(.97); }

.btn-secondary {
  background: var(--c-secondary);
  color: var(--c-secondary-fg);
  border: 1px solid var(--c-border);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--c-secondary-h);
  transform: translateY(-1px);
}
.btn-secondary:active:not(:disabled) { transform: scale(.97); }

.btn-ghost {
  background: transparent;
  color: var(--c-muted);
  border: 1px solid transparent;
}
.btn-ghost:hover:not(:disabled) {
  background: var(--c-surface-2);
  color: var(--c-text);
  border-color: var(--c-border);
}

.btn-large {
  width: 100%;
  padding: var(--sp-4) var(--sp-6);
  font-size: 1.1rem;
  border-radius: var(--r-lg);
  min-height: 56px;
}

.btn-sm {
  padding: var(--sp-2) var(--sp-3);
  font-size: .875rem;
  min-height: 36px;
}

/* -------------------------------------------------------------
   9. Spiel-Screen
   ------------------------------------------------------------- */
.game-card {
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
}

/* Spielinfo-Zeile */
.game-info {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-3);
  padding-bottom: var(--sp-4);
  border-bottom: 1px solid var(--c-border);
}

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

.info-label {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  font-weight: 600;
  color: var(--c-muted);
}

.info-value {
  font-size: 1.125rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  transition: color var(--t-fast);
}

/* Fortschrittsbalken */
.progress-track {
  height: 8px;
  background: var(--c-surface-2);
  border-radius: var(--r-full);
  overflow: hidden;
  border: 1px solid var(--c-border);
}

.progress-fill {
  height: 100%;
  border-radius: var(--r-full);
  background: var(--c-primary);
  width: 0%;
  transition: width var(--t-base), background-color var(--t-base);
}
.progress-fill.warn   { background: var(--c-warning); }
.progress-fill.danger { background: var(--c-error); }

/* Feedback-Box */
.feedback-box {
  min-height: 96px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  text-align: center;
  padding: var(--sp-4) var(--sp-5);
  background: var(--c-surface-2);
  border: 2px solid var(--c-border);
  border-radius: var(--r-lg);
  transition: background-color var(--t-base), border-color var(--t-base);
}

.feedback-box.state-higher {
  background: var(--c-higher-bg);
  border-color: var(--c-higher-bd);
}
.feedback-box.state-lower {
  background: var(--c-lower-bg);
  border-color: var(--c-lower-bd);
}
.feedback-box.state-correct {
  background: var(--c-ok-bg);
  border-color: var(--c-ok-bd);
}

.feedback-msg {
  font-size: 1.25rem;
  font-weight: 700;
  transition: color var(--t-fast);
}
.feedback-box.state-higher .feedback-msg { color: var(--c-higher); }
.feedback-box.state-lower  .feedback-msg { color: var(--c-lower);  }
.feedback-box.state-correct .feedback-msg { color: var(--c-success); }

.feedback-emoji { font-size: 1.75rem; min-height: 2rem; }

/* Schüttel-Animation bei Fehleingabe */
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%     { transform: translateX(-8px); }
  40%     { transform: translateX(8px); }
  60%     { transform: translateX(-6px); }
  80%     { transform: translateX(6px); }
}
.feedback-box.do-shake { animation: shake .4s ease; }

/* Eingabe-Bereich */
.input-area {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.input-label {
  font-weight: 600;
  font-size: .875rem;
  color: var(--c-muted);
}

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

.guess-input {
  flex: 1;
  padding: var(--sp-3) var(--sp-4);
  border: 2px solid var(--c-border);
  border-radius: var(--r-md);
  font-size: 1.75rem;
  font-weight: 700;
  text-align: center;
  font-family: var(--mono);
  background: var(--c-surface);
  color: var(--c-text);
  min-height: 60px;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  -moz-appearance: textfield;
}
.guess-input::-webkit-outer-spin-button,
.guess-input::-webkit-inner-spin-button { -webkit-appearance: none; }

.guess-input:focus {
  border-color: var(--c-primary);
  outline: none;
  box-shadow: 0 0 0 3px var(--c-primary-bd);
}
.guess-input.is-error {
  border-color: var(--c-error);
  box-shadow: 0 0 0 3px rgba(239,68,68,.25);
}

.input-error {
  font-size: .8rem;
  color: var(--c-error);
  min-height: 1.1rem;
  font-weight: 500;
}

/* On-Screen-Keyboard */
.onscreen-kb {
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  padding: var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.kb-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-2);
}

.kb-key {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  background: var(--c-surface);
  color: var(--c-text);
  font-size: 1.25rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: background-color var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.kb-key:hover  { background: var(--c-secondary-h); transform: translateY(-1px); }
.kb-key:active {
  transform: scale(.93);
  background: var(--c-primary);
  color: var(--c-primary-fg);
}

.kb-clear {
  background: rgba(245,158,11,.12);
  color: var(--c-warning);
  font-size: .95rem;
  font-weight: 800;
}
.kb-del {
  background: rgba(239,68,68,.10);
  color: var(--c-error);
}

.kb-submit {
  width: 100%;
  min-height: 52px;
  border-radius: var(--r-md);
  font-size: .95rem;
}

/* Hinweis-Bereich */
.hint-area {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.hint-controls {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 var(--sp-1);
  background: var(--c-primary);
  color: var(--c-primary-fg);
  border-radius: var(--r-full);
  font-size: .7rem;
  font-weight: 700;
}

.hint-cost {
  font-size: .75rem;
  color: var(--c-muted);
}

.hint-text {
  display: none;
  padding: var(--sp-3) var(--sp-4);
  background: var(--c-hint-bg);
  border: 1px solid var(--c-hint-bd);
  border-radius: var(--r-md);
  font-size: .9rem;
  font-weight: 500;
  color: var(--c-text);
  line-height: 1.4;
}
.hint-text.is-visible {
  display: block;
  animation: fadeUp var(--t-base) ease-out;
}

/* Verlauf */
.history-label {
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  font-weight: 700;
  color: var(--c-muted);
  margin-bottom: var(--sp-2);
}

.history-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

@keyframes popIn {
  from { transform: scale(.7); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

.history-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 10px;
  border-radius: var(--r-full);
  font-size: .8rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  animation: popIn var(--t-fast) ease-out;
}
.history-chip.h-higher {
  background: rgba(239,68,68,.15);
  color: var(--c-higher);
}
.history-chip.h-lower {
  background: rgba(59,130,246,.15);
  color: var(--c-lower);
}

/* Zurück-Button */
.back-btn {
  align-self: flex-start;
  font-size: .825rem;
}

/* Score-Flash-Animation */
@keyframes scoreFlash {
  0%,100% { color: var(--c-text); transform: scale(1); }
  50%     { color: var(--c-error); transform: scale(1.15); }
}
.score-flash { animation: scoreFlash .4s ease; }

/* -------------------------------------------------------------
   10. Modals
   ------------------------------------------------------------- */
.modal-overlay[hidden] { display: none; }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: var(--sp-4);
  animation: overlayIn var(--t-base) ease-out;
}

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

.modal {
  position: relative;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 400px;
  max-height: 90dvh;
  overflow-y: auto;
  animation: modalIn var(--t-base) ease-out;
}

.modal-lg { max-width: 460px; }

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

.modal-body {
  padding: var(--sp-8) var(--sp-6) var(--sp-6);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.modal-center {
  align-items: center;
  text-align: center;
}

.modal-close {
  position: absolute;
  top: var(--sp-4);
  right: var(--sp-4);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  background: var(--c-surface-2);
  color: var(--c-text);
  cursor: pointer;
  font-family: var(--font);
  transition: background-color var(--t-fast), transform var(--t-fast);
}
.modal-close:hover { background: var(--c-secondary-h); transform: rotate(90deg); }

/* Gewinn-Modal */
@keyframes bounceIn {
  0%   { transform: scale(0) rotate(-10deg); }
  60%  { transform: scale(1.2) rotate(5deg); }
  100% { transform: scale(1) rotate(0); }
}
.win-emoji,.over-emoji {
  font-size: 3.5rem;
  animation: bounceIn .5s cubic-bezier(.34,1.56,.64,1);
}

.modal-body h2 {
  font-size: 1.625rem;
  font-weight: 800;
}

/* Verlinkter Farbverlauf für Gewinn-Titel */
#win-heading {
  background: linear-gradient(135deg, var(--c-primary), var(--c-success));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.win-subtitle,.over-text {
  color: var(--c-muted);
  font-size: .9rem;
  max-width: 28ch;
}

.result-grid {
  display: flex;
  gap: var(--sp-3);
  width: 100%;
}

.result-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: var(--c-surface-2);
  border-radius: var(--r-lg);
  padding: var(--sp-3) var(--sp-2);
  border: 1px solid var(--c-border);
}

.result-label {
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  font-weight: 600;
  color: var(--c-muted);
}

.result-value {
  font-size: 1.375rem;
  font-weight: 800;
  color: var(--c-primary);
  font-variant-numeric: tabular-nums;
}

@keyframes pulse {
  0%,100% { transform: scale(1); }
  50%     { transform: scale(1.06); }
}
.new-record {
  background: linear-gradient(135deg, #f59e0b, #f97316);
  color: #fff;
  padding: var(--sp-2) var(--sp-5);
  border-radius: var(--r-full);
  font-size: .85rem;
  font-weight: 700;
  animation: pulse 1.2s infinite;
}

.modal-actions {
  display: flex;
  gap: var(--sp-3);
  width: 100%;
}
.modal-actions .btn { flex: 1; }

.share-row {
  display: flex;
  gap: var(--sp-2);
  width: 100%;
}

.share-input {
  flex: 1;
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  background: var(--c-surface-2);
  color: var(--c-text);
  font-size: .75rem;
  font-family: var(--mono);
}

/* Hilfe-Modal */
.help-sec {
  width: 100%;
}

.help-sec h3 {
  font-size: .9rem;
  font-weight: 700;
  color: var(--c-primary);
  margin-bottom: var(--sp-2);
  padding-bottom: var(--sp-1);
  border-bottom: 1px solid var(--c-border);
}

.help-sec ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.help-sec ul li {
  padding-left: var(--sp-4);
  position: relative;
  font-size: .875rem;
  color: var(--c-text);
  line-height: 1.4;
}

.help-sec ul li::before {
  content: '›';
  position: absolute;
  left: 0;
  color: var(--c-primary);
  font-weight: 700;
}

kbd {
  display: inline-block;
  padding: 1px 6px;
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  border-bottom-width: 2px;
  border-radius: 4px;
  font-family: var(--mono);
  font-size: .8em;
}

/* -------------------------------------------------------------
   11. Konfetti-Canvas
   ------------------------------------------------------------- */
#confetti-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 150;
}

/* -------------------------------------------------------------
   12. Footer
   ------------------------------------------------------------- */
.app-footer {
  background: var(--c-surface);
  border-top: 1px solid var(--c-border);
  padding: var(--sp-4);
  text-align: center;
  font-size: .8rem;
  color: var(--c-muted);
  margin-top: auto;
}

.app-footer a {
  color: var(--c-primary);
  text-decoration: none;
  font-weight: 500;
}
.app-footer a:hover { text-decoration: underline; }

/* -------------------------------------------------------------
   Update-Banner
   ------------------------------------------------------------- */
.update-banner {
  position: fixed;
  bottom: var(--sp-4);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-wrap: wrap;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: var(--sp-3) var(--sp-4);
  box-shadow: 0 4px 16px rgba(0,0,0,.15);
  font-size: .875rem;
  z-index: 200;
  max-width: calc(100vw - var(--sp-6));
}

.update-banner[hidden] { display: none; }

.update-banner-actions {
  display: flex;
  gap: var(--sp-2);
  flex-shrink: 0;
}

/* -------------------------------------------------------------
   13. Responsive Anpassungen
   ------------------------------------------------------------- */
@media (max-width: 360px) {
  .app-main { padding: var(--sp-3); gap: var(--sp-3); }
  .card     { padding: var(--sp-4); }

  .difficulty-grid { grid-template-columns: 1fr; gap: var(--sp-2); }
  .diff-card-inner  {
    flex-direction: row;
    min-height: auto;
    gap: var(--sp-3);
    padding: var(--sp-3);
  }

  .result-grid { flex-direction: column; }
  .modal-body  { padding: var(--sp-6) var(--sp-4) var(--sp-4); }
}

@media (min-width: 540px) {
  :root { --max-w: 520px; }
  .card { padding: var(--sp-8); }
}
