:root {
  --bg: #15121f;
  --card: #221d33;
  --text: #f2eefc;
  --muted: #9a92b3;
  --accent: #ff5fa2;
  --accent-2: #7c5cff;
  --ok: #3ecf8e;
  --err: #ff6b6b;

  --r-common: #b0c3d9;
  --r-uncommon: #5e98d9;
  --r-rare: #4b69ff;
  --r-epic: #d32ce6;
  --r-legendary: #e4ae39;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

main { max-width: 560px; margin: 0 auto; padding: 16px; }
body.host main { max-width: 1280px; }
body.screen main { max-width: none; padding: 24px 32px; }

a { color: var(--accent); }
h1, h2 { margin: 0 0 12px; line-height: 1.2; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }

.card {
  background: var(--card);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 16px;
}
.link-card { display: block; color: inherit; text-decoration: none; }
.link-card:active { transform: scale(0.99); }

.center { text-align: center; }
.muted { color: var(--muted); font-size: 0.9em; }
.big { font-size: 1.4rem; }
.error { color: var(--err); }
.question { font-size: 1.2rem; }
.plain { list-style: none; padding: 0; margin: 0; }
.plain li { padding: 4px 0; }

input[type=text], input[type=file], select, textarea {
  width: 100%;
  font: inherit;
  padding: 12px 14px;
  margin: 6px 0 12px;
  border-radius: 10px;
  border: 1px solid #3a3352;
  background: #17131f;
  color: var(--text);
}

button, .button {
  display: inline-block;
  font: inherit;
  font-weight: 600;
  padding: 12px 22px;
  border: 0;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
  cursor: pointer;
  text-decoration: none;
}
button.secondary { background: #3a3352; }
button.small { padding: 6px 12px; font-size: 0.85rem; }
button.huge { font-size: 1.6rem; padding: 18px 48px; margin: 16px 0; }

.flash { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; background: #2d2742; }
.flash-success { background: #1d3d31; }
.flash-error { background: #4a2028; }

.preview { width: 100%; border-radius: 12px; margin-bottom: 12px; }

/* --- Хост --- */

.host-nav { display: flex; gap: 20px; padding: 12px 32px; background: #0e0b16; }
.host-nav a { color: var(--muted); text-decoration: none; }
.host-nav a:hover { color: var(--text); }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(480px, 1fr)); gap: 16px; }
table { width: 100%; border-collapse: collapse; margin-bottom: 12px; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid #332c49; vertical-align: top; }
td:last-child a { white-space: nowrap; }
tr.done td { opacity: 0.45; }
form.inline { display: flex; gap: 8px; align-items: center; }
form.inline input, form.inline select { margin: 0; }

.rarity-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 8px; }

.screen-title { text-align: center; font-size: 2.4rem; margin: 8px 0 4px; }

/* --- Призы и редкость --- */

.prize-card {
  flex: 0 0 auto;
  width: 220px;
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 14px;
  border-radius: 12px;
  font-weight: 700;
  color: white;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
  background: #2a2540;
  border-bottom: 6px solid currentColor;
}
.rarity-common    { --rc: var(--r-common); }
.rarity-uncommon  { --rc: var(--r-uncommon); }
.rarity-rare      { --rc: var(--r-rare); }
.rarity-epic      { --rc: var(--r-epic); }
.rarity-legendary { --rc: var(--r-legendary); }
.prize-card[class*="rarity-"] {
  background: radial-gradient(circle at 50% 120%, var(--rc), color-mix(in srgb, var(--rc) 25%, #1a1626) 70%);
  border-bottom-color: var(--rc);
}
.rarity-dot[class*="rarity-"] { background: var(--rc); }

.pool { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin: 24px 0; }
.pool .prize-card { width: 180px; height: 110px; font-size: 0.95rem; }

.big-card { display: inline-flex; width: 420px; height: 220px; font-size: 1.8rem; }

/* --- Лента рулетки --- */

.roulette {
  position: relative;
  overflow: hidden;
  margin: 32px 0;
  padding: 20px 0;
  background: #0e0b16;
  border-radius: 16px;
}
.roulette::before, .roulette::after {
  content: "";
  position: absolute;
  top: 0; bottom: 0;
  width: 15%;
  z-index: 2;
  pointer-events: none;
}
.roulette::before { left: 0; background: linear-gradient(90deg, #0e0b16, transparent); }
.roulette::after { right: 0; background: linear-gradient(-90deg, #0e0b16, transparent); }
.marker {
  position: absolute;
  left: 50%;
  top: 0; bottom: 0;
  width: 4px;
  margin-left: -2px;
  background: #ffd84d;
  box-shadow: 0 0 12px #ffd84d;
  z-index: 3;
}
.strip { display: flex; gap: 10px; will-change: transform; }
.strip .prize-card { transition: transform 0.3s, box-shadow 0.3s, opacity 0.3s; }
.strip .prize-card.winner { transform: scale(1.08); box-shadow: 0 0 30px var(--rc); }
.strip .prize-card.nope { position: relative; }
.strip .prize-card.nope::after {
  content: "НЕА";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: rgba(10, 6, 16, 0.65);
  font-size: 3.6rem;
  font-weight: 900;
  color: #ff3b3b;
  text-shadow: 0 0 16px rgba(255, 59, 59, 0.8), 0 2px 0 #fff;
  transform: rotate(-12deg);
  animation: stamp 0.35s cubic-bezier(0.2, 2, 0.4, 1);
}
@keyframes stamp { from { transform: rotate(-12deg) scale(3); opacity: 0; } }

.recipient-form { max-width: 900px; margin: 24px auto; }
.recipients { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.recipient {
  padding: 10px 16px;
  border-radius: 10px;
  background: #2d2742;
  cursor: pointer;
  font-size: 1.1rem;
}
.recipient.is-winner { outline: 2px solid var(--accent); }
.recipient:has(input:checked) { background: var(--accent-2); }

/* --- Раскрытие приза --- */

.reveal { margin: 40px 0; }
.flip { position: relative; width: 420px; height: 220px; margin: 0 auto 24px; perspective: 1000px; }
.flip > div { position: absolute; inset: 0; backface-visibility: hidden; transition: transform 1s; }
.flip-front { transform: rotateY(180deg); }
.flip-back { transform: rotateY(0); }
.reveal.animate .flip-front { animation: flip-front 2.2s forwards; }
.reveal.animate .flip-back { animation: flip-back 2.2s forwards; }
@keyframes flip-front { 0%, 45% { transform: rotateY(0); } 100% { transform: rotateY(180deg); } }
@keyframes flip-back { 0%, 45% { transform: rotateY(-180deg); } 100% { transform: rotateY(0); } }

/* --- Баттл --- */

.battle { display: flex; gap: 24px; align-items: center; justify-content: center; margin: 16px 0; }
.battle-side { flex: 1; }
.photo-button { padding: 0; background: none; border-radius: 16px; overflow: hidden; width: 100%; }
.photo-button img { display: block; width: 100%; height: 72vh; object-fit: contain; background: #0e0b16; transition: transform 0.2s; }
.photo-button:hover img { transform: scale(1.02); }
.vs { font-size: 3rem; font-weight: 900; color: var(--accent); }
.battle-winner { text-align: center; }
.battle-winner img { max-height: 65vh; max-width: 100%; border-radius: 16px; box-shadow: 0 0 40px var(--r-legendary); }

/* --- QR --- */

.qr-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.qr-card { background: white; color: #111; border-radius: 12px; padding: 12px; text-align: center; break-inside: avoid; }
.qr-card svg { width: 100%; height: auto; }
.qr-name { font-weight: 700; font-size: 1.2rem; }
.qr-url { font-size: 0.7rem; color: #666; word-break: break-all; margin: 4px 0 8px; }

@media print {
  body { background: white; }
  .no-print, .host-nav { display: none !important; }
  .qr-grid { grid-template-columns: repeat(3, 1fr); }
  .qr-card { border: 1px dashed #aaa; }
}

@media (max-width: 600px) {
  .grid { grid-template-columns: 1fr; }
}
