/* Swipe Safe – Layout und Darstellung (Hochformat, iPhone-Safari).
   Bewegung der Karte läuft nur über transform und opacity. */

:root {
  --arbeit: #7db6ea;
  --privat: #bfa3f0;
  --muell: #f2808c;
  --cyan: #5fcfe6;
  --richtig: #5fd3aa;
  --falsch: #f27f8b;
  --tinte: #0b1020;
  --paneel: rgba(8, 12, 28, 0.8);
  --rand-hell: rgba(255, 255, 255, 0.18);
  --card-w: clamp(160px, min(70vw, calc((100dvh - 230px) / 1.4)), 340px);
  --card-h: calc(var(--card-w) * 1.4);
  --abstand: 16px;
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  background: #05070f;
  color: #fff;
  font-family: system-ui, -apple-system, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  font-size: 100%;
  -webkit-text-size-adjust: 100%;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

body {
  position: fixed;
  inset: 0;
  width: 100%;
}

h1,
p,
ul {
  margin: 0;
  padding: 0;
}

ul {
  list-style: none;
}

[hidden] {
  display: none !important;
}

.sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Sichtbarer Fokus für alle bedienbaren Elemente. */
button:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 3px;
}

/* ---------- Rahmen und Bildschirme ---------- */

.app {
  position: fixed;
  inset: 0;
  z-index: 1;
  width: 100%;
  max-width: 520px;
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top);
  padding-right: env(safe-area-inset-right);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  animation: einblenden 0.25s ease-out;
}

.screen:focus {
  outline: none;
}

@keyframes einblenden {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

/* ---------- Schaltflächen ---------- */

.button {
  min-width: 12rem;
  min-height: 3.25rem;
  padding: 0.75rem 2rem;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--cyan), #b9a8f0);
  color: var(--tinte);
  font: inherit;
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  cursor: pointer;
  box-shadow: 0 8px 28px rgba(150, 120, 230, 0.30);
  transition: transform 0.12s ease-out;
}

.button:active {
  transform: scale(0.96);
}

/* ---------- Startseite ---------- */

.screen-start,
.screen-interlude,
.screen-result {
  align-items: center;
  justify-content: center;
  gap: 1.1rem;
  padding-left: max(var(--abstand), env(safe-area-inset-left));
  padding-right: max(var(--abstand), env(safe-area-inset-right));
  text-align: center;
}

