/* LassZocken – Kinder-App (mobile-first, 360–430 px optimiert) */

.child-app main {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: calc(16px + var(--safe-top)) calc(16px + var(--safe-right)) calc(24px + var(--safe-bottom)) calc(16px + var(--safe-left));
}

.screen { display: grid; gap: var(--space-5); animation: screen-in 0.22s ease-out; }
.screen-center { min-height: 70dvh; place-items: center; }
@keyframes screen-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.screen h1:focus { outline: none; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }

.headline { font-size: var(--fs-xl); font-weight: 800; }
.headline-sub { color: var(--text-2); margin-top: 6px; }

/* ---------- Profilauswahl ---------- */

.profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: var(--space-4);
}

.profile-card {
  position: relative;
  display: grid;
  justify-items: center;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-3);
  border-radius: var(--radius-lg);
  border: 2px solid color-mix(in srgb, var(--accent) 55%, transparent);
  background:
    linear-gradient(160deg, color-mix(in srgb, var(--accent) 22%, transparent), transparent 70%),
    var(--surface);
  cursor: pointer;
  min-height: 190px;
  box-shadow: var(--shadow);
  transition: transform 0.12s ease, border-color 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.profile-card:hover { transform: translateY(-2px); border-color: var(--accent); }
.profile-card:active { transform: scale(0.98); }
.profile-card .name { font-size: 1.4rem; font-weight: 800; }
.profile-card .meta { font-size: var(--fs-xs); color: var(--text-3); }

.avatar {
  width: 96px; height: 96px;
  display: grid; place-items: center;
  background: var(--accent);
  clip-path: polygon(14% 0, 86% 0, 100% 14%, 100% 86%, 86% 100%, 14% 100%, 0 86%, 0 14%);
}
.avatar img { width: 70%; height: 70%; }
.avatar-sm { width: 48px; height: 48px; }

.parent-link {
  justify-self: center;
  display: inline-flex; align-items: center; gap: 8px;
  min-height: var(--tap); padding: 8px 14px;
  color: var(--text-3); font-size: var(--fs-sm); text-decoration: none; border-radius: var(--radius-sm);
}
.parent-link:hover { color: var(--text-2); background: var(--hover); }
.parent-link svg { width: 16px; height: 16px; }

/* ---------- PIN ---------- */

.pin-wrap { display: grid; justify-items: center; gap: var(--space-4); text-align: center; }
.pin-dots { display: flex; gap: 14px; min-height: 28px; }
.pin-dot {
  width: 20px; height: 20px; border-radius: 5px;
  border: 2px solid var(--line-strong); background: transparent;
  transition: background-color 0.1s ease, transform 0.1s ease;
}
.pin-dot.filled { background: var(--accent, var(--brand)); border-color: var(--accent, var(--brand)); transform: scale(1.05); }
.pin-dot.optional { border-style: dashed; opacity: 0.6; }
.pin-wrap.shake .pin-dots { animation: shake 0.35s; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.pin-error { min-height: 1.5em; color: var(--error-text); font-weight: 600; }

.keypad {
  display: grid;
  grid-template-columns: repeat(3, minmax(72px, 96px));
  gap: 12px;
  justify-content: center;
}
.key {
  height: 68px;
  border-radius: var(--radius);
  border: 2px solid var(--line-strong);
  background: var(--surface-2);
  font-size: 1.6rem; font-weight: 700;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.key:active { background: var(--surface-3); transform: scale(0.97); }
.key-action { font-size: 1rem; background: transparent; }
.key-ok { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); font-size: 1.1rem; }
.key[disabled] { opacity: 0.4; }

/* ---------- Spielauswahl ---------- */

.game-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-2);
}
@media (min-width: 520px) { .game-grid { grid-template-columns: repeat(4, 1fr); } }

