/* ============================================================
 *  MAPLESTORY VN — Site Stylesheet
 *  Kế thừa theme từ landing page
 * ============================================================ */

:root {
  /* ===== RANMELLE DARK MODE PALETTE ===== */
  --ranmelle-bg:           #0f1d34;
  --ranmelle-bg-deep:      #071120;
  --ranmelle-panel:        rgba(30, 41, 59, 0.78);
  --ranmelle-panel-strong: rgba(51, 65, 85, 0.9);
  --ranmelle-border:       rgba(148, 163, 184, 0.28);
  --ranmelle-blue:         #7faaf5;
  --ranmelle-blue-dark:    #6494e8;
  --ranmelle-blue-soft:    #93c5fd;
  --ranmelle-gold:         #d4b57a;
  --ranmelle-gold-soft:    #fde68a;
  --ranmelle-text:         #dbeafe;
  --ranmelle-text-soft:    #a8bdd8;
  --ranmelle-white:        #ffffff;

  /* Legacy mapping (per-page CSS ref vars này) */
  --bg-deep:      var(--ranmelle-bg-deep);
  --bg-mid:       var(--ranmelle-bg);
  --bg-warm:      #1e293b;
  --sunset:       var(--ranmelle-gold);
  --sunset-glow:  var(--ranmelle-gold-soft);
  --maple-red:    var(--ranmelle-blue-dark);
  --maple-orange: var(--ranmelle-blue);
  --maple-gold:   var(--ranmelle-gold);
  --leaf-rust:    var(--ranmelle-blue-dark);
  --cream:        var(--ranmelle-text);
  --ink:          var(--ranmelle-text);
  --star:         var(--ranmelle-white);
  --panel-bg:     var(--ranmelle-panel);
  --panel-border: var(--ranmelle-border);

  --accent-gold:   var(--ranmelle-gold);
  --accent-orange: var(--ranmelle-gold);
  --accent-red:    var(--ranmelle-blue-dark);
  --accent-blue:   var(--ranmelle-blue);

  --discord:      #5865F2;
  --success:      #4ade80;
  --warning:      var(--ranmelle-gold);
  --error:        #ef4444;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  min-height: 100vh;
  font-family: 'Quicksand', sans-serif;
  color: var(--ranmelle-text);
  -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(ellipse 60% 40% at 20% 8%, rgba(148, 163, 184, 0.14), transparent 65%),
    radial-gradient(ellipse 50% 40% at 82% 12%, rgba(127, 178, 245, 0.08), transparent 65%),
    linear-gradient(180deg, #0f1d34 0%, #0b1728 55%, #071120 100%);
  background-attachment: fixed;
  background-size: cover;
  position: relative;
  overflow-x: hidden;
}

a { color: var(--maple-gold); text-decoration: none; transition: color .25s; }
a:hover { color: var(--sunset-glow); }

/* ============================================================
 *  CHARACTER AVATAR (shared cho rankings, dashboard, etc.)
 * ============================================================ */
.char-avatar {
  width: 48px; height: 48px;
  object-fit: contain;
  object-position: center bottom;
  display: block;
  opacity: 0;
  transition: opacity .35s ease;
  /* Giữ pixel art sắc nét, không bị blur khi scale */
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
}
.char-avatar.loaded { opacity: 1; }
.char-avatar.error {
  opacity: 1;
  background: rgba(255, 244, 220, .04) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23ffc94a' opacity='0.4'><path d='M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z'/></svg>") center/60% no-repeat;
  border-radius: 8px;
}
.char-avatar:not(.loaded):not(.error) {
  background: linear-gradient(90deg,
    rgba(255, 244, 220, .04) 0%,
    rgba(241, 185, 79, .1)  50%,
    rgba(255, 244, 220, .04) 100%
  );
  background-size: 200% 100%;
  animation: char-shimmer 1.4s linear infinite;
  border-radius: 8px;
}
@keyframes char-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ============================================================
 *  BACKGROUND LAYERS (fixed to viewport)
 * ============================================================ */
.bg-stars {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  display: none; /* Thay bằng tsParticles hearts + stars */
}

.bg-mountains {
  display: none; /* Không dùng ngọn núi dark cho tone Ranmelle */
}

/* Particle container cho tsParticles */
#particles-js {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.bg-leaves {
  position: fixed; inset: 0; pointer-events: none; z-index: 2;
  overflow: hidden;
  display: none; /* Không cần lá phong; tsParticles thay thế */
}

.bg-grain {
  position: fixed; inset: 0; pointer-events: none; z-index: 9;
  opacity: .06; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)' opacity='1'/></svg>");
}

