:root {
  --bg: #1b1b1b;
  --bg-soft: #1f1f1f;
  --nav-bg: rgba(27, 27, 27, 0.98);
  --card-bg: #242424;
  --card-hover: #2a2a2a;
  --border-color: #333333;
  --text: #ffffff;
  --text-muted: #8e8e93;
  --accent: #8354f7;
  --accent-hover: #9b72f9;
  --accent-tint: rgba(131, 84, 247, 0.12);
  --up: #34c759;
  --down: #ff3b30;
  --played: #6b7280;
  --radius: 8px;
  --radius-lg: 10px;
  --btn-radius: 6px;
  --font: "Montserrat", "Codec Pro", system-ui, -apple-system, sans-serif;
  --brand-gradient: linear-gradient(135deg, #8354f7, #9b72f9);
}

[data-theme="light"] {
  --bg: #f4f4f6;
  --bg-soft: #ececf0;
  --nav-bg: rgba(255, 255, 255, 0.97);
  --card-bg: #ffffff;
  --card-hover: #efeff2;
  --border-color: #e2e2e7;
  --text: #1c1c1e;
  --text-muted: #6b6b72;
  --up: #1f9d49;
  --down: #e02424;
  --played: #9aa0a8;
}

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

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100svh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  display: flex;
  justify-content: center;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
    env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.app {
  width: 100%;
  max-width: 520px;
  padding: 28px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* Kopfbereich ------------------------------------------------------------ */
.app__head {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand {
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: var(--brand-gradient);
  color: #fff;
  display: grid;
  place-items: center;
}

.brand svg {
  width: 26px;
  height: 26px;
}

.app__title {
  margin: 0;
  font-size: 1.7rem;
  font-weight: 800;
  letter-spacing: -1px;
  line-height: 1.1;
}

.app__sub {
  margin: 2px 0 0;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
}

/* Spielfeld -------------------------------------------------------------- */
.game {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.game__frame {
  position: relative;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  background: var(--card-bg);
  overflow: hidden;
  aspect-ratio: 420 / 640;
  width: min(100%, calc(var(--avail) * (420 / 640)));
  margin-inline: auto;
  box-shadow: 0 10px 30px rgba(131, 84, 247, 0.15);
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: manipulation;
  cursor: pointer;
}

/* HUD -------------------------------------------------------------------- */
.hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  padding: 14px 16px;
  pointer-events: none;
}

.hud__item {
  display: flex;
  flex-direction: column;
  background: var(--accent-tint);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 6px 12px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.hud__item:last-child {
  text-align: right;
}

.hud__label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.hud__value {
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

/* Overlays --------------------------------------------------------------- */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
  padding: 32px 26px;
  background: rgba(27, 27, 27, 0.82);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.overlay.is-active {
  opacity: 1;
  visibility: visible;
}

.overlay__title {
  margin: 0;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -1px;
  line-height: 1.1;
}

.overlay__text {
  margin: 0;
  max-width: 32ch;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.overlay__text strong {
  color: var(--accent-hover);
  font-weight: 800;
}

/* Komponenten ------------------------------------------------------------ */
.badge {
  display: inline-flex;
  align-items: center;
  margin: 0;
  padding: 4px 14px;
  border: 1px solid var(--accent);
  border-radius: 20px;
  background: var(--accent-tint);
  color: var(--accent-hover);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.badge--muted {
  border-color: var(--border-color);
  background: var(--card-hover);
  color: var(--text-muted);
}

.btn {
  min-height: 48px;
  padding: 0 28px;
  border: 1px solid transparent;
  border-radius: var(--btn-radius);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  transition: transform 0.2s ease, background-color 0.2s ease,
    border-color 0.2s ease;
}

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

.btn--primary:hover {
  background: var(--accent-hover);
  transform: translateY(-2px);
}

.btn:active {
  transform: translateY(0);
}

.btn:focus-visible {
  outline: none;
  border-color: #fff;
  box-shadow: 0 0 0 3px var(--accent-tint);
}

/* Hinweis & Fuß ---------------------------------------------------------- */
.hint {
  margin: 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 500;
}

.hint span {
  margin: 0 4px;
}

kbd {
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text);
  background: var(--card-hover);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 1px 6px;
}

.app__foot {
  display: flex;
  justify-content: space-between;
  padding-top: 14px;
  border-top: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
}

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

/* Zurück zur Spielhalle -------------------------------------------------- */
.backlink {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  align-self: flex-start;
  width: fit-content;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 700;
  transition: color 0.2s ease;
}

.backlink svg {
  width: 16px;
  height: 16px;
}

.backlink:hover {
  color: var(--accent-hover);
}

.backlink:focus-visible {
  outline: none;
  color: var(--accent-hover);
}


/* Vollbild-/Fokusmodus (mobile) --------------------------------------- */
:root {
  --avail: calc(100svh - 280px);
}

html.is-fs {
  --avail: calc(100dvh - 80px);
}
