/* Herzeln – Neon-Arcade-Variante (Rosé/Herz-Akzent). */

:root {
  --bg:       #0a0a14;
  --bg-2:     #2a0f1e;
  --fg:       #f3e9ef;
  --muted:    #b79aa8;
  --accent:   #ff4d6d;
  --accent-2: #ffb84d;
  --card-bg:  #f6f3ef;
  --card-ink: #16121a;
  --red:      #e23b5a;
  --board-bg: rgba(255, 255, 255, 0.04);
  --radius:   12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
  min-height: 100vh;
  background: radial-gradient(900px 500px at 50% -10%, var(--bg-2), var(--bg) 60%);
  color: var(--fg);
  font: 16px/1.5 ui-sans-serif, system-ui, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  display: flex; flex-direction: column; align-items: center;
  overscroll-behavior: none;
}
.bg-grid {
  position: fixed; inset: 0; z-index: -1;
  background-image:
    linear-gradient(rgba(255, 77, 109, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 184, 77, 0.05) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(800px 460px at 50% 0%, #000 30%, transparent 80%);
}

.top { width: 100%; max-width: 480px; padding: 1rem 1.1rem 0; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.back { color: var(--muted); text-decoration: none; font-weight: 600; letter-spacing: 0.03em; }
.back:hover { color: var(--accent); }

.wrap { width: 100%; max-width: 480px; padding: 0.4rem 1.1rem 2.5rem; display: flex; flex-direction: column; align-items: center; }
.game-title {
  margin: 0.3rem 0 0.6rem; font-size: clamp(1.8rem, 7vw, 2.5rem); font-weight: 900; letter-spacing: 0.04em;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 14px rgba(255, 77, 109, 0.4));
}

.btn {
  font: inherit; font-weight: 700; color: var(--fg);
  background: var(--board-bg); border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px; padding: 0.5rem 1rem; cursor: pointer;
  transition: border-color 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}
.btn:hover { border-color: var(--accent); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-primary { border-color: transparent; background: linear-gradient(90deg, var(--accent), var(--accent-2)); color: #2a0c12; box-shadow: 0 8px 24px -10px var(--accent); }

/* Punktestand */
.scoreboard { width: 100%; display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.4rem; margin-bottom: 0.7rem; }
.sb-chip {
  display: flex; flex-direction: column; align-items: center; gap: 0.05rem;
  padding: 0.35rem 0.3rem; border-radius: 10px; background: var(--board-bg);
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.sb-chip.sb--me { border-color: color-mix(in srgb, var(--accent) 50%, transparent); }
.sb-chip.sb--turn { box-shadow: 0 0 0 1px var(--accent), 0 0 18px -6px var(--accent); }
.sb-name { font-size: 0.72rem; font-weight: 700; color: var(--muted); }
.sb-chip.sb--me .sb-name { color: var(--accent); }
.sb-total { font-size: 1.2rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.sb-hand { font-size: 0.66rem; color: var(--muted); font-variant-numeric: tabular-nums; }

/* Tisch / Stich */
.table {
  width: 100%; aspect-ratio: 5 / 3; max-height: 42vh;
  background: radial-gradient(circle at 50% 45%, rgba(255,77,109,0.10), transparent 70%), var(--board-bg);
  border: 1px solid rgba(255, 255, 255, 0.08); border-radius: var(--radius);
  margin-bottom: 0.5rem; position: relative;
}
.trick { position: absolute; inset: 0; display: grid; grid-template-columns: 1fr 1fr 1fr; grid-template-rows: 1fr 1fr 1fr;
  grid-template-areas: ". top ." "left . right" ". bottom ."; place-items: center; padding: 0.4rem; }
.slot { display: flex; flex-direction: column; align-items: center; gap: 0.15rem; }
.slot-top { grid-area: top; } .slot-left { grid-area: left; } .slot-right { grid-area: right; } .slot-bottom { grid-area: bottom; }
.slot-name { font-size: 0.66rem; color: var(--muted); font-weight: 700; }
.slot--lead .slot-name { color: var(--accent-2); }
.slot-card { min-height: 1px; }

/* Karten */
.card {
  display: inline-flex; flex-direction: column; align-items: center; justify-content: space-between;
  width: 2.5rem; height: 3.5rem; padding: 0.2rem 0.1rem;
  background: var(--card-bg); color: var(--card-ink);
  border-radius: 7px; border: 1px solid rgba(0,0,0,0.2);
  font-weight: 800; line-height: 1; box-shadow: 0 2px 6px -2px rgba(0,0,0,0.6);
  user-select: none;
}
.c-rank { font-size: 0.95rem; }
.c-suit { font-size: 1.15rem; }
.card.s-heart, .card.s-diamond { color: var(--red); }
.card.s-club, .card.s-spade { color: #1b2433; }

/* Hand */
.hand { display: flex; justify-content: center; flex-wrap: wrap; gap: 0.15rem; min-height: 3.6rem; padding: 0.2rem 0; }
.hand .card { cursor: default; transition: transform 0.1s ease, box-shadow 0.12s ease, opacity 0.12s ease; }
.hand .card--ok { cursor: pointer; }
.hand .card--ok:hover { transform: translateY(-6px); box-shadow: 0 8px 18px -6px var(--accent); }
.hand .card--dim { opacity: 0.4; filter: saturate(0.6); }
.hand .card--sel { transform: translateY(-8px); box-shadow: 0 0 0 2px var(--accent), 0 8px 18px -6px var(--accent); }

.msg { width: 100%; text-align: center; color: var(--muted); font-size: 0.9rem; min-height: 1.3em; margin: 0.2rem 0 0.5rem; }
.actions { display: flex; gap: 0.7rem; justify-content: center; min-height: 1px; }

/* Overlay / Ergebnis */
.overlay {
  position: fixed; inset: 0; z-index: 30;
  display: flex; align-items: center; justify-content: center; padding: 1rem;
  background: rgba(8, 8, 16, 0.78); backdrop-filter: blur(4px); animation: fade-in 0.2s ease;
}
.overlay[hidden] { display: none; }
.overlay-card {
  position: relative; width: 100%; max-width: 360px; text-align: center;
  background: linear-gradient(180deg, var(--bg-2), var(--bg));
  border: 1px solid rgba(255, 255, 255, 0.12); border-radius: 16px;
  padding: 1.4rem 1.3rem; box-shadow: 0 24px 70px -20px #000, 0 0 50px -22px var(--accent);
}
.overlay-close {
  position: absolute; top: 0.6rem; right: 0.6rem; width: 1.9rem; height: 1.9rem; border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.16); background: rgba(255, 255, 255, 0.05);
  color: var(--muted); font-size: 0.9rem; font-weight: 800; cursor: pointer; line-height: 1;
}
.overlay-close:hover { color: var(--fg); border-color: var(--accent); }
.overlay-title {
  margin: 0 0 0.3rem; font-size: clamp(1.5rem, 7vw, 2rem); font-weight: 900;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.overlay-sub { margin: 0 0 0.8rem; color: var(--muted); }
.result { margin: 0.6rem 0 1rem; }
.res-row { display: flex; justify-content: space-between; padding: 0.3rem 0.6rem; border-radius: 8px; font-weight: 700; }
.res-row--me { background: rgba(255, 77, 109, 0.14); color: var(--fg); }
.res-row span:last-child { font-variant-numeric: tabular-nums; }

.lb-form { margin: 0.3rem 0 1rem; }
.lb-form-label { display: block; font-size: 0.8rem; font-weight: 700; color: var(--accent); margin-bottom: 0.4rem; }
.lb-form-row { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: center; }
#hz-name {
  flex: 1; min-width: 7rem; font: inherit; font-weight: 700; color: var(--fg);
  background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.16); border-radius: 10px; padding: 0.55rem 0.7rem;
}
#hz-name:focus { outline: none; border-color: var(--accent); }
.lb-result { margin: 0 0 1rem; font-weight: 800; color: var(--accent); }
.overlay-actions { display: flex; gap: 0.7rem; justify-content: center; }

/* Bestenliste */
.leaderboard { width: 100%; max-width: 480px; margin-top: 1.4rem; }
.lb-title { margin: 0 0 0.2rem; font-size: 0.72rem; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent); }
.lb-sub { margin: 0 0 0.7rem; font-size: 0.8rem; color: var(--muted); }
.lb-list { list-style: none; margin: 0; padding: 0; }
.lb-empty { color: var(--muted); font-size: 0.9rem; padding: 0.4rem 0; }
.lb-row {
  display: grid; grid-template-columns: 2.6rem 1fr auto; align-items: center; gap: 0.6rem;
  padding: 0.5rem 0.7rem; margin-bottom: 0.35rem;
  border: 1px solid rgba(255, 255, 255, 0.07); border-radius: 10px; background: var(--board-bg);
}
.lb-rank { font-weight: 800; color: var(--muted); font-variant-numeric: tabular-nums; }
.lb-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-score { font-weight: 800; font-variant-numeric: tabular-nums; }
.lb-row--me { border-color: color-mix(in srgb, var(--accent) 65%, transparent); box-shadow: 0 0 22px -10px var(--accent); }

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .overlay { animation: none; } }