/* ============================================================
 *  NAVIGATION
 * ============================================================ */
.topnav {
  position: sticky; top: 0; z-index: 50;
  background: rgba(15, 29, 52, 0.78);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(148, 163, 184, 0.15);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}
.nav-inner {
  max-width: 1240px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 28px;
  gap: 24px;
}
.brand {
  display: inline-flex; align-items: center; gap: 12px;
  color: var(--ranmelle-text); text-decoration: none;
}
.brand-leaf {
  width: 36px; height: 36px;
  filter: drop-shadow(0 0 12px rgba(212, 181, 122, 0.55));
  transition: transform .4s cubic-bezier(.2,.8,.2,1);
}
.brand:hover .brand-leaf { transform: rotate(-12deg) scale(1.1); }
.brand-text { display: flex; flex-direction: column; line-height: 1; }
.brand-main {
  font-family: 'Bungee', cursive; font-size: 20px; letter-spacing: -.5px;
  background: linear-gradient(180deg, #fde68a 0%, var(--ranmelle-gold) 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.brand-sub {
  font-size: 10px; letter-spacing: 4px; text-transform: uppercase;
  font-weight: 700; color: var(--ranmelle-gold); margin-top: 3px;
}

.nav-links { display: flex; gap: 8px; align-items: center; }
.nav-links a {
  position: relative;
  padding: 8px 16px; border-radius: 999px;
  font-weight: 600; font-size: 14px;
  color: rgba(219, 234, 254, 0.75);
  letter-spacing: .3px;
  transition: all .25s;
}
.nav-links a:hover { color: var(--ranmelle-text); background: rgba(127, 178, 245, 0.1); }
.nav-links a.active {
  color: var(--ranmelle-gold);
  background: rgba(212, 181, 122, 0.12);
  box-shadow: inset 0 0 0 1px rgba(212, 181, 122, 0.3);
}
.nav-links .nav-discord {
  color: #c5cdff;
}
.nav-links .nav-discord::before {
  content: ''; display: inline-block; width: 7px; height: 7px;
  border-radius: 50%; background: var(--discord);
  margin-right: 7px; vertical-align: middle;
  box-shadow: 0 0 8px var(--discord);
}

.nav-auth { display: flex; gap: 10px; align-items: center; }

.btn-ghost {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 18px; border-radius: 999px;
  font-weight: 600; font-size: 14px;
  color: var(--cream);
  border: 1.5px solid rgba(255, 244, 220, .25);
  background: rgba(11, 10, 35, .3);
  transition: all .25s;
}
.btn-ghost {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 18px; border-radius: 999px;
  font-weight: 600; font-size: 14px;
  color: var(--ranmelle-text);
  border: 1.5px solid rgba(148, 163, 184, 0.28);
  background: rgba(15, 29, 52, 0.5);
  transition: all .25s;
}
.btn-ghost:hover {
  border-color: var(--ranmelle-gold);
  color: var(--ranmelle-gold);
  background: rgba(212, 181, 122, 0.1);
}
.btn-logout { padding: 9px 12px; }
.btn-cta {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 22px; border-radius: 999px;
  font-weight: 700; font-size: 14px;
  color: #fff;
  background: linear-gradient(180deg, var(--ranmelle-blue) 0%, var(--ranmelle-blue-dark) 100%);
  box-shadow: 0 6px 18px rgba(127, 178, 245, 0.35), inset 0 1px 0 rgba(255,255,255,.25);
  transition: all .25s cubic-bezier(.2,.8,.2,1);
}
.btn-cta:hover {
  transform: translateY(-2px); color: #fff;
  box-shadow: 0 10px 24px rgba(127, 178, 245, 0.55), inset 0 1px 0 rgba(255,255,255,.35);
}

/* Mobile nav toggle */
.nav-toggle {
  display: none;
  background: transparent; border: none; cursor: pointer;
  width: 40px; height: 40px;
  flex-direction: column; gap: 5px; justify-content: center; align-items: center;
}
.nav-toggle span {
  display: block; width: 22px; height: 2px; border-radius: 1px;
  background: var(--ranmelle-text); transition: all .3s;
}
.nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ============================================================
 *  PAGE LAYOUT
 * ============================================================ */
.page {
  position: relative; z-index: 5;
  max-width: 1240px;
  margin: 0 auto;
  padding: 40px 28px 80px;
}

.section-title {
  font-family: 'Bungee', cursive;
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.1;
  background: linear-gradient(180deg, #fde68a 0%, var(--ranmelle-gold) 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 4px 0 rgba(0, 0, 0, .4));
  margin-bottom: 6px;
}
.section-subtitle {
  font-size: 13px; font-weight: 600;
  color: var(--ranmelle-gold);
  letter-spacing: 3px; text-transform: uppercase;
  margin-bottom: 24px;
}

.page-head {
  text-align: center;
  margin-bottom: 36px;
}
.page-head-desc {
  max-width: 580px;
  margin: 12px auto 0;
  color: var(--ranmelle-text-soft);
  font-size: 14px;
  line-height: 1.6;
}

/* ============================================================
 *  PANELS / CARDS — dark glass
 * ============================================================ */
.panel {
  background: var(--ranmelle-panel);
  border: 1.5px solid var(--ranmelle-border);
  border-radius: 18px;
  padding: 28px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow:
    inset 0 1px 0 rgba(148, 163, 184, 0.08),
    0 12px 32px rgba(0, 0, 0, .35);
}
.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px; gap: 14px;
}
.panel-title {
  font-family: 'Bungee', cursive;
  font-size: 22px;
  color: var(--ranmelle-text);
}

/* ============================================================
 *  FORMS — đăng nhập, đăng ký
 * ============================================================ */
.auth-wrap {
  min-height: calc(100vh - 200px);
  display: flex; align-items: center; justify-content: center;
  padding: 32px 0;
}
.auth-card {
  width: 100%; max-width: 460px;
  background: var(--ranmelle-panel);
  border: 1.5px solid var(--ranmelle-border);
  border-radius: 22px;
  padding: 40px 36px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow:
    inset 0 1px 0 rgba(148, 163, 184, 0.08),
    0 20px 50px rgba(0, 0, 0, .4);
}
.auth-card .auth-leaf {
  display: block; width: 56px; height: 56px;
  margin: 0 auto 16px;
  filter: drop-shadow(0 0 18px rgba(212, 181, 122, 0.55));
  animation: leaf-bob 4s ease-in-out infinite;
}
@keyframes leaf-bob {
  0%,100% { transform: translateY(0) rotate(-3deg); }
  50%     { transform: translateY(-6px) rotate(3deg); }
}
.auth-title {
  font-family: 'Bungee', cursive;
  font-size: 32px; text-align: center;
  background: linear-gradient(180deg, #fde68a 0%, var(--ranmelle-gold) 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 8px;
}
.auth-sub {
  text-align: center; color: var(--ranmelle-text-soft);
  font-size: 13px; margin-bottom: 28px;
}

.form-group { margin-bottom: 18px; }
.form-label {
  display: block; margin-bottom: 8px;
  font-size: 12px; font-weight: 700;
  color: var(--ranmelle-gold);
  letter-spacing: 1.5px; text-transform: uppercase;
}
.form-input {
  width: 100%;
  padding: 14px 16px;
  background: rgba(7, 17, 32, 0.6);
  border: 1.5px solid rgba(148, 163, 184, 0.2);
  border-radius: 12px;
  color: var(--ranmelle-text);
  font-family: 'Quicksand', sans-serif;
  font-size: 15px; font-weight: 500;
  transition: all .25s;
}
.form-input:focus {
  outline: none;
  border-color: var(--ranmelle-blue);
  box-shadow: 0 0 0 3px rgba(127, 178, 245, 0.2);
  background: rgba(7, 17, 32, 0.85);
}
.form-input::placeholder { color: rgba(168, 189, 216, 0.4); }

.form-hint {
  margin-top: 6px;
  font-size: 12px; color: var(--ranmelle-text-soft);
}

.btn-submit {
  width: 100%;
  padding: 14px;
  margin-top: 8px;
  border: none; border-radius: 12px;
  font-family: 'Quicksand', sans-serif;
  font-size: 15px; font-weight: 700;
  letter-spacing: .8px; text-transform: uppercase;
  color: #0f1d34; cursor: pointer;
  background: linear-gradient(180deg, var(--ranmelle-gold-soft) 0%, var(--ranmelle-gold) 100%);
  box-shadow:
    0 8px 22px rgba(212, 181, 122, 0.35),
    inset 0 1px 0 rgba(255,255,255,.35);
  transition: all .3s cubic-bezier(.2,.8,.2,1);
  position: relative; overflow: hidden;
}
.btn-submit::before {
  content: ''; position: absolute;
  top: 0; left: -100%; width: 100%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.35), transparent);
  transition: left .6s;
}
.btn-submit:hover { transform: translateY(-2px); box-shadow: 0 14px 30px rgba(212, 181, 122, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.45); }
.btn-submit:hover::before { left: 100%; }
.btn-submit:active { transform: translateY(0); }
.btn-submit:disabled { opacity: .6; cursor: not-allowed; transform: none; }