.game-tile {
  position: relative;
  display: grid;
  grid-template-rows: auto auto;
  justify-items: center;
  align-content: center;
  gap: 6px;
  padding: 10px 6px;
  min-height: 88px;
  border-radius: var(--radius-sm);
  border: 2px solid color-mix(in srgb, var(--accent) 35%, var(--line));
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent) 26%, transparent), transparent 65%),
    var(--surface);
  text-align: center;
  cursor: pointer;
  transition: transform 0.1s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.game-tile::after {
  /* Pixel-Ecke */
  content: ""; position: absolute; right: 6px; top: 6px; width: 5px; height: 5px;
  background: var(--accent); opacity: 0.6;
  box-shadow: -7px 0 0 color-mix(in srgb, var(--accent) 40%, transparent), 0 7px 0 color-mix(in srgb, var(--accent) 40%, transparent);
}
.game-tile:hover { border-color: var(--accent); }
.game-tile:active { transform: scale(0.98); }
.game-tile[aria-checked="true"] {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 45%, transparent), var(--shadow);
}
.game-tile[aria-checked="true"]::before {
  content: "✓"; position: absolute; right: 5px; top: 5px;
  width: 20px; height: 20px; border-radius: 6px; display: grid; place-items: center;
  background: var(--accent); color: var(--bg); font-weight: 900; font-size: 0.75rem;
}
.game-art {
  width: 60px; height: 60px; display: grid; place-items: center;
  background: var(--accent);
  clip-path: polygon(12% 0, 88% 0, 100% 12%, 100% 88%, 88% 100%, 12% 100%, 0 88%, 0 12%);
}
.game-art img { width: 72%; height: 72%; }
.game-tile .game-art { width: 40px; height: 40px; }
.game-name { font-weight: 750; font-size: 0.875rem; line-height: 1.15; overflow-wrap: anywhere; }

.start-bar {
  position: sticky;
  bottom: calc(12px + var(--safe-bottom));
  z-index: 5;
}
.start-bar .btn { box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); }

.stats-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }
.stat { padding: var(--space-3) var(--space-4); border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); }
.stat .label { font-size: var(--fs-xs); color: var(--text-3); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.stat .value { font-size: 1.15rem; font-weight: 750; margin-top: 2px; }
.stat-wide { width: 100%; }

/* ---------- Tageskontingent ---------- */

.quota {
  width: 100%;
  display: grid; gap: var(--space-2);
  padding: var(--space-4);
  border-radius: var(--radius);
  border: 2px solid color-mix(in srgb, var(--ok) 45%, var(--line));
  background: linear-gradient(135deg, color-mix(in srgb, var(--ok) 14%, transparent), transparent 70%), var(--surface);
  text-align: left;
}
.quota-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-3); }
.quota .label { font-size: var(--fs-xs); color: var(--text-3); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.quota-of { font-size: var(--fs-xs); color: var(--text-3); }
.quota-value { font-size: 1.6rem; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--ok); }
.quota-bar { height: 10px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.quota-bar span { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--ok); transition: width 0.4s ease; }
.quota-warn { font-weight: 700; color: var(--error-text); }
.quota.quota-low { border-color: color-mix(in srgb, var(--warn) 60%, var(--line)); background: linear-gradient(135deg, color-mix(in srgb, var(--warn) 16%, transparent), transparent 70%), var(--surface); }
.quota.quota-low .quota-value { color: var(--warn); }
.quota.quota-low .quota-bar span { background: var(--warn); }
.quota.quota-over { border-color: var(--danger); background: linear-gradient(135deg, color-mix(in srgb, var(--danger) 22%, transparent), transparent 70%), var(--surface); }
.quota.quota-over .quota-value { color: var(--danger); }
.quota.quota-over .quota-bar span { background: var(--danger); }
.quota.quota-over .label { color: var(--error-text); }

.honest-note { font-size: var(--fs-xs); color: var(--text-3); text-align: center; }

.child-footer { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-2); }

/* ---------- Aktiv-Screen ---------- */

