:root {
  --bg: #191221;
  --bg-card: #251c30;
  --accent: #b98cf0;
  --accent-2: #7c4dcf;
  --like: #4ade80;
  --skip: #f87171;
  --text: #f2eefa;
  --text-dim: #b6abc9;
  --radius: 18px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: radial-gradient(circle at top, #2a1f38, var(--bg) 60%);
  color: var(--text);
  min-height: 100vh;
}

.page { display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: rgba(0,0,0,0.2);
  backdrop-filter: blur(6px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand { font-weight: 700; font-size: 1.1rem; color: var(--text); text-decoration: none; }

.topbar-right { display: flex; align-items: center; gap: 10px; }

.icon-btn {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
}
.icon-btn:hover { border-color: var(--accent); }
.icon-btn.hidden { display: none; }

.user-box { display: flex; align-items: center; gap: 10px; font-size: 0.9rem; }
.user-box img { width: 28px; height: 28px; border-radius: 50%; }
.user-box a.admin-link {
  color: var(--accent);
  text-decoration: none;
  border: 1px solid var(--accent);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
}
.user-box button {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.85rem;
}

.container { max-width: 720px; margin: 0 auto; padding: 24px 16px 60px; width: 100%; flex: 1; }

.loading { text-align: center; padding: 60px 0; color: var(--text-dim); }

.login-box { text-align: center; padding: 60px 20px; }
.login-box h1 { font-size: 1.6rem; margin-bottom: 10px; }
.login-box p { color: var(--text-dim); margin-bottom: 28px; }

.btn {
  display: inline-block;
  border: none;
  border-radius: 999px;
  padding: 12px 26px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.15s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: white; }
.btn-secondary { background: rgba(255,255,255,0.08); color: var(--text); }
.btn:disabled { opacity: 0.5; cursor: default; }

.discord-btn { background: #5865F2; color: white; }

/* Category grid */
.category-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; margin-top: 20px; }
.category-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 18px 14px;
  text-align: center;
  text-decoration: none;
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.06);
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.category-card:hover { transform: translateY(-3px); border-color: var(--accent); }
.category-card .cat-title { font-weight: 700; margin-bottom: 8px; }
.category-card .cat-progress { font-size: 0.8rem; color: var(--text-dim); }
.category-card .progress-bar { height: 6px; border-radius: 3px; background: rgba(255,255,255,0.08); margin-top: 8px; overflow: hidden; }
.category-card .progress-fill { height: 100%; background: var(--accent); }
.category-card.done { border-color: var(--like); }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.65); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px; }
.modal.hidden { display: none; }
.modal-card { background: var(--bg-card); border-radius: var(--radius); padding: 26px; max-width: 480px; width: 100%; max-height: 80vh; overflow-y: auto; }
.modal-card-wide { max-width: 560px; }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.modal-actions .btn { flex: 1; }
.rules-content h2 { margin-top: 0; }
.rules-content { line-height: 1.5; color: var(--text-dim); }
.rules-content ul { padding-left: 20px; }
#rulesAcceptBtn { margin-top: 18px; width: 100%; }

/* Досягнення */
.achievements-list { display: flex; flex-direction: column; gap: 10px; margin: 16px 0; max-height: 50vh; overflow-y: auto; }
.achievement-card, .toast.achievement-toast {
  display: flex; gap: 12px; align-items: flex-start;
  background: rgba(255,255,255,0.04); border-radius: 14px; padding: 12px 14px;
}
.achievement-icon, .toast-icon { font-size: 1.6rem; flex-shrink: 0; }
.achievement-title, .toast-title { font-weight: 700; }
.achievement-caption, .toast-caption { color: var(--text-dim); font-size: 0.85rem; margin-top: 2px; }
.achievement-date { color: var(--text-dim); font-size: 0.75rem; margin-top: 4px; }

.toast-container { position: fixed; top: 76px; right: 16px; z-index: 100; display: flex; flex-direction: column; gap: 8px; max-width: 320px; }
.toast {
  background: var(--bg-card); border: 1px solid var(--accent); border-radius: 14px; padding: 12px 14px;
  box-shadow: 0 10px 24px rgba(0,0,0,0.4);
  opacity: 0; transform: translateX(20px); transition: opacity 0.3s ease, transform 0.3s ease;
}
.toast.show { opacity: 1; transform: translateX(0); }

