/* ══════════════════════════════════════
   Pedantix — Overlays & Modals
   ══════════════════════════════════════ */

/* ── Shared overlay base ── */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, .7);
  backdrop-filter: blur(6px)
}

.overlay.hidden { display: none }

.overlay-card {
  background: rgba(14, 14, 26, .97);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 2.5rem;
  max-width: 420px;
  width: 90%;
  text-align: center;
  box-shadow: 0 24px 80px rgba(0, 0, 0, .6)
}

[data-theme=light] .overlay-card { background: rgba(250, 250, 255, .97) }

.overlay-title { font-size: 1.5rem; font-weight: 800; margin-bottom: .5rem }
.overlay-sub { color: var(--text-2); font-size: .9rem; margin-bottom: 1.5rem }

/* ── Loading ── */
.loading-spinner {
  width: 40px; height: 40px;
  border: 3px solid rgba(99, 102, 241, .2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .9s linear infinite;
  margin: 0 auto 1rem
}

.loading-step { font-size: .8rem; color: var(--text-3); margin-top: .5rem }

/* ── Win overlay ── */
.win-emoji { font-size: 3rem; margin-bottom: .8rem }
.win-article-title { color: var(--accent); font-weight: 700; font-size: 1.1rem; margin-bottom: .5rem }
.win-stats { color: var(--text-2); font-size: .88rem; margin-bottom: 1rem; line-height: 1.7 }
.win-actions { display: flex; flex-direction: column; gap: .7rem }
.win-link { color: var(--accent); text-decoration: none; font-size: .83rem }
.win-link:hover { text-decoration: underline }

.win-pseudo-section {
  margin-top: 1rem; padding-top: .8rem;
  border-top: 1px solid var(--border);
  animation: fadeIn .4s ease;
}

.win-pseudo-section h3 { font-size: .82rem; font-weight: 700; color: var(--text-2); margin-bottom: .5rem; }
.win-pseudo-row { display: flex; gap: .5rem; justify-content: center; align-items: center; flex-wrap: wrap; }

.win-pseudo-input {
  background: var(--bg-input); border: 1px solid var(--border-accent);
  border-radius: var(--radius-sm); color: var(--text-1);
  padding: .45rem .8rem; font-size: .9rem; font-family: inherit;
  outline: none; width: 180px; text-align: center; transition: border-color .2s;
}

.win-pseudo-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(99, 102, 241, .15); }
.win-pseudo-input::placeholder { color: var(--text-3) }

/* ── Category overlay ── */
.cat-overlay {
  position: fixed; inset: 0; z-index: 510;
  display: flex; align-items: center; justify-content: center;
  background: rgba(4, 4, 14, .88); backdrop-filter: blur(10px)
}
[data-theme=light] .cat-overlay { background: rgba(220, 220, 238, .88) }
.cat-overlay.hidden { display: none }

.cat-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 20px; padding: 1.8rem 1.8rem 1.5rem;
  max-width: 680px; width: 96%; max-height: 92vh;
  overflow-y: auto; box-shadow: 0 32px 100px rgba(0, 0, 0, .6);
  position: relative;
}

.cat-close {
  position: absolute; top: .8rem; right: 1rem;
  background: none; border: none; color: var(--text-3);
  font-size: 1.2rem; cursor: pointer; padding: .3rem;
  display: none;
}
.cat-close:hover { color: var(--text-1) }
.cat-close.visible { display: block }

.cat-card::-webkit-scrollbar { width: 4px }
.cat-card::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px }

.cat-header { text-align: center; margin-bottom: 1.2rem }
.cat-header h2 { font-size: 1.45rem; font-weight: 800; margin-bottom: .28rem }
.cat-header p { color: var(--text-2); font-size: .84rem }

.cat-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: .6rem; margin-bottom: 1.1rem
}

.cat-item {
  position: relative; border: 2px solid var(--border);
  border-radius: 14px; padding: .9rem .85rem .78rem;
  cursor: pointer; transition: border-color .2s, background .2s, transform .15s;
  text-align: left; user-select: none; overflow: hidden
}
.cat-item:hover { border-color: var(--border-accent); background: rgba(99, 102, 241, .05); transform: translateY(-2px) }
.cat-item.selected { background: rgba(99, 102, 241, .1) }

.cat-item .cat-bar {
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px; border-radius: 14px 0 0 14px;
  opacity: 0; transition: opacity .2s
}
.cat-item.selected .cat-bar { opacity: 1 }

