:root {
  --red: #c8102e;
  --red-deep: #7a0a1e;
  --berry: #4a0714;
  --yellow: #ffc72c;
  --gold: #e0a526;
  --green: #14693f;
  --green-deep: #0b3f27;
  --cream: #fff3d6;
  --ink: #3a0a12;
  --radius: 22px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: "Fredoka", "Trebuchet MS", system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.4;
  color: var(--cream);
  background: var(--berry);
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- pozadí ---------- */
.bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background:
    radial-gradient(120% 70% at 50% -10%, #d8142f 0%, rgba(216, 20, 47, 0) 60%),
    radial-gradient(90% 60% at 50% 110%, #0f5a38 0%, rgba(15, 90, 56, 0) 65%),
    linear-gradient(180deg, #a50d26 0%, #6a0a1c 55%, #4a0714 100%);
}

.deco {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--s);
  height: var(--s);
  max-width: 150px;
  max-height: 150px;
  rotate: var(--r);
  opacity: 0.5;
  animation: bob 9s ease-in-out infinite;
  animation-delay: var(--d);
}

@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-14px) rotate(5deg); }
}

#snow, #confetti {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
#snow { z-index: 1; }
#confetti { z-index: 60; }

/* ---------- layout ---------- */
.app {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: calc(var(--safe-t) + 56px) calc(var(--safe-r) + 16px) calc(var(--safe-b) + 32px) calc(var(--safe-l) + 16px);
  min-height: 100vh;
  min-height: 100dvh;
}

.top { text-align: center; margin-bottom: 20px; }

.title {
  margin: 0;
  font-size: clamp(34px, 11vw, 52px);
  line-height: 1.02;
  font-weight: 700;
  letter-spacing: 0.01em;
}
.title span {
  display: inline-block;
  padding: 0.18em 0.6em 0.26em;
  color: var(--yellow);
  background: var(--red);
  border: 3px solid var(--yellow);
  border-radius: 14px;
  box-shadow: 0 5px 0 var(--berry), 0 14px 24px rgba(0, 0, 0, 0.35), inset 0 0 0 3px var(--red-deep);
  rotate: -2deg;
  text-shadow: 0 3px 0 var(--red-deep);
}

.tagline {
  margin: 16px auto 0;
  max-width: 22em;
  font-size: 18px;
  font-weight: 500;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
}

h2 { margin: 0 0 6px; font-size: 26px; line-height: 1.15; font-weight: 700; }

.card {
  background: rgba(255, 243, 214, 0.96);
  color: var(--ink);
  border-radius: var(--radius);
  padding: 20px 18px 22px;
  margin-bottom: 16px;
  box-shadow: 0 6px 0 rgba(74, 7, 20, 0.55), 0 18px 30px rgba(0, 0, 0, 0.3);
}
.card h2 { color: var(--red-deep); }

.muted { margin: 0 0 14px; font-size: 16px; opacity: 0.78; }
.card .muted:last-child { margin-bottom: 0; }
.center { text-align: center; }

.notice {
  margin: 0 0 16px;
  padding: 12px 16px;
  border-radius: 14px;
  font-weight: 500;
  background: var(--cream);
  color: var(--ink);
  border-left: 8px solid var(--green);
}
.notice-err { border-left-color: var(--red); }

/* ---------- výběr jména ---------- */
.names { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.name-btn {
  appearance: none;
  min-height: 62px;
  padding: 8px 10px;
  font: inherit;
  font-size: 20px;
  font-weight: 600;
  color: var(--cream);
  background: var(--green);
  border: 0;
  border-radius: 16px;
  box-shadow: 0 5px 0 var(--green-deep);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.1;
  transition: transform 0.08s, box-shadow 0.08s;
}
.name-btn:nth-child(4n+1), .name-btn:nth-child(4n+4) { background: var(--red); box-shadow: 0 5px 0 var(--red-deep); }
.name-btn:active { transform: translateY(4px); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.4); }
.name-btn small { font-size: 13px; font-weight: 400; opacity: 0.85; margin-top: 3px; }
.name-btn.is-locked {
  background: #d9cdb2;
  color: #7a6e58;
  box-shadow: 0 5px 0 #b8ab8e;
}
.name-btn.is-locked .nm { text-decoration: line-through; text-decoration-thickness: 2px; }

:focus-visible { outline: 3px solid var(--yellow); outline-offset: 3px; }