/* Мої голоси */
.my-votes-list { display: flex; flex-direction: column; gap: 10px; margin: 16px 0; max-height: 55vh; overflow-y: auto; }
.my-vote-row { display: flex; align-items: center; gap: 12px; background: rgba(255,255,255,0.04); border-radius: 14px; padding: 10px 12px; }
.my-vote-thumb { width: 48px; height: 48px; object-fit: contain; image-rendering: pixelated; background: rgba(0,0,0,0.3); border-radius: 8px; flex-shrink: 0; }
.my-vote-info { flex: 1; min-width: 0; }
.my-vote-name { font-weight: 600; }
.my-vote-value { color: var(--text-dim); font-size: 0.85rem; }

.material-plus {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; border-radius: 50%; background: var(--accent); color: white;
  font-size: 0.7rem; font-weight: 800; margin-left: 5px; cursor: help; vertical-align: middle;
}

/* Voting screen */
.vote-container { display: flex; flex-direction: column; align-items: center; }
.vote-header { width: 100%; display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; flex-wrap: wrap; gap: 6px; }
.back-link { color: var(--text-dim); text-decoration: none; font-size: 0.9rem; }
.category-title { font-weight: 700; font-size: 1.1rem; }
.progress-text { color: var(--text-dim); font-size: 0.85rem; }

.vote-toolbar { display: flex; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; justify-content: center; width: 100%; }
.btn.small { padding: 7px 14px; font-size: 0.82rem; }

.revote-banner {
  background: rgba(185,140,240,0.12); border: 1px solid var(--accent); color: var(--accent);
  border-radius: 12px; padding: 8px 14px; font-size: 0.85rem; text-align: center; margin-bottom: 6px; max-width: 360px;
}

.card-stack {
  position: relative;
  width: 100%;
  max-width: 360px;
  height: 480px;
  margin: 20px auto;
  touch-action: none;
}

.swipe-card {
  position: absolute;
  inset: 0;
  background: var(--bg-card);
  border-radius: 22px;
  overflow: hidden;
  box-shadow: 0 12px 30px rgba(0,0,0,0.4);
  display: flex;
  flex-direction: column;
  cursor: grab;
  user-select: none;
  transition: transform var(--swipe-duration, 0.25s) ease, opacity var(--swipe-duration, 0.25s) ease;
}
.swipe-card:active { cursor: grabbing; }
.swipe-card .img-wrap {
  flex: 1;
  background: #100b16 repeating-conic-gradient(#150f1d 0% 25%, #100b16 0% 50%) 50% / 24px 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.swipe-card img { max-width: 85%; max-height: 85%; image-rendering: pixelated; filter: drop-shadow(0 6px 10px rgba(0,0,0,0.5)); }
.swipe-card .info { padding: 16px 18px 20px; }
.swipe-card .item-name { font-weight: 700; font-size: 1.15rem; margin-bottom: 4px; }
.swipe-card .item-type { color: var(--text-dim); font-size: 0.85rem; }
.swipe-card .item-material { color: var(--text-dim); font-size: 0.8rem; margin-top: 4px; }

.current-vote-badge {
  position: absolute; top: 26px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,0.55); color: var(--text); font-size: 0.8rem;
  padding: 5px 12px; border-radius: 999px; z-index: 2;
}

.stamp {
  position: absolute;
  top: 26px;
  padding: 6px 14px;
  border: 3px solid;
  border-radius: 10px;
  font-weight: 800;
  font-size: 1.3rem;
  text-transform: uppercase;
  opacity: 0;
  pointer-events: none;
}
.stamp.like { left: 20px; color: var(--like); border-color: var(--like); transform: rotate(-14deg); }
.stamp.skip { right: 20px; color: var(--skip); border-color: var(--skip); transform: rotate(14deg); }

.vote-buttons { display: flex; gap: 26px; margin-top: 10px; }
.round-btn {
  width: 64px; height: 64px; border-radius: 50%; border: none; font-size: 1.6rem;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 16px rgba(0,0,0,0.35);
}
.skip-btn { background: var(--bg-card); color: var(--skip); border: 2px solid var(--skip); }
.like-btn { background: var(--bg-card); color: var(--like); border: 2px solid var(--like); }
.round-btn:active { transform: scale(0.92); }

.done-screen { text-align: center; padding: 60px 20px; }
.done-screen.hidden { display: none; }

.hidden { display: none !important; }

@media (max-width: 420px) {
  .card-stack { height: 60vh; }
}
