/* Wortgarten – Buchstabenkreis + Kreuzwort. App-Shell: randlos, kein Scroll. */
:root {
  --bg: #0a0a14;
  --fg: #eef2f0;
  --muted: #93a29c;
  --accent: #43c59e;       /* Jade */
  --accent-2: #7ce0bf;
  --board-bg: #141b1f;
  --tile-bg: #1b2429;
  --tile-empty: #0f1518;
  --tile-found: #1f5a48;
  --tile-ink: #ecfff8;
  --letter-bg: #17323a;
  --letter-on: #43c59e;
  --danger: #d9805a;
  --radius: 14px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  min-height: 100dvh; height: 100dvh; overflow: hidden;
  background: var(--bg); color: var(--fg);
  display: flex; flex-direction: column; align-items: center;
  -webkit-user-select: none; user-select: none; touch-action: manipulation;
}
.bg-grid {
  position: fixed; inset: 0; z-index: -1; opacity: 0.5;
  background:
    radial-gradient(circle at 50% 0%, rgba(67,197,158,0.12), transparent 60%),
    repeating-linear-gradient(0deg, rgba(255,255,255,0.03) 0 1px, transparent 1px 40px),
    repeating-linear-gradient(90deg, rgba(255,255,255,0.03) 0 1px, transparent 1px 40px);
}