.cat-item .cat-check {
  position: absolute; top: .5rem; right: .5rem;
  width: 17px; height: 17px; border: 2px solid var(--border);
  border-radius: 50%; display: flex; align-items: center;
  justify-content: center; font-size: .65rem; transition: all .18s
}
.cat-item.selected .cat-check { background: var(--accent); border-color: var(--accent); color: #fff }

.cat-icon { font-size: 1.7rem; margin-bottom: .42rem; display: block; line-height: 1 }
.cat-name { font-size: .86rem; font-weight: 700; color: var(--text-1); margin-bottom: .14rem }
.cat-desc { font-size: .7rem; color: var(--text-3); line-height: 1.3 }
.cat-hint { text-align: center; font-size: .7rem; color: var(--text-3); margin-bottom: .8rem }

.cat-actions { display: flex; gap: .65rem; justify-content: center; flex-wrap: wrap }
.cat-actions .btn { min-width: 125px; padding: .52rem 1.1rem; font-size: .86rem }

/* ── Difficulty selector ── */
.diff-row { display: flex; gap: .5rem; justify-content: center; flex-wrap: wrap; margin-bottom: 1.1rem }
.diff-btn {
  flex: 1; max-width: 160px; padding: .55rem .6rem;
  border-radius: 10px; border: 2px solid var(--border);
  background: transparent; color: var(--text-2);
  font-family: inherit; font-size: .78rem; font-weight: 700;
  cursor: pointer; transition: all .18s; text-align: center; line-height: 1.3
}
.diff-btn:hover { border-color: var(--border-accent); color: var(--text-1); transform: translateY(-1px) }
.diff-btn.active { color: #fff; border-color: transparent }
.diff-btn.easy.active { background: #22c55e }
.diff-btn.normal.active { background: #f59e0b }
.diff-btn.hard.active { background: #ef4444 }
.diff-sep {
  text-align: center; font-size: .7rem; font-weight: 600;
  color: var(--text-3); letter-spacing: .06em; text-transform: uppercase; margin-bottom: .7rem
}

/* ── Multiplayer overlay ── */
.colab-overlay {
  position: fixed; inset: 0; z-index: 520;
  display: flex; align-items: center; justify-content: center;
  background: rgba(4, 4, 14, .9); backdrop-filter: blur(10px);
}
[data-theme=light] .colab-overlay { background: rgba(220, 220, 238, .9) }
.colab-overlay.hidden { display: none }

.colab-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 20px; padding: 2rem; max-width: 540px;
  width: 96%; max-height: 92vh; overflow-y: auto;
  box-shadow: 0 32px 100px rgba(0, 0, 0, .6);
}
.colab-card::-webkit-scrollbar { width: 4px }
.colab-card::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px }

.colab-header { text-align: center; margin-bottom: 1.4rem }
.colab-header h2 { font-size: 1.35rem; font-weight: 800; margin-bottom: .3rem }
.colab-header p { color: var(--text-2); font-size: .82rem }

.colab-pseudo-row { display: flex; gap: .5rem; justify-content: center; margin-bottom: 1.2rem; align-items: center; }
.colab-pseudo-row label { font-size: .8rem; font-weight: 600; color: var(--text-2); }
.colab-pseudo-input {
  background: var(--bg-input); border: 1px solid var(--border-accent);
  border-radius: var(--radius-sm); color: var(--text-1);
  padding: .45rem .7rem; font-size: .9rem; font-family: inherit;
  outline: none; width: 160px; transition: border-color .2s;
}
.colab-pseudo-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(99, 102, 241, .15) }

.colab-modes { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; margin-bottom: 1rem; }
.colab-mode {
  border: 2px solid var(--border); border-radius: 16px;
  padding: 1.2rem 1rem; cursor: pointer; transition: all .2s; text-align: center;
}
.colab-mode:hover { border-color: var(--accent); transform: translateY(-2px); background: rgba(99, 102, 241, .04) }
.colab-mode-icon { font-size: 2rem; margin-bottom: .5rem; display: block }
.colab-mode-title { font-size: .9rem; font-weight: 700; margin-bottom: .2rem }
.colab-mode-desc { font-size: .72rem; color: var(--text-3) }

.colab-create, .colab-join { display: none; text-align: center; animation: fadeIn .3s ease }
.colab-create.active, .colab-join.active { display: block }
.colab-back { font-size: .78rem; color: var(--text-3); cursor: pointer; margin-bottom: .8rem; display: inline-block; }
.colab-back:hover { color: var(--text-1) }

.code-display { display: flex; gap: .4rem; justify-content: center; margin: 1rem 0; }
.code-char {
  width: 42px; height: 50px; border-radius: 10px;
  background: rgba(99, 102, 241, .1); border: 2px solid var(--border-accent);
  display: flex; align-items: center; justify-content: center;
  font-family: 'JetBrains Mono', monospace; font-size: 1.3rem;
  font-weight: 800; color: var(--accent);
}
.code-char:nth-child(1) { animation: codeAppear .3s ease-out .0s backwards }
.code-char:nth-child(2) { animation: codeAppear .3s ease-out .05s backwards }
.code-char:nth-child(3) { animation: codeAppear .3s ease-out .1s backwards }
.code-char:nth-child(4) { animation: codeAppear .3s ease-out .15s backwards }
.code-char:nth-child(5) { animation: codeAppear .3s ease-out .2s backwards }
.code-char:nth-child(6) { animation: codeAppear .3s ease-out .25s backwards }

.colab-waiting-players { margin: .8rem 0; font-size: .8rem; color: var(--text-2); }
.colab-player-list { display: flex; gap: .3rem; justify-content: center; flex-wrap: wrap; margin: .5rem 0; }

.colab-code-input {
  background: var(--bg-input); border: 1px solid var(--border-accent);
  border-radius: var(--radius-sm); color: var(--text-1);
  padding: .55rem 1rem; font-size: 1.1rem;
  font-family: 'JetBrains Mono', monospace; font-weight: 700;
  letter-spacing: .25em; text-transform: uppercase;
  outline: none; width: 200px; text-align: center; transition: border-color .2s;
}
.colab-code-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(99, 102, 241, .15) }
.colab-code-input::placeholder { letter-spacing: .1em; font-weight: 400; color: var(--text-3) }
.colab-join-error { color: #ef4444; font-size: .78rem; font-weight: 600; margin-top: .4rem; min-height: 1.2em; }

.colab-close {
  position: absolute; top: .8rem; right: 1rem;
  background: none; border: none; color: var(--text-3);
  font-size: 1.2rem; cursor: pointer; padding: .3rem;
}
.colab-close:hover { color: var(--text-1) }

/* ── Leaderboard overlay ── */
.lb-overlay {
  position: fixed; inset: 0; z-index: 530;
  display: flex; align-items: center; justify-content: center;
  background: rgba(4, 4, 14, .9); backdrop-filter: blur(10px);
}
[data-theme=light] .lb-overlay { background: rgba(220, 220, 238, .9) }
.lb-overlay.hidden { display: none }

.lb-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 20px; padding: 1.8rem; max-width: 750px;
  width: 96%; max-height: 92vh; overflow-y: auto;
  box-shadow: 0 32px 100px rgba(0, 0, 0, .6); position: relative;
}
.lb-card::-webkit-scrollbar { width: 4px }
.lb-card::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px }