.auth-switch {
  margin-top: 24px; padding-top: 20px;
  text-align: center; font-size: 14px;
  color: var(--ranmelle-text-soft);
  border-top: 1px solid rgba(148, 163, 184, 0.15);
}
.auth-switch a { font-weight: 700; }

/* ============================================================
 *  FLASH / ALERT MESSAGES
 * ============================================================ */
.flash-stack {
  display: flex; flex-direction: column; gap: 10px;
  margin-bottom: 24px;
}
.flash {
  padding: 14px 18px; border-radius: 12px;
  font-size: 14px; font-weight: 500;
  border: 1.5px solid;
  display: flex; align-items: center; gap: 12px;
  animation: flashIn .4s cubic-bezier(.2,.8,.2,1);
}
@keyframes flashIn {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.flash-success {
  background: rgba(74, 222, 128, .12); border-color: rgba(74, 222, 128, .35); color: #a7f3d0;
}
.flash-error {
  background: rgba(239, 68, 68, .12); border-color: rgba(239, 68, 68, .35); color: #fecaca;
}
.flash-warning {
  background: rgba(212, 181, 122, .14); border-color: rgba(212, 181, 122, .4); color: #fde68a;
}
.flash-info {
  background: rgba(127, 178, 245, .12); border-color: rgba(127, 178, 245, .35); color: #bfdbfe;
}

/* ============================================================
 *  FOOTER
 * ============================================================ */
.site-footer {
  position: relative; z-index: 5;
  margin-top: 80px;
  background: rgba(7, 17, 32, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid rgba(148, 163, 184, 0.15);
  padding: 36px 28px 28px;
}
.footer-inner {
  max-width: 1240px; margin: 0 auto;
  display: grid; grid-template-columns: 1.2fr 1fr 1.3fr;
  align-items: center; gap: 28px;
}
.footer-brand { display: flex; align-items: center; gap: 14px; }
.footer-title { font-family: 'Bungee', cursive; font-size: 18px; color: var(--ranmelle-text); }
.footer-sub { font-size: 11px; letter-spacing: 3px; text-transform: uppercase; color: var(--ranmelle-gold); }
.footer-links { display: flex; gap: 22px; justify-content: center; flex-wrap: wrap; }
.footer-links a { font-size: 13px; font-weight: 600; color: var(--ranmelle-text-soft); }
.footer-links a:hover { color: var(--ranmelle-gold); }
.footer-copy { font-size: 12px; color: rgba(168, 189, 216, 0.5); text-align: right; }
.footer-disclaimer { margin-top: 4px; font-size: 10px; opacity: .7; }

/* ============================================================
 *  RESPONSIVE
 * ============================================================ */
@media (max-width: 900px) {
  .nav-links, .nav-auth { display: none; }
  .nav-toggle { display: flex; }
  .topnav.open .nav-links,
  .topnav.open .nav-auth {
    display: flex;
    position: absolute; top: 100%; left: 0; right: 0;
    background: rgba(11, 10, 35, .96);
    flex-direction: column; align-items: stretch;
    padding: 16px; gap: 8px;
    border-bottom: 1px solid rgba(241, 185, 79, .2);
  }
  .topnav.open .nav-auth { top: auto; padding-top: 0; }
  .footer-inner { grid-template-columns: 1fr; text-align: center; }
  .footer-brand { justify-content: center; }
  .footer-copy { text-align: center; }
}
@media (max-width: 600px) {
  .page { padding: 28px 18px 60px; }
  .auth-card { padding: 32px 24px; }
  .brand-sub { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .bg-leaves .leaf, .bg-stars::before, .bg-stars::after, .auth-leaf { animation: none !important; }
}

/* ===== Registration closed / auth-closed page ===== */
.auth-container {
  display: flex; align-items: center; justify-content: center;
  min-height: 60vh;
  padding: 40px 20px;
}
.auth-closed-icon {
  font-size: 56px;
  text-align: center;
  margin-bottom: 12px;
  filter: drop-shadow(0 4px 12px rgba(241, 185, 79, 0.4));
}
.auth-closed-message {
  text-align: center;
  font-size: 16px;
  line-height: 1.6;
  color: rgba(255, 244, 220, 0.78);
  margin: 12px 0 28px;
}
.auth-closed-actions {
  display: flex; gap: 12px; justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 24px;
}
.auth-discord-hint {
  text-align: center;
  font-size: 13px;
  color: rgba(255, 244, 220, 0.55);
  margin: 0;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 244, 220, 0.08);
}
.auth-discord-hint a {
  color: var(--maple-gold);
  font-weight: 600;
}
.auth-discord-hint a:hover { color: var(--accent-orange); }
