* { box-sizing: border-box; }

:root {
  --discord: #5865f2;
  --xbox: #107c10;
  --ink: #1a1a2e;
  --muted: #666;
}

body {
  margin: 0;
  min-height: 100vh;
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #2b1055 0%, #7597de 100%);
  color: #333;
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
}

button { font: inherit; }
[hidden] { display: none !important; }

.container {
  width: min(100%, 650px);
  padding: 40px;
  background: rgba(255, 255, 255, .95);
  border: 1px solid rgba(255, 255, 255, .5);
  border-radius: 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
  backdrop-filter: blur(10px);
  animation: fade-in .55s ease-out;
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(-20px); }
  to { opacity: 1; transform: translateY(0); }
}

#loginView { max-width: 450px; margin: auto; text-align: center; }
.logo-icons { direction: ltr; display: flex; justify-content: center; align-items: center; gap: 15px; margin-bottom: 22px; }
.logo { width: 50px; height: 50px; display: grid; place-items: center; border-radius: 16px; color: white; font-size: 24px; font-weight: 800; box-shadow: 0 8px 18px rgba(0,0,0,.13); }
.logo img { width: 29px; height: 29px; }
.discord-logo { background: var(--discord); }
.xbox-logo { background: var(--xbox); }
.exchange { color: #aaa; font-size: 25px; }
h1 { margin: 0 0 10px; color: var(--ink); font-size: 28px; }
.subtitle { margin: 0 0 32px; color: var(--muted); font-size: 15px; line-height: 1.7; }

.btn {
  min-height: 50px;
  padding: 13px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 0;
  border-radius: 12px;
  font-weight: 650;
  cursor: pointer;
  transition: transform .25s, background .25s, box-shadow .25s;
}
.btn:hover:not(:disabled) { transform: translateY(-2px); }
.btn:disabled { opacity: .6; cursor: wait; }
.btn-discord { width: 100%; color: white; background: var(--discord); box-shadow: 0 8px 20px rgba(88,101,242,.25); font-size: 17px; }
.btn-discord:hover:not(:disabled) { background: #4752c4; box-shadow: 0 12px 25px rgba(88,101,242,.4); }
.button-logo { width: 21px; height: 21px; object-fit: contain; }

.features { margin-top: 35px; padding: 20px; border-radius: 16px; background: #f8f9fa; text-align: right; }
.features h2 { margin: 0 0 15px; font-size: 16px; }
.features p { margin: 10px 0 0; color: #555; font-size: 14px; }
.features p span { display: inline-grid; width: 20px; height: 20px; margin-left: 5px; place-items: center; border-radius: 50%; color: #16813b; background: #dcfce7; font-size: 11px; font-weight: bold; }

.oauth-steps { display: grid; gap: 0; text-align: right; }
.oauth-step { position: relative; display: grid; grid-template-columns: 30px 48px 1fr auto; align-items: center; gap: 12px; padding: 15px; border: 2px solid #e5e7eb; border-radius: 15px; background: white; transition: opacity .25s, border-color .25s, box-shadow .25s; }
.oauth-step.connected { border-color: #86d36c; box-shadow: 0 7px 18px rgba(40,167,69,.12); }
.oauth-step.locked { opacity: .55; background: #f5f5f5; }
.step-number { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; color: white; background: #25263a; font-size: 12px; font-weight: bold; }
.oauth-step.connected .step-number { background: #28a745; }
.step-logo { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 13px; }
.step-logo img { width: 27px; height: 27px; }
.step-copy { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.step-copy small { color: #999; font-size: 10px; }
.step-copy strong { color: #27272f; font-size: 15px; }
.step-copy > span { overflow: hidden; color: #777; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.step-button { min-width: 58px; padding: 9px 10px; border: 0; border-radius: 9px; color: white; font-weight: 650; cursor: pointer; }
.step-button:disabled { opacity: .55; cursor: not-allowed; }
.xbox-step-button { background: var(--xbox); }
.discord-step-button { background: var(--discord); }
.step-button.done { color: #166534; background: #dcfce7; }
.step-connector { height: 25px; margin-right: 43px; border-right: 2px dashed #cbd0d5; }
.step-connector span { display: block; width: 8px; height: 8px; margin-right: -5px; border-radius: 50%; background: #cbd0d5; transform: translateY(8px); }
.join-notice { margin-top: 18px; padding: 15px; display: grid; grid-template-columns: 35px 1fr auto; align-items: center; gap: 11px; border: 1px solid #fde68a; border-radius: 13px; background: #fffbeb; text-align: right; }
.join-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; color: #92400e; background: #fef3c7; font-weight: bold; }
.join-notice strong { color: #78350f; font-size: 13px; }
.join-notice p { margin: 4px 0 0; color: #92400e; font-size: 11px; line-height: 1.5; }
.join-notice a { padding: 9px 12px; border-radius: 9px; color: white; background: var(--discord); font-size: 11px; font-weight: bold; text-decoration: none; white-space: nowrap; }
.login-session-actions { margin-top: 18px; }
.login-session-actions .btn { width: 100%; }

.header { margin-bottom: 25px; text-align: center; }
.header p { margin: 0; color: var(--muted); font-size: 15px; }
.connection-area { display: flex; align-items: center; justify-content: center; gap: 15px; padding: 20px 0 30px; }
.profile-card { position: relative; width: 200px; min-height: 195px; padding: 22px 18px; border: 2px solid transparent; border-radius: 20px; background: white; box-shadow: 0 10px 30px rgba(0,0,0,.07); text-align: center; transition: transform .3s, opacity .3s; }
.profile-card:hover { transform: translateY(-4px); }
.discord-card { border-color: var(--discord); }
.xbox-card { border-color: var(--xbox); }
.xbox-card.unlinked { border-color: #ddd; border-style: dashed; background: #f8f9fa; opacity: .82; }
.platform-badge { position: absolute; top: 14px; right: 14px; width: 25px; height: 25px; display: grid; place-items: center; border-radius: 8px; color: white; font-size: 12px; font-weight: bold; }
.platform-badge img { width: 14px; height: 14px; }
.discord-badge { background: var(--discord); }
.xbox-badge { background: var(--xbox); }
.avatar { width: 80px; height: 80px; margin: 0 auto 12px; display: grid; place-items: center; overflow: hidden; border-radius: 50%; color: white; font-size: 28px; font-weight: 700; box-shadow: 0 5px 15px rgba(0,0,0,.12); background-size: cover; background-position: center; }
.avatar img { width: 42px; height: 42px; object-fit: contain; }
.discord-avatar { background-color: var(--discord); }
.xbox-avatar { background-color: var(--xbox); }
.xbox-card.unlinked .xbox-avatar { color: #bbb; background: #eee; }
.xbox-card.unlinked .xbox-avatar img { filter: grayscale(1); opacity: .45; }
.profile-card h2 { margin: 0 0 5px; overflow: hidden; color: #333; font-size: 18px; text-overflow: ellipsis; white-space: nowrap; }
.profile-card p { margin: 0; overflow: hidden; color: #888; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }

.link-status { position: relative; min-width: 75px; display: flex; align-items: center; justify-content: center; flex: 1; }
.link-line { position: absolute; width: 100%; height: 3px; background: #e0e0e0; }
.link-line.active { background: linear-gradient(90deg, var(--discord), var(--xbox)); }
.link-icon { position: relative; z-index: 1; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; color: #bbb; background: white; box-shadow: 0 4px 10px rgba(0,0,0,.1); font-size: 19px; }
.link-icon.active { color: #16813b; border: 2px solid #28a745; font-weight: bold; }

.actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; margin-top: 8px; }
.btn-xbox { color: white; background: var(--xbox); }
.btn-xbox:hover:not(:disabled) { background: #086508; box-shadow: 0 5px 15px rgba(16,124,16,.3); }
.btn-unlink, .btn-danger { color: #dc2626; background: #fee2e2; }
.btn-unlink:hover:not(:disabled), .btn-danger:hover:not(:disabled) { background: #fca5a5; }
.btn-logout, .btn-cancel { color: #4b5563; background: #f3f4f6; }
.btn-logout:hover:not(:disabled), .btn-cancel:hover:not(:disabled) { background: #e5e7eb; }
.database-note { margin: 0 0 18px; padding: 13px 16px; display: flex; align-items: center; justify-content: center; gap: 10px; border: 1px solid #bbf7d0; border-radius: 12px; color: #166534; background: #f0fdf4; }
.database-note > span { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; color: white; background: #28a745; font-weight: bold; }
.database-note div { display: flex; flex-direction: column; }
.database-note small { color: #4f7c58; }

.message { margin-bottom: 20px; padding: 12px 18px; border-radius: 10px; text-align: center; font-size: 14px; font-weight: 550; }
.message.success { color: #166534; background: #dcfce7; border: 1px solid #bbf7d0; }
.message.error { color: #991b1b; background: #fee2e2; border: 1px solid #fecaca; }
.message.warning { color: #854d0e; background: #fef9c3; border: 1px solid #fef08a; }
.loading-view { padding: 50px 0; display: grid; justify-items: center; gap: 15px; color: #666; }
.spinner { width: 34px; height: 34px; border: 4px solid #ddd; border-top-color: var(--discord); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.confirm-overlay { position: fixed; z-index: 10; inset: 0; padding: 20px; display: grid; place-items: center; background: rgba(18,12,32,.65); backdrop-filter: blur(5px); }
.confirm-box { width: min(100%, 420px); padding: 30px; border-radius: 20px; background: white; box-shadow: 0 20px 60px rgba(0,0,0,.35); text-align: center; }
.confirm-box h2 { margin: 12px 0 8px; }
.confirm-box p { margin: 0 0 24px; color: #666; line-height: 1.6; }
.confirm-box > div { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.warning-icon { width: 52px; height: 52px; margin: auto; display: grid; place-items: center; border-radius: 50%; color: #dc2626; background: #fee2e2; font-size: 25px; font-weight: bold; }

@media (max-width: 600px) {
  .container { padding: 30px 20px; }
  .connection-area { flex-direction: column; }
  .profile-card { width: 100%; }
  .link-status { width: 100%; height: 55px; }
  .link-line { width: 3px; height: 100%; }
  .actions { grid-template-columns: 1fr; }
  .confirm-box > div { grid-template-columns: 1fr; }
  .oauth-step { grid-template-columns: 27px 42px 1fr; }
  .step-button { grid-column: 1 / -1; width: 100%; }
  .join-notice { grid-template-columns: 35px 1fr; }
  .join-notice a { grid-column: 1 / -1; text-align: center; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
