*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #07070a;
  --surface: rgba(255, 255, 255, 0.04);
  --surface-hover: rgba(255, 255, 255, 0.07);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #f4f4f8;
  --text-muted: #9494a8;
  --ig-1: #833ab4;
  --ig-2: #fd1d1d;
  --ig-3: #fcb045;
  --accent: #e1306c;
  --gold: #f5c542;
  --gold-glow: rgba(245, 197, 66, 0.15);
  --silver: #b8c4d4;
  --success: #34d399;
  --error-bg: rgba(239, 68, 68, 0.12);
  --error-text: #fca5a5;
  --radius: 20px;
  --radius-sm: 12px;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
  --font: "Plus Jakarta Sans", system-ui, sans-serif;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* Ambient background */
.ambient {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.5;
  animation: float 20s ease-in-out infinite;
}

.orb-1 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(225, 48, 108, 0.35), transparent 70%);
  top: -150px;
  left: 50%;
  transform: translateX(-50%);
}

.orb-2 {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(131, 58, 180, 0.25), transparent 70%);
  bottom: -100px;
  right: -100px;
  animation-delay: -7s;
}

.orb-3 {
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, rgba(252, 176, 69, 0.15), transparent 70%);
  bottom: 30%;
  left: -80px;
  animation-delay: -14s;
}

@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(30px, -20px) scale(1.05); }
  66% { transform: translate(-20px, 15px) scale(0.95); }
}

.page {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  max-width: 760px;
  margin: 0 auto;
  width: 100%;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: inherit;
}

.brand-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--ig-1), var(--ig-2), var(--ig-3));
  color: white;
  box-shadow: 0 8px 24px rgba(225, 48, 108, 0.25);
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.brand-text strong {
  font-size: 0.95rem;
  font-weight: 700;
}

.brand-text small {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
}

.auth-pill {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 0.45rem 0.45rem 0.85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  backdrop-filter: blur(12px);
  font-size: 0.78rem;
  color: var(--text-muted);
  transition: border-color 0.25s, background 0.25s;
}

.auth-pill.logged-in {
  border-color: rgba(52, 211, 153, 0.3);
  background: rgba(52, 211, 153, 0.06);
  color: #86efac;
}

.auth-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
  transition: background 0.25s, box-shadow 0.25s;
}

.auth-pill.logged-in .auth-dot {
  background: var(--success);
  box-shadow: 0 0 8px rgba(52, 211, 153, 0.6);
}

#auth-status-text {
  max-width: 180px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.auth-actions {
  display: flex;
  gap: 0.35rem;
}

/* Container */
.container {
  flex: 1;
  max-width: 760px;
  margin: 0 auto;
  padding: 0 1.5rem 3rem;
  width: 100%;
}

/* Hero */
.hero {
  text-align: center;
  padding: 2rem 0 2.5rem;
}

.hero-badge {
  display: inline-block;
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}