.active-screen { text-align: center; justify-items: center; }
.live-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 14px; border-radius: 999px;
  background: rgba(74, 222, 128, 0.14); color: var(--ok); font-weight: 750; font-size: var(--fs-sm);
}
.live-pill .dot { width: 10px; height: 10px; border-radius: 3px; background: var(--ok); animation: pulse 1.6s ease-in-out infinite; }
.live-pill.offline { background: rgba(255, 200, 87, 0.14); color: var(--warn); }
.live-pill.offline .dot { background: var(--warn); animation: none; }
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.35; transform: scale(0.8); } }

.active-title { font-size: var(--fs-xl); font-weight: 800; }
.active-title .game { color: var(--accent); display: block; }

.timer-box {
  position: relative;
  width: 100%;
  padding: var(--space-5) var(--space-3);
  border-radius: var(--radius-lg);
  border: 2px solid color-mix(in srgb, var(--accent) 50%, var(--line));
  background:
    radial-gradient(120% 120% at 50% 0%, color-mix(in srgb, var(--accent) 18%, transparent), transparent 70%),
    var(--surface);
  display: grid; justify-items: center; gap: var(--space-3);
}
.timer-box .game-art { width: 52px; height: 52px; }

/* Fortschrittsring: Anteil des heutigen Kontingents (grün → gelb ab 10 Min. → rot drüber) */
.ring-wrap { position: relative; width: min(76vw, 300px); aspect-ratio: 1; display: grid; place-items: center; }
.ring { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); overflow: visible; }
.ring circle { fill: none; stroke-width: 9; }
.ring-track { stroke: var(--surface-3); }
.ring-fill {
  stroke: var(--ok); stroke-linecap: round; stroke-dasharray: 100 100; stroke-dashoffset: 100;
  transition: stroke-dashoffset 0.6s ease, stroke 0.3s ease;
  filter: drop-shadow(0 0 6px color-mix(in srgb, var(--ok) 60%, transparent));
}
.ring-wrap.ring-low .ring-fill { stroke: var(--warn); filter: drop-shadow(0 0 6px color-mix(in srgb, var(--warn) 60%, transparent)); }
.ring-wrap.ring-over .ring-fill { stroke: var(--danger); filter: drop-shadow(0 0 8px color-mix(in srgb, var(--danger) 70%, transparent)); }
.ring-wrap.ring-over .ring { animation: ring-pulse 1.4s ease-in-out infinite; }
.ring-wrap.ring-none .ring-fill { stroke: var(--accent); opacity: 0.35; filter: none; }
@keyframes ring-pulse { 50% { opacity: 0.55; } }
.ring-center { position: relative; display: grid; justify-items: center; gap: 6px; }
.ring-center /* Meine Spielzeiten */
.history-btn { justify-content: center; }
.week-nav { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: var(--space-3); }
.week-arrow { min-width: 52px; font-size: 1.5rem; line-height: 1; padding: 6px 0; }
.week-arrow:disabled { visibility: hidden; }
.week-label { text-align: center; display: grid; }
.week-label strong { font-size: 1.1rem; }
.week-label small { color: var(--text-3); font-size: var(--fs-xs); }
.history-body { display: grid; gap: var(--space-4); }
.history-body[aria-busy="true"] { opacity: 0.5; }
.history-limit { margin: 0; font-weight: 700; text-align: center; }
.history-limit.all-ok { color: var(--ok); }
.history-card { padding: var(--space-3) var(--space-4); border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); }