/* ---------- tlačítka ---------- */
.btn {
  appearance: none;
  display: block;
  width: 100%;
  min-height: 56px;
  padding: 12px 22px;
  font: inherit;
  font-size: 19px;
  font-weight: 700;
  color: var(--berry);
  background: var(--yellow);
  border: 0;
  border-radius: 999px;
  box-shadow: 0 5px 0 var(--gold);
  cursor: pointer;
  transition: transform 0.08s, box-shadow 0.08s;
}
.btn:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 1px 0 var(--gold); }
.btn:disabled { opacity: 0.7; cursor: default; }
.btn-big { min-height: 72px; font-size: 28px; margin-top: 8px; animation: pulse 1.6s ease-in-out infinite; }
.btn-big:disabled { animation: none; }
.btn-small { display: inline-block; width: auto; min-height: 44px; padding: 8px 16px; font-size: 16px; }
.btn-ghost { background: transparent; color: var(--red-deep); box-shadow: inset 0 0 0 2px var(--red-deep); }
.btn-ghost:active:not(:disabled) { box-shadow: inset 0 0 0 2px var(--red-deep); }
.btn-danger { background: var(--red); color: var(--cream); box-shadow: 0 5px 0 var(--red-deep); }

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.035); }
}

.link {
  appearance: none;
  background: none;
  border: 0;
  padding: 14px 10px;
  font: inherit;
  font-size: 17px;
  color: var(--cream);
  text-decoration: underline;
  text-underline-offset: 4px;
  cursor: pointer;
}