.lb-header { text-align: center; margin-bottom: 1rem }
.lb-header h2 { font-size: 1.35rem; font-weight: 800; margin-bottom: .3rem }
.lb-header p { color: var(--text-2); font-size: .82rem }

.lb-filters { display: flex; gap: .4rem; justify-content: center; margin-bottom: .6rem; flex-wrap: wrap; }
.lb-tab {
  padding: .38rem .8rem; border-radius: 8px; border: 2px solid var(--border);
  background: transparent; color: var(--text-2); font-family: inherit;
  font-size: .76rem; font-weight: 700; cursor: pointer; transition: all .18s;
}
.lb-tab:hover { border-color: var(--border-accent); color: var(--text-1) }
.lb-tab.active { background: var(--accent); color: #fff; border-color: var(--accent) }

.lb-diff-row { display: flex; gap: .3rem; justify-content: center; margin-bottom: 1rem; }
.lb-diff-btn {
  padding: .3rem .7rem; border-radius: 8px; border: 2px solid var(--border);
  background: transparent; color: var(--text-2); font-family: inherit;
  font-size: .72rem; font-weight: 700; cursor: pointer; transition: all .18s;
}
.lb-diff-btn:hover { border-color: var(--border-accent); color: var(--text-1) }
.lb-diff-btn.active { color: #fff; border-color: transparent }
.lb-diff-btn.active[data-diff=easy] { background: #22c55e }
.lb-diff-btn.active[data-diff=normal] { background: #f59e0b }
.lb-diff-btn.active[data-diff=hard] { background: #ef4444 }

.lb-table-wrap { overflow-x: auto }
.lb-table { width: 100%; border-collapse: collapse; font-size: .8rem; }
.lb-table th {
  text-align: left; padding: .5rem .5rem; font-size: .68rem;
  font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-3); border-bottom: 2px solid var(--border);
}
.lb-table td { padding: .42rem .5rem; border-bottom: 1px solid rgba(255, 255, 255, .04); }
.lb-table tr:nth-child(even) { background: rgba(255, 255, 255, .02) }
[data-theme=light] .lb-table tr:nth-child(even) { background: rgba(0, 0, 0, .02) }
.lb-table tr:hover { background: var(--bg-hover) }
.lb-table tr.lb-highlight { background: rgba(99, 102, 241, .08) !important; outline: 2px solid rgba(99, 102, 241, .3); border-radius: 4px; }
.lb-rank { font-weight: 800; text-align: center; min-width: 2rem }
.lb-rank.gold { color: #fbbf24 }
.lb-rank.silver { color: #94a3b8 }
.lb-rank.bronze { color: #d97706 }
.lb-pseudo { font-weight: 700; color: var(--text-1); max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.lb-mode-badge { font-size: .62rem; font-weight: 700; padding: .08rem .35rem; border-radius: 8px; }
.lb-mode-badge.solo { background: rgba(99, 102, 241, .15); color: var(--accent) }
.lb-mode-badge.coop { background: rgba(34, 197, 94, .15); color: var(--success) }
.lb-empty { text-align: center; color: var(--text-3); font-size: .85rem; padding: 2rem 0; font-style: italic; }
.lb-close {
  position: absolute; top: .8rem; right: 1rem;
  background: none; border: none; color: var(--text-3);
  font-size: 1.2rem; cursor: pointer; padding: .3rem;
}
.lb-close:hover { color: var(--text-1) }

/* ── Daily mode overlay ── */
.daily-badge {
  display: inline-flex; align-items: center; gap: .4rem;
  background: linear-gradient(135deg, rgba(245, 158, 11, .15), rgba(239, 68, 68, .15));
  border: 1px solid rgba(245, 158, 11, .3); border-radius: 20px;
  padding: .15rem .6rem; font-size: .68rem; font-weight: 700;
  color: #f59e0b; letter-spacing: .04em;
}
.daily-badge .daily-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: #f59e0b; animation: dailyPulse 2s ease-in-out infinite;
}
@keyframes dailyPulse { 0%, 100% { opacity: 1 } 50% { opacity: .3 } }

.daily-overlay {
  position: fixed; inset: 0; z-index: 540;
  display: flex; align-items: center; justify-content: center;
  background: rgba(4, 4, 14, .92); backdrop-filter: blur(10px);
}
[data-theme=light] .daily-overlay { background: rgba(220, 220, 238, .92) }
.daily-overlay.hidden { display: none }

.daily-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 20px; padding: 2rem; max-width: 700px;
  width: 96%; max-height: 92vh; overflow-y: auto;
  position: relative; box-shadow: 0 32px 100px rgba(0, 0, 0, .6);
}
.daily-card::-webkit-scrollbar { width: 4px }
.daily-card::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px }

.daily-close {
  position: absolute; top: .8rem; right: 1rem;
  background: none; border: none; color: var(--text-3);
  font-size: 1.2rem; cursor: pointer; padding: .3rem;
}
.daily-close:hover { color: var(--text-1) }

.daily-header { text-align: center; margin-bottom: 1.2rem }
.daily-header h2 { font-size: 1.4rem; font-weight: 800; margin-bottom: .3rem }
.daily-header p { color: var(--text-2); font-size: .82rem }
.daily-date { font-family: 'JetBrains Mono', monospace; font-size: 1.1rem; font-weight: 800; color: var(--accent); margin: .5rem 0; }
.daily-countdown { font-size: .78rem; color: var(--text-3); margin-bottom: 1rem; }

.daily-tabs { display: flex; gap: .4rem; justify-content: center; margin-bottom: 1rem; }
.daily-tab {
  padding: .42rem .9rem; border-radius: 8px; border: 2px solid var(--border);
  background: transparent; color: var(--text-2); font-family: inherit;
  font-size: .8rem; font-weight: 700; cursor: pointer; transition: all .18s;
}
.daily-tab:hover { border-color: var(--border-accent); color: var(--text-1) }
.daily-tab.active { background: linear-gradient(135deg, #f59e0b, #ef4444); color: #fff; border-color: transparent }

.daily-status { text-align: center; padding: 1rem 0; }
.daily-status-done {
  background: rgba(34, 197, 94, .1); border: 1px solid rgba(34, 197, 94, .3);
  border-radius: 12px; padding: .8rem; margin-bottom: 1rem;
  text-align: center; animation: fadeIn .3s ease;
}
.daily-status-done p { font-size: .85rem; color: var(--success); font-weight: 600 }
.daily-play-row { display: flex; gap: .6rem; justify-content: center; flex-wrap: wrap; margin-top: .8rem; }