.week-chart { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.week-col {
  display: grid; grid-template-rows: auto 110px auto; gap: 4px; justify-items: center;
  padding: 2px 0; border: 0; border-radius: 8px; background: none; color: var(--text); font: inherit; cursor: pointer;
}
.week-col:disabled { cursor: default; }
.week-col .v { font-size: 0.6875rem; font-weight: 700; color: var(--text-2); min-height: 1.2em; font-variant-numeric: tabular-nums; }
.week-col .area { position: relative; width: 100%; display: flex; justify-content: center; align-items: flex-end; border-bottom: 1px solid var(--line); }
.week-col .bar { width: min(60%, 26px); border-radius: 4px 4px 0 0; background: var(--accent); min-height: 0; }
.week-col.ok .bar { background: var(--ok); }
.week-col.over .bar { background: var(--danger); }
.week-col .limit { position: absolute; left: 12%; right: 12%; border-top: 2px dashed var(--text-3); opacity: 0.8; }
.week-col .wd { font-size: var(--fs-xs); font-weight: 700; color: var(--text-3); }
.week-col.today .wd { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }
.week-col.future { opacity: 0.4; }
.week-legend { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-3); margin-top: var(--space-2); font-size: var(--fs-xs); color: var(--text-3); }
.week-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.week-legend .l-ok { background: var(--ok); }
.week-legend .l-over { background: var(--danger); }
.week-legend .l-limit { width: 14px; height: 0; border-radius: 0; border-top: 2px dashed var(--text-3); vertical-align: 3px; }

.history-games { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.history-games li { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; }
.history-games .game-art { width: 30px; height: 30px; }
.history-games .name { font-weight: 700; line-height: 1.2; }
.history-games .share { display: block; height: 6px; margin-top: 4px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.history-games .share span { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
.history-games .dur { font-weight: 750; text-align: right; }
.history-games .n { display: block; font-size: var(--fs-xs); color: var(--text-3); font-weight: 600; }

.history-days { display: grid; gap: var(--space-3); }
.history-day { scroll-margin-top: 12px; }
.history-day-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-3); margin-bottom: var(--space-2); }
.history-day-head strong { font-size: 1rem; }
.history-day-head .sum { font-weight: 800; white-space: nowrap; }
.history-day .chip { display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 999px; font-size: var(--fs-xs); font-weight: 750; background: var(--surface-3); color: var(--text-2); }
.history-day .chip.ok { background: color-mix(in srgb, var(--ok) 22%, transparent); color: var(--ok-text); }
.history-day .chip.over { background: color-mix(in srgb, var(--danger) 25%, transparent); color: var(--error-text); }
.history-day .empty { margin: 0; color: var(--text-3); font-size: var(--fs-sm); }
.history-day .extra { margin: 0 0 var(--space-2); color: var(--text-3); font-size: var(--fs-xs); }
.today-list .by { display: block; font-size: var(--fs-xs); color: var(--text-3); }

.big-timer { font-size: clamp(2rem, 11vw, 3.3rem); }
.ring-left { font-weight: 750; font-size: var(--fs-sm); color: var(--ok); min-height: 1.3em; }
.ring-wrap.ring-low .ring-left { color: var(--warn); }
.ring-wrap.ring-over .ring-left { color: var(--error-text); }
#quota-active .quota-bar { display: none; } /* der Ring zeigt den Fortschritt */

/* Serie & Abzeichen */
.streak-card {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: var(--space-3);
  width: 100%; padding: var(--space-3) var(--space-4); border-radius: var(--radius);
  border: 1px solid color-mix(in srgb, var(--warn) 45%, var(--line));
  background: linear-gradient(135deg, color-mix(in srgb, var(--warn) 14%, transparent), transparent 70%), var(--surface);
  text-align: left; cursor: pointer; color: var(--text);
}
.streak-card .flame { font-size: 1.8rem; }
.streak-card.cold .flame { filter: grayscale(1); opacity: 0.6; }
.streak-text strong { display: block; font-size: 1.05rem; }
.streak-text small { color: var(--text-3); font-size: var(--fs-xs); }
.badges-count { font-weight: 750; color: var(--text-2); white-space: nowrap; }
.badges-grid { list-style: none; margin: var(--space-3) 0; padding: 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-2); }
.badges-grid li { position: relative; padding: var(--space-3); border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--line); display: grid; gap: 4px; align-content: start; }
.badges-grid .emoji { font-size: 2rem; line-height: 1; }
.badges-grid .t { font-weight: 800; }
.badges-grid .d { font-size: var(--fs-xs); color: var(--text-3); }
.badges-grid li.locked .emoji { filter: grayscale(1); opacity: 0.35; }
.badges-grid li.locked :is(.t, .d) { opacity: 0.7; }
.badges-grid li.earned {
  border: 2px solid var(--warn);
  background: linear-gradient(160deg, color-mix(in srgb, var(--warn) 24%, var(--surface-2)), var(--surface-2) 70%);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--warn) 18%, transparent);
}
.badges-grid .got {
  position: absolute; top: 8px; right: 8px; padding: 2px 8px; border-radius: 999px;
  background: var(--warn); color: var(--warn-ink); font-size: var(--fs-xs); font-weight: 800;
}
.badges-grid .when { color: var(--text-2); font-weight: 650; }
.badges-grid .bar { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.badges-grid .bar span { display: block; height: 100%; background: var(--warn); }

/* Heute gespielt */
.today-card { padding: var(--space-3) var(--space-4); border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); }
.today-title { font-size: var(--fs-xs); color: var(--text-3); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: var(--space-2); }
.today-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.today-list li { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; }
.today-list .game-art { width: 30px; height: 30px; }
.today-list .what { font-weight: 700; line-height: 1.2; }
.today-list .when { font-size: var(--fs-xs); color: var(--text-3); }
.today-list .dur { font-weight: 750; text-align: right; }
.today-list .ok { display: block; font-size: var(--fs-xs); color: var(--ok); font-weight: 650; }
.big-timer {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--fs-xxl);
  font-weight: 800;
  letter-spacing: 0.02em;
  line-height: 1;
  color: var(--text);
  text-shadow: 0 0 24px color-mix(in srgb, var(--accent) 45%, transparent);
}
.timer-meta { color: var(--text-2); font-size: var(--fs-sm); }