.hero h1 {
  font-size: clamp(2rem, 5vw, 2.75rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin-bottom: 0.85rem;
}

.gradient-text {
  background: linear-gradient(135deg, #f472b6, #e1306c, #c084fc);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-desc {
  color: var(--text-muted);
  font-size: 1.02rem;
  max-width: 420px;
  margin: 0 auto;
}

/* Panel */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.panel-icon {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(225, 48, 108, 0.12);
  border-radius: var(--radius-sm);
  font-size: 1.4rem;
}

.panel-head h2 {
  font-size: 1.05rem;
  font-weight: 700;
}

.panel-head p {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.input-wrap {
  display: flex;
  gap: 0.75rem;
}

input[type="url"],
input[type="text"],
input[type="password"] {
  flex: 1;
  width: 100%;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.9rem 1.1rem;
  color: var(--text);
  font-family: inherit;
  font-size: 0.92rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus {
  border-color: rgba(225, 48, 108, 0.5);
  box-shadow: 0 0 0 3px rgba(225, 48, 108, 0.12);
}

input::placeholder {
  color: #5a5a6e;
}

.rules {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.65rem;
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.rule {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  padding: 0.65rem 0.4rem;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.2);
}

.rule-icon {
  font-size: 1.1rem;
}

.rule strong {
  color: var(--text);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.2s, box-shadow 0.2s;
  white-space: nowrap;
}

.btn:active:not(:disabled) {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-sm {
  font-size: 0.78rem;
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
}

.btn-full {
  width: 100%;
  padding: 0.85rem;
  margin-top: 0.25rem;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #c13584);
  color: white;
  font-size: 0.92rem;
  padding: 0 1.6rem;
  box-shadow: 0 8px 24px rgba(225, 48, 108, 0.3);
}

.btn-primary:hover:not(:disabled) {
  box-shadow: 0 12px 32px rgba(225, 48, 108, 0.4);
}

.btn-ig {
  background: linear-gradient(135deg, var(--ig-1), var(--ig-2), var(--ig-3));
  color: white;
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
}

.btn-ghost:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.btn-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Alert */
.alert {
  padding: 0.9rem 1.1rem;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  margin-top: 1rem;
}

.alert-error {
  background: var(--error-bg);
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: var(--error-text);
}

/* Stats */
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.85rem;
  margin-top: 1.5rem;
  animation: fadeUp 0.5s ease;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1rem;
  text-align: center;
  backdrop-filter: blur(12px);
  transition: transform 0.2s;
}

.stat-card:hover {
  transform: translateY(-2px);
}

.stat-highlight {
  border-color: rgba(225, 48, 108, 0.3);
  background: rgba(225, 48, 108, 0.06);
}

.stat-icon {
  font-size: 1.3rem;
  margin-bottom: 0.35rem;
}

.stat-value {
  display: block;
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
}

.stat-value.stat-small {
  font-size: 1rem;
  font-weight: 700;
}

.stat-highlight .stat-value {
  background: linear-gradient(135deg, #f472b6, var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stat-label {
  display: block;
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 0.2rem;
  font-weight: 600;
}

/* Results */
.results {
  margin-top: 2rem;
  animation: fadeUp 0.5s ease;
}

.results-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.results-header h2 {
  font-size: 1.4rem;
  font-weight: 800;
}

.results-header p {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 0.25rem;
}

.winner-section {
  margin-bottom: 1.5rem;
}

.section-label {
  margin-bottom: 0.75rem;
}

.label-badge {
  display: inline-block;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.label-badge.gold {
  background: var(--gold-glow);
  border: 1px solid rgba(245, 197, 66, 0.3);
  color: var(--gold);
}

.label-badge.silver {
  background: rgba(184, 196, 212, 0.1);
  border: 1px solid rgba(184, 196, 212, 0.25);
  color: var(--silver);
}

.winner-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.winner-card {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem;
  backdrop-filter: blur(12px);
  animation: fadeUp 0.45s ease both;
  transition: border-color 0.2s, transform 0.2s;
}

.winner-card:hover {
  transform: translateX(4px);
}

.winner-card.asil {
  border-color: rgba(245, 197, 66, 0.35);
  background: linear-gradient(135deg, rgba(245, 197, 66, 0.08), var(--surface));
  box-shadow: 0 8px 32px rgba(245, 197, 66, 0.08);
}

.winner-card.yedek {
  border-color: rgba(184, 196, 212, 0.2);
}

.winner-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.1rem;
  flex-shrink: 0;
  text-transform: uppercase;
}

.winner-card.asil .winner-avatar {
  background: linear-gradient(135deg, #f5c542, #e6a817);
  color: #1a1400;
  box-shadow: 0 4px 16px rgba(245, 197, 66, 0.3);
}

.winner-card.yedek .winner-avatar {
  background: linear-gradient(135deg, #94a3b8, #64748b);
  color: white;
}

.winner-body {
  flex: 1;
  min-width: 0;
}

.winner-username {
  font-weight: 700;
  font-size: 1.05rem;
}

.winner-username a {
  color: var(--text);
  text-decoration: none;
  transition: color 0.2s;
}

.winner-username a:hover {
  color: #f472b6;
}

.winner-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.winner-text {
  margin-top: 0.55rem;
  font-size: 0.88rem;
  color: #b4b4c4;
  font-style: italic;
  line-height: 1.45;
  padding-left: 0.75rem;
  border-left: 2px solid var(--border-strong);
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.hidden {
  display: none !important;
}

/* Footer */
.footer {
  text-align: center;
  padding: 1.5rem;
  color: var(--text-muted);
  font-size: 0.75rem;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
}

.modal-card {
  position: relative;
  width: 100%;
  max-width: 420px;
  background: #12121a;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
  animation: modalIn 0.3s ease;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.modal-close:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.modal-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.modal-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--ig-1), var(--ig-2));
  color: white;
  margin-bottom: 1rem;
}

.modal-header h2 {
  font-size: 1.25rem;
  font-weight: 700;
}

.modal-header p {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

.modal-form label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  margin: 0.85rem 0 0.4rem;
}

.modal-form label:first-of-type {
  margin-top: 0;
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.modal-note {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.modal-actions .btn-full {
  text-decoration: none;
}

/* Responsive */
@media (max-width: 640px) {
  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .auth-pill {
    justify-content: space-between;
  }

  #auth-status-text {
    max-width: none;
    flex: 1;
  }

  .input-wrap {
    flex-direction: column;
  }

  .btn-primary {
    width: 100%;
    padding: 0.95rem;
  }

  .rules {
    grid-template-columns: 1fr;
  }

  .stats {
    grid-template-columns: 1fr;
  }

  .hero {
    padding: 1rem 0 1.75rem;
  }
}