.sound {
  position: fixed;
  z-index: 70;
  top: calc(var(--safe-t) + 10px);
  right: calc(var(--safe-r) + 12px);
  min-height: 40px;
  padding: 6px 14px;
  display: flex;
  align-items: center;
  gap: 6px;
  font: inherit;
  font-size: 15px;
  color: var(--cream);
  background: rgba(74, 7, 20, 0.7);
  border: 2px solid rgba(255, 243, 214, 0.4);
  border-radius: 999px;
  cursor: pointer;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
.sound[aria-pressed="true"] { background: var(--green); border-color: var(--yellow); }

/* ---------- kolo ---------- */
.who { text-align: center; margin: 0 0 8px; font-size: 20px; text-shadow: 0 2px 6px rgba(0, 0, 0, 0.5); }
.who strong { color: var(--yellow); font-size: 26px; }

.wheel-wrap {
  position: relative;
  width: min(92vw, 420px);
  margin: 34px auto 12px;
  aspect-ratio: 1;
  filter: drop-shadow(0 14px 18px rgba(0, 0, 0, 0.45));
}
#wheel { display: block; width: 100%; height: 100%; will-change: transform; }
.pointer {
  position: absolute;
  z-index: 3;
  left: 50%;
  top: -30px;
  width: 44px;
  height: 58px;
  margin-left: -22px;
  transform-origin: 50% 33%;
}
.wheel-wrap.landed #wheel { animation: glow 0.7s ease-in-out 3; }
@keyframes glow {
  50% { filter: brightness(1.25) saturate(1.2); }
}

/* ---------- odhalení ---------- */
.reveal {
  text-align: center;
  padding: 26px 18px 28px;
  margin-top: 4px;
  border-radius: 28px;
  background: rgba(58, 5, 17, 0.72);
  border: 3px solid var(--yellow);
  box-shadow: 0 0 0 6px rgba(255, 199, 44, 0.18), 0 20px 40px rgba(0, 0, 0, 0.4);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.tada { margin: 0; font-size: clamp(36px, 12vw, 52px); color: var(--yellow); text-shadow: 0 4px 0 var(--red-deep); }
.reveal-lead { margin: 8px 0 0; font-size: 21px; }
.gift-name {
  margin: 6px 0 14px;
  font-size: clamp(46px, 17vw, 84px);
  font-weight: 700;
  line-height: 1.05;
  color: var(--cream);
  text-shadow: 0 4px 0 var(--red), 0 8px 0 var(--red-deep), 0 14px 24px rgba(0, 0, 0, 0.5);
  overflow-wrap: anywhere;
}
.gift-name .ch { display: inline-block; }
.hint {
  margin: 4px 0 16px;
  padding: 14px 16px;
  background: var(--cream);
  color: var(--ink);
  border-radius: 16px;
  text-align: left;
}
.hint-title { margin: 0 0 4px; font-weight: 700; color: var(--green); }
.hint p:last-child { margin: 0; }
.secret-note { margin: 6px 0 0; font-size: 22px; font-weight: 600; color: var(--yellow); }

.reveal.pop .tada { animation: pop 0.8s cubic-bezier(0.2, 1.6, 0.4, 1) both; }
.reveal.pop .reveal-lead { animation: fade 0.5s 0.5s both; }
.reveal.pop .gift-name .ch { animation: letter 0.7s cubic-bezier(0.2, 1.7, 0.4, 1) both; animation-delay: calc(0.9s + var(--i) * 0.07s); }
.reveal.pop .hint { animation: fade 0.6s 1.9s both; }
.reveal.pop .secret-note { animation: fade 0.6s 2.3s both, wobble 2.4s 3s ease-in-out infinite; }

@keyframes pop { from { transform: scale(0.2) rotate(-12deg); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes letter { from { transform: translateY(40px) scale(0.2); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes wobble { 0%, 100% { rotate: 0deg; } 50% { rotate: -2deg; } }

/* ---------- admin ---------- */
.stack { display: grid; gap: 12px; }
label { font-weight: 600; }
.field {
  width: 100%;
  min-height: 52px;
  padding: 10px 14px;
  font: inherit;
  font-size: 17px;
  color: var(--ink);
  background: #fff;
  border: 2px solid var(--red-deep);
  border-radius: 14px;
}
.table-wrap { overflow-x: auto; margin: 14px 0; }
table { width: 100%; border-collapse: collapse; font-size: 16px; }
th, td { padding: 8px 6px; text-align: left; border-bottom: 1px solid rgba(58, 10, 18, 0.15); vertical-align: middle; }
th { font-size: 14px; color: var(--red-deep); }
td form { margin: 0; }
.secret { filter: blur(7px); font-weight: 600; transition: filter 0.2s; user-select: none; }
body.peek .secret { filter: none; user-select: auto; }
.notice-ok { border-left-color: var(--green); }
.admin .btn { width: auto; }
.admin .stack .btn { width: 100%; }
.admin .center { margin-top: 8px; }
.admin .card .btn-small { margin-bottom: 4px; }

@media (min-width: 700px) {
  .app { padding-top: 72px; }
  .deco { opacity: 0.4; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .reveal.pop .tada, .reveal.pop .reveal-lead, .reveal.pop .gift-name .ch, .reveal.pop .hint, .reveal.pop .secret-note { opacity: 1; }
}

/* ---------- předání telefonu, potvrzení, konec ---------- */
.btn-next { margin-top: 22px; min-height: 64px; font-size: 22px; background: var(--green); color: var(--cream); box-shadow: 0 5px 0 var(--green-deep); border: 2px solid var(--yellow); }
.btn-next:active:not(:disabled) { box-shadow: 0 1px 0 var(--green-deep); }
.reveal.pop .btn-next { animation: fade 0.6s 2.8s both; }
.handoff { text-align: center; padding: 40px 16px; animation: fade 0.4s both; }
.handoff h2 { font-size: 30px; color: var(--yellow); }
.handoff p { font-size: 20px; margin: 6px 0; }
.handoff-ico { font-size: 64px; margin: 0 0 6px !important; line-height: 1; }
#screen-done .handoff-ico { animation: wobble 2.4s ease-in-out infinite; }
.sheet {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px calc(var(--safe-r) + 16px) calc(var(--safe-b) + 16px) calc(var(--safe-l) + 16px);
  background: rgba(30, 2, 8, 0.65);
}
.sheet[hidden] { display: none; }
.sheet-box {
  width: 100%;
  max-width: 440px;
  display: grid;
  gap: 12px;
  padding: 22px 18px 18px;
  background: var(--cream);
  color: var(--ink);
  border-radius: 26px;
  animation: rise 0.25s ease-out both;
}
.sheet-q { margin: 0 0 4px; text-align: center; font-size: 26px; font-weight: 700; line-height: 1.15; color: var(--red-deep); }
.btn-ghost-light { background: transparent; color: var(--red-deep); box-shadow: inset 0 0 0 2px var(--red-deep); min-height: 52px; }
@keyframes rise { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
body[data-screen="wheel"] .tagline { display: none; }
body[data-screen="wheel"] .top { margin-bottom: 12px; }
body[data-screen="wheel"] .wheel-wrap { margin-top: 30px; }