.active-actions {
  display: grid; gap: var(--space-3); width: 100%;
  position: sticky; bottom: calc(12px + var(--safe-bottom)); z-index: 5; /* Stopp auch auf kleinen Handys sichtbar */
}
.active-actions .btn { box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); }
.loading-retry { color: var(--text-3); font-size: var(--fs-sm); opacity: 0; animation: show-late 0.3s ease 8s forwards; }
@keyframes show-late { to { opacity: 1; } }
.btn-stop { min-height: 76px; font-size: 1.35rem; }

/* Dialog: Bonuszeit */
.bonus-dialog .dialog-body { text-align: center; }
.bonus-dialog .gift { font-size: 4rem; line-height: 1; animation: gift-pop 0.6s cubic-bezier(.2, 1.6, .4, 1) both; }
@keyframes gift-pop { from { transform: scale(0.3) rotate(-12deg); opacity: 0; } to { transform: none; opacity: 1; } }
.bonus-items { list-style: none; margin: var(--space-3) 0; padding: 0; display: grid; gap: var(--space-2); }
.bonus-items li { padding: var(--space-3); border-radius: var(--radius); background: var(--surface-2); }
.bonus-items .plus { display: block; font-size: 1.6rem; font-weight: 800; color: var(--ok); }
.bonus-items .why { color: var(--text-2); }
.bonus-items .btn { margin-top: var(--space-2); }
.credit-btn { border-style: dashed; color: var(--ok); }
.badge-new-dialog .gift { font-size: 5rem; filter: drop-shadow(0 6px 18px color-mix(in srgb, var(--warn) 55%, transparent)); }
.badge-new-kicker { margin: 0 0 var(--space-2); font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; color: var(--warn); font-size: var(--fs-sm); }

/* Dialog: Spiel wechseln */
.switch-grid { max-height: 60dvh; overflow: auto; padding: 4px; }

@media (max-width: 370px) {
  .keypad { grid-template-columns: repeat(3, 72px); }
  .key { height: 60px; }
  .game-tile { min-height: 80px; padding: 8px 4px; }
  .game-tile .game-art { width: 34px; height: 34px; }
  .game-name { font-size: 0.8125rem; }
}