/* --- Kopf --------------------------------------------------------------- */
.top {
  flex: 0 0 auto; width: 100%; max-width: 720px;
  padding: 0.5rem 1.1rem 0; display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.back { color: var(--muted); text-decoration: none; font-weight: 700; font-size: 0.95rem; white-space: nowrap; }
.back:hover { color: var(--accent); }
.game-title { margin: 0; font-size: 1.15rem; font-weight: 800; letter-spacing: 0.02em; color: var(--accent); text-align: center; }
.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.45rem 0.9rem; cursor: pointer;
  white-space: nowrap;
}
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { border-color: transparent; background: linear-gradient(90deg, var(--accent), var(--accent-2)); color: #06231a; }

/* --- Layout ------------------------------------------------------------- */
.wrap {
  flex: 1 1 auto; min-height: 0; width: 100%; max-width: 720px;
  padding: 0.4rem 0.9rem 0.5rem; display: flex; flex-direction: column; align-items: stretch; gap: 0.4rem;
}
.hud { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; }
.seg { display: inline-flex; background: var(--board-bg); border: 1px solid rgba(255,255,255,0.1); border-radius: 999px; padding: 0.15rem; }
.seg-btn { font: inherit; font-size: 0.82rem; font-weight: 700; color: var(--muted); background: none; border: 0; padding: 0.3rem 0.7rem; border-radius: 999px; cursor: pointer; }
.seg-btn.seg--on { color: #06231a; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.stats { display: flex; gap: 0.9rem; font-size: 0.86rem; color: var(--muted); }
.stats b { color: var(--fg); font-variant-numeric: tabular-nums; }
.stat-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; }

/* --- Gitter ------------------------------------------------------------- */
.stage { flex: 1 1 auto; min-height: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.board {
  display: grid;
  grid-template-columns: repeat(var(--cols, 1), var(--cell, 28px));
  grid-auto-rows: var(--cell, 28px);
  gap: var(--gap, 3px);
}
.cell { width: var(--cell); height: var(--cell); }
.tile {
  width: var(--cell); height: var(--cell);
  display: flex; align-items: center; justify-content: center;
  background: var(--tile-empty);
  border: 1px solid rgba(67,197,158,0.28); border-radius: calc(var(--cell) * 0.14);
  font-weight: 800; font-size: calc(var(--cell) * 0.56); line-height: 1;
  color: transparent; text-transform: uppercase;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}
.tile.filled { background: var(--tile-found); color: var(--tile-ink); border-color: var(--accent); }
/* Tipp: Buchstabe sichtbar, aber deutlich anders als gefundene Wörter –
   gestrichelter Rand (Form-Unterschied, nicht nur Farbe → farbblind-sicher). */
.tile.hint { color: var(--accent-2); background: rgba(124,224,191,0.1); border-color: var(--accent-2); border-style: dashed; }
.tile.pop { animation: wg-pop 0.34s ease; }
@keyframes wg-pop { 0% { transform: scale(0.5); } 60% { transform: scale(1.18); } 100% { transform: scale(1); } }

/* --- Meldung ------------------------------------------------------------ */
.msg { flex: 0 0 auto; min-height: 1.3rem; margin: 0; text-align: center; font-size: 0.9rem; font-weight: 700; color: var(--accent-2); }
.msg.bad { color: var(--danger); }

/* --- Buchstabenkreis ---------------------------------------------------- */
.wheelwrap { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: 0.35rem; }
.preview {
  min-height: 2rem; padding: 0.15rem 0.9rem; border-radius: 999px;
  font-size: 1.35rem; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--fg); background: rgba(0,0,0,0.25); min-width: 3rem; text-align: center;
  display: flex; align-items: center; justify-content: center;
}
.preview.bad { color: var(--danger); }
.preview:empty { opacity: 0; }
.wheel {
  position: relative; width: var(--wheel, 240px); height: var(--wheel, 240px);
  border-radius: 50%;
  background: radial-gradient(circle at 50% 42%, #123, #0c1418 72%);
  border: 1px solid rgba(255,255,255,0.07);
  touch-action: none;
}
.wheel-lines { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.wheel-lines line, .wheel-lines polyline { stroke: var(--accent); stroke-width: 6; stroke-linecap: round; stroke-linejoin: round; fill: none; opacity: 0.85; }
.letter {
  position: absolute; top: 0; left: 0;
  width: var(--lsize, 46px); height: var(--lsize, 46px); margin: calc(var(--lsize, 46px) / -2) 0 0 calc(var(--lsize, 46px) / -2);
  display: flex; align-items: center; justify-content: center;
  background: var(--letter-bg); color: var(--fg);
  border: 1px solid rgba(255,255,255,0.12); border-radius: 50%;
  font-size: calc(var(--lsize, 46px) * 0.46); font-weight: 800; text-transform: uppercase;
  cursor: pointer; transition: transform 0.1s ease, background 0.1s ease;
}
.letter.on { background: var(--letter-on); color: #06231a; transform: scale(1.12); }
.wheel-actions { display: flex; gap: 0.8rem; }
.btn-round { position: relative; width: 2.6rem; height: 2.6rem; padding: 0; border-radius: 50%; font-size: 1.1rem; display: flex; align-items: center; justify-content: center; }
/* Frei-Tipp-Zähler auf dem 💡-Knopf */
.hint-badge { position: absolute; top: -4px; right: -4px; min-width: 1.05rem; height: 1.05rem; padding: 0 0.2rem; display: flex; align-items: center; justify-content: center; background: var(--accent); color: #06231a; border-radius: 999px; font-size: 0.66rem; font-weight: 800; line-height: 1; }
#hint.hint-locked { border-color: rgba(217,128,90,0.6); }   /* keine Frei-Tipps mehr: nächster Tipp kostet die Wertung */

/* --- Bestenliste (wandert per arcade-scores ins Modal) ------------------ */
.leaderboard { width: 100%; max-width: 720px; }
.wrap > .leaderboard { display: none; }
.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); }

/* --- Overlay ------------------------------------------------------------ */
.overlay { position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center; padding: 1rem; background: rgba(4,8,10,0.72); backdrop-filter: blur(3px); }
.overlay[hidden] { display: none; }
.overlay-card { position: relative; width: min(94vw, 380px); background: var(--board-bg); border: 1px solid rgba(255,255,255,0.1); border-radius: 18px; padding: 1.4rem 1.3rem; text-align: center; box-shadow: 0 24px 60px -20px rgba(0,0,0,0.8); }
.overlay-close { position: absolute; top: 0.6rem; right: 0.6rem; width: 1.9rem; height: 1.9rem; border-radius: 8px; background: none; border: 1px solid rgba(255,255,255,0.14); color: var(--muted); font-weight: 800; cursor: pointer; }
.overlay-title { margin: 0.2rem 0 0.3rem; font-size: 1.5rem; color: var(--accent); }
.overlay-sub { margin: 0 0 0.9rem; color: var(--muted); }
.garden { font-size: 2.4rem; letter-spacing: 0.1em; margin: 0.3rem 0 0.7rem; }
.overlay-actions { display: flex; gap: 0.7rem; justify-content: center; flex-wrap: wrap; }
.lb-form { margin: 0.6rem 0; }
.lb-form-label { display: block; font-size: 0.82rem; color: var(--muted); margin-bottom: 0.4rem; }
.lb-form-row { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: center; }
.lb-form-row input { flex: 1; min-width: 7rem; font: inherit; font-weight: 700; color: var(--fg); background: var(--tile-bg); border: 1px solid rgba(255,255,255,0.16); border-radius: 10px; padding: 0.5rem 0.7rem; }
.lb-result { color: var(--accent-2); font-weight: 700; margin: 0.3rem 0; }
.hint-reward { color: var(--accent-2); font-weight: 700; margin: 0.2rem 0 0.4rem; font-size: 0.92rem; }
.lb-locked { margin: 0.5rem 0; padding: 0.5rem 0.7rem; border-radius: 10px; background: rgba(217,128,90,0.12); border: 1px solid rgba(217,128,90,0.4); color: #e7b39c; font-size: 0.86rem; }

/* Schmale Schirme: Kopfzeile kompakter, damit „Neuer Garten" nicht abschneidet. */
@media (max-width: 430px) {
  .top { padding: 0.5rem 0.7rem 0; gap: 0.5rem; }
  .game-title { font-size: 1rem; }
  .top .btn { padding: 0.4rem 0.6rem; font-size: 0.85rem; }
  .back { font-size: 0.9rem; }
}

/* Querformat mit Breite (Tablet quer, Desktop): Gitter LINKS, Kreis RECHTS –
   nutzt den horizontalen Platz, statt alles in eine schmale Mittelspalte zu
   quetschen (sonst wird das Gitter oben/unten abgeschnitten). */
@media (orientation: landscape) and (min-width: 740px) and (min-height: 600px) {
  .wrap {
    display: grid; column-gap: 1rem;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto 1fr auto;
    grid-template-areas: "hud hud" "stage wheel" "msg msg";
  }
  .hud { grid-area: hud; }
  .stage { grid-area: stage; }
  .wheelwrap { grid-area: wheel; justify-content: center; }
  .msg { grid-area: msg; }
  .wrap { max-width: 1120px; }
}

/* Flaches Handy-Querformat: Gitter neben den Kreis, wenig Höhe. */
@media (orientation: landscape) and (max-height: 560px) {
  .wrap { flex-direction: row; flex-wrap: wrap; align-items: center; }
  .hud { flex: 1 0 100%; }
  .stage { flex: 1 1 50%; }
  .wheelwrap { flex: 1 1 40%; }
}
