:root {
  --bg: #0b1a12;
  --surface: #13281c;
  --surface-2: #1c3a28;
  --text: #f2f7f3;
  --muted: #9fb8a8;
  --green: #4ccf3a;
  --green-dark: #2a7d22;
  --red: #ff3b30;
  --diamond: #5ff2e3;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 17px/1.4 ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
svg { width: 24px; height: 24px; fill: currentColor; }
.muted { color: var(--muted); }
.pixel { font-family: "Press Start 2P", ui-monospace, monospace; font-weight: 400; letter-spacing: .02em; }
[hidden] { display: none !important; }

#app { position: relative; height: 100dvh; max-width: 560px; margin: 0 auto; overflow: hidden; }
.screen { position: absolute; inset: 0; display: none; flex-direction: column;
  padding: calc(var(--safe-top) + 16px) 16px calc(var(--safe-bottom) + 16px); }
.screen.active { display: flex; }

/* Brak dostępu */
.gate-header { text-align: center; margin-top: 56px; }
.avatar-lg { width: 120px; height: 120px; margin: 0 auto 20px; border-radius: 24px; background: url(avatar.jpg) center / cover;
  box-shadow: 0 0 40px rgba(76, 207, 58, .35); }
.gate-header h1 { margin: 0 0 12px; font-size: 26px; color: var(--green); }
.invite { display: flex; flex-direction: column; gap: 10px; margin-top: 24px; }
.invite input { padding: 14px; border-radius: 14px; border: 1px solid var(--surface-2); background: var(--surface);
  color: var(--text); font: inherit; font-size: 16px; outline: none; }
.primary { padding: 14px; border-radius: 14px; background: var(--green); color: #08200a; font-weight: 700; font-size: 17px; }

/* Start: plakat + kafelki dzieci */
#screen-home { overflow-y: auto; }
.poster { position: relative; flex: none; height: min(58vh, 560px); min-height: 300px; overflow: hidden;
  margin: calc(-1 * (var(--safe-top) + 16px)) -16px 0; background: #0d1f16; }
.poster img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 30%; }
.poster::after { content: ""; position: absolute; inset: auto 0 0; height: 40%;
  background: linear-gradient(to bottom, rgba(11,26,18,0), var(--bg)); }
.poster-name { position: absolute; left: 0; right: 0; top: calc(var(--safe-top) + 20px); z-index: 1; margin: 0; text-align: center;
  font-size: min(9vw, 44px); color: #b6ff9e; text-shadow: 0 4px 0 #1d5c16, 0 0 30px rgba(76, 207, 58, .6); }
.who { margin: 4px 0 14px; text-align: center; font-size: 20px; font-weight: 700; }
.kids { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.kid { position: relative; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 22px 10px 18px;
  border-radius: 22px; background: var(--surface); border: 3px solid var(--surface-2);
  box-shadow: 0 6px 0 #071209; transition: transform .1s ease, box-shadow .1s ease; }
.kid:active { transform: translateY(4px); box-shadow: 0 2px 0 #071209; }
.kid-face { width: 72px; height: 72px; border-radius: 18px; display: grid; place-items: center; font-size: 34px; font-weight: 800; color: #08200a; }
.kid:nth-child(1) .kid-face { background: #ffcc4d; }
.kid:nth-child(2) .kid-face { background: #ff8fc8; }
.kid:nth-child(3) .kid-face { background: #8fd3ff; }
.kid-name { font-size: 22px; font-weight: 800; }
.kid-gems { display: flex; align-items: center; gap: 6px; color: var(--diamond); }
.kid-gems svg { width: 22px; height: 22px; }
.kid-gems .pixel { font-size: 14px; }
.kid-call { position: absolute; top: 10px; right: 10px; width: 34px; height: 34px; border-radius: 50%; background: var(--green);
  display: grid; place-items: center; color: #08200a; }
.kid-call svg { width: 18px; height: 18px; }

/* Rozmowa */
.call { background: #000; }
.call-bg { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; transition: opacity .7s ease; }
.call.present .call-bg { opacity: 1; animation: drift 16s ease-in-out infinite alternate; }
@keyframes drift { from { transform: scale(1.02); } to { transform: scale(1.07) translate(-1%, .8%); } }
@media (prefers-reduced-motion: reduce) { .call.present .call-bg { animation: none; } }
.call::before { content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: linear-gradient(to bottom, rgba(0,0,0,.55) 0%, rgba(0,0,0,0) 30%, rgba(0,0,0,0) 55%, rgba(0,0,0,.8) 100%); }
.call > *:not(.call-bg) { position: relative; z-index: 2; }
.call-top { text-align: center; margin-top: 20px; }
.call-status { margin: 0; color: rgba(255,255,255,.85); font-size: 17px; font-variant-numeric: tabular-nums; text-shadow: 0 1px 8px rgba(0,0,0,.6); }
.call-top h2 { margin: 10px 0 0; font-size: 30px; color: #b6ff9e; text-shadow: 0 3px 0 #1d5c16, 0 0 24px rgba(0,0,0,.6); }

.voice-bar { position: relative; width: 64px; height: 6px; margin: 16px auto 0; background: rgba(255,255,255,.3); }
.voice-bar .ring { position: absolute; inset: 0; background: var(--green); opacity: 0;
  transform: scaleX(var(--lvl, 1)); transition: transform .08s linear, opacity .2s; }
.voice-bar.speaking .ring { opacity: 1; transform: scaleX(calc((var(--lvl, 1) - 1) * 8 + 1)); }
.voice-bar.speaking .ring.r2 { opacity: .35; filter: blur(6px); }
.voice-bar.ringing .ring { animation: barpulse 1.4s ease-in-out infinite; }
.voice-bar.ringing .ring.r2 { animation-delay: .7s; }
@keyframes barpulse { 0%, 100% { opacity: 0; transform: scaleX(.4); } 50% { opacity: 1; transform: scaleX(1.6); } }

.vault { margin: auto auto 28px; display: flex; align-items: center; gap: 10px; padding: 10px 18px; border-radius: 999px;
  background: rgba(0,0,0,.55); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); color: var(--diamond); }
.vault-icon { width: 30px; height: 30px; }
.vault .pixel { font-size: 18px; }
.vault-who { color: rgba(255,255,255,.8); font-size: 15px; }
.vault.bump { animation: bump .6s ease; }
@keyframes bump { 30% { transform: scale(1.25); } 100% { transform: scale(1); } }

.call-controls { display: grid; grid-template-columns: 1fr 1fr 1fr; align-items: end; margin-bottom: 12px; }
.round { display: flex; flex-direction: column; align-items: center; gap: 8px; font-size: 14px; }
.round svg { width: 64px; height: 64px; padding: 18px; border-radius: 50%; }
.round.ghost svg { background: rgba(255,255,255,.18); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.round.ghost[aria-pressed="true"] svg { background: #fff; color: #111; }
.round.red svg { background: var(--red); }
.round.big svg { width: 80px; height: 80px; padding: 22px; }

/* Nagroda: diament wyskakuje na środku */
.pop { position: absolute; left: 50%; top: 42%; z-index: 10; display: flex; flex-direction: column; align-items: center; gap: 10px;
  transform: translate(-50%, -50%); pointer-events: none; animation: pop 1.8s ease forwards; }
.pop svg { width: 120px; height: 120px; filter: drop-shadow(0 0 24px rgba(95, 242, 227, .8)); }
.pop b { font-size: 28px; color: var(--diamond); text-shadow: 0 3px 0 #0a4a44; }
@keyframes pop {
  0% { opacity: 0; transform: translate(-50%, -30%) scale(.3); }
  20% { opacity: 1; transform: translate(-50%, -50%) scale(1.15); }
  35% { transform: translate(-50%, -50%) scale(1); }
  75% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, 120%) scale(.3); }
}

.toast { position: absolute; left: 16px; right: 16px; bottom: calc(var(--safe-bottom) + 24px); z-index: 20; background: var(--surface-2);
  padding: 12px 16px; border-radius: 12px; font-size: 15px; text-align: center; box-shadow: 0 6px 24px rgba(0,0,0,.4); }