.start-title {
  font-size: clamp(2.6rem, 14vw, 3.6rem);
  font-weight: 900;
  letter-spacing: -0.01em;
  background: linear-gradient(90deg, var(--cyan), #b9a8f0);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.start-intro {
  max-width: 22rem;
  font-size: 1.05rem;
  line-height: 1.4;
}

.legend {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  width: min(100%, 22rem);
}

.legend-item {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas:
    "icon label"
    "icon hint";
  column-gap: 0.9rem;
  align-items: center;
  padding: 0.65rem 1rem;
  border: 2px solid var(--akzent);
  border-radius: 1rem;
  background: var(--paneel);
  text-align: start;
}

.legend-arbeit {
  --akzent: var(--arbeit);
}

.legend-privat {
  --akzent: var(--privat);
}

.legend-muell {
  --akzent: var(--muell);
}

.legend-icon {
  grid-area: icon;
  width: 2.4rem;
  height: 2.4rem;
  color: var(--akzent);
}

.legend-label {
  grid-area: label;
  font-size: 1.1rem;
  font-weight: 800;
}

.legend-hint {
  grid-area: hint;
  font-size: 0.9rem;
  color: #d5dbea;
}

.keyboard-hint {
  font-size: 0.85rem;
  color: #c3cadb;
}

@media (hover: none) and (pointer: coarse) {
  .keyboard-hint {
    display: none;
  }
}

/* ---------- Spielbildschirm: Kopf ---------- */

.screen-game {
  display: grid;
  grid-template-rows: auto 1fr;
}

.hud {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem max(var(--abstand), env(safe-area-inset-right)) 0.75rem max(var(--abstand), env(safe-area-inset-left));
  background: linear-gradient(rgba(5, 7, 15, 0.7), rgba(5, 7, 15, 0));
}

.brand {
  font-size: 0.95rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #d5dbea;
}

.level-name {
  margin-top: 0.15rem;
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
}

.score-row {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  margin-top: 0.2rem;
  min-height: 1.8rem;
}

.score {
  font-size: 1.4rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.gain {
  font-size: 1.15rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(90deg, var(--cyan), #cfa8f5);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.15s ease-out, transform 0.15s ease-out;
}

.gain.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.timer {
  flex: none;
  padding: 0.3rem 0.85rem;
  border: 2px solid var(--rand-hell);
  border-radius: 999px;
  background: var(--paneel);
  font-size: 1.6rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

/* ---------- Spielbildschirm: Spielfläche und Karte ---------- */

.stage {
  position: relative;
  min-height: 0;
  touch-action: none;
}

.card {
  position: absolute;
  top: 50%;
  left: 50%;
  width: var(--card-w);
  height: var(--card-h);
  margin-top: calc(var(--card-h) / -2);
  margin-left: calc(var(--card-w) / -2);
  border-radius: 2rem;
  background: #f1f5f8;
  color: #374151;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.45), 0 0 20px 6px rgba(170, 205, 235, 0.35);
  will-change: transform, opacity;
  touch-action: none;
}

/* Farbige Leuchtränder liegen übereinander und werden nur über opacity eingeblendet. */
.card-glow {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  opacity: 0;
  pointer-events: none;
}

.card-glow-arbeit {
  box-shadow: 0 0 0 4px var(--arbeit), 0 0 20px 8px rgba(125, 182, 234, 0.6);
}

.card-glow-privat {
  box-shadow: 0 0 0 4px var(--privat), 0 0 20px 8px rgba(191, 163, 240, 0.6);
}

.card-glow-muell {
  box-shadow: 0 0 0 4px var(--muell), 0 0 20px 8px rgba(242, 128, 140, 0.6);
}

.card-face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 1.6rem 1.1rem 1.4rem;
  border-radius: inherit;
}

/* Zierwinkel: oben rechts cyan, unten links lila. */
.card-face::before,
.card-face::after {
  content: "";
  position: absolute;
  width: 1.7rem;
  height: 1.7rem;
  pointer-events: none;
}

.card-face::before {
  top: 0.9rem;
  right: 0.9rem;
  border-top: 3px solid #7fc6dc;
  border-right: 3px solid #7fc6dc;
  border-top-right-radius: 0.9rem;
}

.card-face::after {
  bottom: 0.9rem;
  left: 0.9rem;
  border-bottom: 3px solid #b9a4e6;
  border-left: 3px solid #b9a4e6;
  border-bottom-left-radius: 0.9rem;
}

.card-icon {
  width: 52%;
  aspect-ratio: 1;
}

.card-icon svg {
  display: block;
  width: 100%;
  height: 100%;
}

.card-name {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  min-height: 2.4em;
  max-width: 100%;
  font-size: clamp(0.95rem, 4.6vw, 1.3rem);
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
  overflow-wrap: anywhere;
}

.card-meta {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: #656d7c;
  text-align: center;
}

/* ---------- Rückmeldung Richtig/Falsch ---------- */

.feedback {
  position: absolute;
  top: 50%;
  left: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding: 1.1rem 1.8rem;
  border-radius: 1.6rem;
  background: var(--paneel);
  border: 3px solid var(--farbe, var(--richtig));
  color: #fff;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.7);
  transition: opacity 0.12s ease-out, transform 0.12s ease-out;
  pointer-events: none;
}

.feedback.is-visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.feedback.is-richtig {
  --farbe: var(--richtig);
}

.feedback.is-falsch {
  --farbe: var(--falsch);
}

.feedback-icon {
  width: 4.2rem;
  height: 4.2rem;
  color: var(--farbe);
}

.feedback-text {
  font-size: 1.7rem;
  font-weight: 900;
}

/* ---------- Zwischenseite ---------- */

.interlude-kicker {
  font-size: 0.9rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--cyan);
}

.interlude-title {
  max-width: 18rem;
  font-size: clamp(1.8rem, 8vw, 2.4rem);
  font-weight: 900;
  line-height: 1.15;
}

.interlude-hint {
  color: #d5dbea;
}

.interlude-bar {
  width: min(70%, 14rem);
  height: 0.5rem;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.2);
}

.interlude-bar-fill {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--cyan), #b9a8f0);
  transform-origin: left center;
  animation: balken 2s linear forwards;
}

@keyframes balken {
  from {
    transform: scaleX(0);
  }

  to {
    transform: scaleX(1);
  }
}

/* ---------- Ergebnis ---------- */

.result-title {
  font-size: 2rem;
  font-weight: 900;
}

.result-total-label {
  margin-bottom: -0.6rem;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #d5dbea;
}

.result-total {
  font-size: clamp(2.2rem, 11vw, 3rem);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(90deg, var(--cyan), #cfa8f5);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.result-table {
  width: min(100%, 22rem);
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
  border: 2px solid var(--rand-hell);
  border-radius: 1rem;
  background: var(--paneel);
  font-size: 0.95rem;
}

.result-table th,
.result-table td {
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid var(--rand-hell);
}

.result-table tfoot th,
.result-table tfoot td,
.result-table tbody tr:last-child th,
.result-table tbody tr:last-child td {
  border-bottom: 0;
}

.result-table tfoot th,
.result-table tfoot td {
  border-top: 2px solid var(--rand-hell);
  font-weight: 900;
}

.result-table th {
  text-align: start;
  font-weight: 700;
}

.result-table thead th {
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #d5dbea;
}

.result-table .num {
  text-align: end;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

.result-table td.good {
  color: var(--richtig);
}

.result-table td.bad {
  color: var(--falsch);
}

/* ---------- Bewegung reduzieren ---------- */

@media (prefers-reduced-motion: reduce) {
  .screen,
  .interlude-bar-fill {
    animation: none;
  }

  .gain,
  .feedback,
  .button {
    transition: none;
  }
}
