/* ===== Google Fonts ===== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&family=Playfair+Display:ital,wght@0,400;0,600;1,400&display=swap');

/* ===== Design Tokens ===== */
:root {
    --bg-primary: #0a0a12;
    --bg-secondary: #12121f;
    --bg-card: rgba(255, 255, 255, 0.04);
    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-accent: rgba(212, 165, 116, 0.3);
    --text-primary: #f5f0eb;
    --text-secondary: #a09890;
    --text-muted: #6b6360;
    --accent: #d4a574;
    --accent-hover: #e0b88a;
    --accent-glow: rgba(212, 165, 116, 0.15);
    --danger: #c0616b;
    --success: #6bc061;
    --font-display: 'Playfair Display', Georgia, serif;
    --font-body: 'Inter', -apple-system, sans-serif;
    --radius: 16px;
    --radius-sm: 8px;
    --ease: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== Reset ===== */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    overflow-y: scroll;
}

html, body {
    min-height: 100%;
    font-family: var(--font-body);
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
}

/* ===== Ambient Background ===== */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(212, 165, 116, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(100, 80, 160, 0.05) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(212, 165, 116, 0.04) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
    animation: ambientShift 20s ease-in-out infinite alternate;
}

@keyframes ambientShift {
    0%   { opacity: 0.7; }
    100% { opacity: 1; }
}

/* ==========================================================================
   LOGIN PAGE
   ========================================================================== */
.login-container {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 1.5rem;
}

.login-card {
    background: var(--bg-card);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    padding: 3.5rem 3rem;
    max-width: 440px;
    width: 100%;
    text-align: center;
    position: relative;
    overflow: hidden;
    animation: cardAppear 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    opacity: 0;
    transform: translateY(20px);
}

@keyframes cardAppear {
    to { opacity: 1; transform: translateY(0); }
}

.login-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    opacity: 0.5;
}

.login-icon {
    font-size: 2.5rem;
    margin-bottom: 1.5rem;
    display: block;
    animation: floatIcon 3s ease-in-out infinite;
}

@keyframes floatIcon {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-6px); }
}

.login-question {
    font-family: var(--font-display);
    font-size: 1.45rem;
    font-weight: 400;
    font-style: italic;
    color: var(--text-primary);
    margin-bottom: 2rem;
    line-height: 1.6;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.login-input {
    width: 100%;
    padding: 1rem 1.25rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 1rem;
    text-align: center;
    letter-spacing: 0.08em;
    transition: var(--ease);
    outline: none;
    -webkit-appearance: none;
}

.login-input::placeholder {
    color: var(--text-muted);
    font-style: italic;
}

.login-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
    background: rgba(255, 255, 255, 0.05);
}

.login-btn {
    padding: 0.9rem 2rem;
    background: linear-gradient(135deg, var(--accent), #c49464);
    border: none;
    border-radius: var(--radius-sm);
    color: #0a0a12;
    font-family: var(--font-body);
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    cursor: pointer;
    transition: var(--ease);
    position: relative;
    overflow: hidden;
    -webkit-appearance: none;
    -webkit-tap-highlight-color: transparent;
}

.login-btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.5s, height 0.5s;
}

.login-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(212, 165, 116, 0.3);
}

.login-btn:hover::after {
    width: 300px;
    height: 300px;
}

.login-btn:active {
    transform: translateY(0);
}

.login-error {
    margin-top: 0.5rem;
    padding: 0.75rem 1rem;
    background: rgba(192, 97, 107, 0.1);
    border: 1px solid rgba(192, 97, 107, 0.2);
    border-radius: var(--radius-sm);
    color: var(--danger);
    font-size: 0.9rem;
    font-style: italic;
    animation: shakeError 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes shakeError {
    10%, 90% { transform: translate3d(-1px, 0, 0); }
    20%, 80% { transform: translate3d(2px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-3px, 0, 0); }
    40%, 60% { transform: translate3d(3px, 0, 0); }
}

/* ==========================================================================
   CHESS PAGE
   ========================================================================== */
.chess-container {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 1.5rem 1rem 3rem;
}

.chess-header {
    text-align: center;
    margin-bottom: 1.25rem;
    animation: fadeInDown 0.6s ease forwards;
}

@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-10px); }
    to   { opacity: 1; transform: translateY(0); }
}

.chess-title {
    font-family: var(--font-display);
    font-size: 1.6rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.6rem;
}

.chess-title span {
    color: var(--accent);
}

.chess-info-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: center;
}

.info-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.85rem;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 20px;
    font-size: 0.82rem;
    color: var(--text-secondary);
    backdrop-filter: blur(10px);
    transition: var(--ease);
}

.info-badge.full {
    border-color: var(--accent);
    color: var(--accent);
}

/* Main layout */
.chess-main {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
    flex-wrap: wrap;
    justify-content: center;
    animation: fadeIn 0.8s ease forwards;
    animation-delay: 0.2s;
    opacity: 0;
    width: 100%;
    max-width: 820px;
}

@keyframes fadeIn {
    to { opacity: 1; }
}

/* Board wrapper — position: relative for overlay positioning */
.board-wrapper {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    padding: 0.75rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    touch-action: none;
}

#board {
    max-width: 100%;
}

/* Side panel */
.side-panel {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-width: 200px;
    max-width: 260px;
    flex: 1;
}

.panel-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    padding: 1.15rem;
    backdrop-filter: blur(20px);
}

.panel-card h3 {
    font-family: var(--font-display);
    font-size: 0.78rem;
    font-weight: 400;
    color: var(--text-muted);
    margin-bottom: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.status {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-primary);
    transition: var(--ease);
}

.status.check {
    color: #e8a040;
}

.status.checkmate {
    color: var(--accent);
    font-weight: 600;
}

.status.draw {
    color: var(--text-secondary);
}

/* Move history */
#move-history {
    max-height: 240px;
    overflow-y: auto;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 0.82rem;
    color: var(--text-secondary);
    scrollbar-width: thin;
    scrollbar-color: var(--border-subtle) transparent;
}

#move-history::-webkit-scrollbar {
    width: 4px;
}

#move-history::-webkit-scrollbar-thumb {
    background: var(--border-subtle);
    border-radius: 2px;
}

.move-entry {
    padding: 0.25rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.025);
}

.move-num {
    color: var(--text-muted);
    margin-right: 0.3rem;
}

.move-white {
    color: var(--text-primary);
    margin-right: 0.5rem;
}

.move-black {
    color: var(--text-secondary);
}

/* Reset button */
.reset-btn {
    width: 100%;
    padding: 0.7rem;
    background: rgba(192, 97, 107, 0.08);
    border: 1px solid rgba(192, 97, 107, 0.18);
    border-radius: var(--radius-sm);
    color: var(--danger);
    font-family: var(--font-body);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--ease);
    letter-spacing: 0.04em;
    -webkit-tap-highlight-color: transparent;
}

.reset-btn:hover {
    background: rgba(192, 97, 107, 0.18);
    border-color: rgba(192, 97, 107, 0.35);
    transform: translateY(-1px);
}

/* ==========================================================================
   CHESSBOARD.JS DARK THEME OVERRIDES
   ========================================================================== */
.board-b72b1 {
    border-radius: 4px;
    overflow: hidden;
}

.white-1e1d7 {
    background-color: #c8b89a !important;
    color: #5c4a36 !important;
}

.black-3c85d {
    background-color: #7a5c3e !important;
    color: #c8b89a !important;
}

.highlight-white {
    background-color: rgba(212, 165, 116, 0.45) !important;
}

.highlight-black {
    background-color: rgba(212, 165, 116, 0.55) !important;
}

/* ==========================================================================
   BEKLEME OVERLAY (RAKİP BEKLENİYOR)
   ========================================================================== */
.waiting-overlay {
    position: absolute;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(10, 10, 18, 0.82);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border-radius: var(--radius);
    opacity: 1;
    transition: opacity 0.6s ease;
    pointer-events: auto;
}

.waiting-overlay.fade-out {
    opacity: 0;
    pointer-events: none;
}

.waiting-content {
    text-align: center;
    animation: waitingPulse 2s ease-in-out infinite;
}

@keyframes waitingPulse {
    0%, 100% { opacity: 0.85; transform: scale(1); }
    50%      { opacity: 1;    transform: scale(1.03); }
}

.waiting-spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto 1.25rem;
    border: 3px solid rgba(212, 165, 116, 0.15);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.waiting-text {
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-style: italic;
    color: var(--accent);
    letter-spacing: 0.03em;
}

/* ==========================================================================
   TOAST BİLDİRİMİ
   ========================================================================== */
.toast {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    opacity: 0;
    z-index: 10000;
    padding: 0.75rem 1.5rem;
    background: rgba(18, 18, 31, 0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-accent);
    border-radius: 12px;
    color: var(--accent);
    font-family: var(--font-body);
    font-size: 0.88rem;
    font-weight: 500;
    white-space: nowrap;
    pointer-events: none;
    transition: opacity 0.4s ease, transform 0.4s ease;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ==========================================================================
   GAME OVER POP-UP OVERLAY
   ========================================================================== */
.game-over-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    animation: overlayIn 0.4s ease forwards;
    padding: 1rem;
}

.game-over-overlay.hidden {
    display: none;
}

@keyframes overlayIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.game-over-card {
    background: rgba(18, 18, 31, 0.92);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    border: 1px solid var(--border-accent);
    border-radius: 20px;
    padding: 2.5rem 2.5rem 2rem;
    max-width: 380px;
    width: 100%;
    text-align: center;
    animation: cardPop 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    transform: scale(0.9);
    opacity: 0;
}

@keyframes cardPop {
    to { transform: scale(1); opacity: 1; }
}

.game-over-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 1rem;
    animation: floatIcon 3s ease-in-out infinite;
}

.game-over-title {
    font-family: var(--font-display);
    font-size: 1.6rem;
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 0.5rem;
}

.game-over-message {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 1.75rem;
    line-height: 1.6;
}

.game-over-btn {
    padding: 0.7rem 2rem;
    background: linear-gradient(135deg, var(--accent), #c49464);
    border: none;
    border-radius: var(--radius-sm);
    color: #0a0a12;
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    cursor: pointer;
    transition: var(--ease);
    -webkit-tap-highlight-color: transparent;
}

.game-over-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(212, 165, 116, 0.3);
}

.game-over-btn:active {
    transform: translateY(0);
}

/* ==========================================================================
   ANONİM NOT PANOSU
   ========================================================================== */
.notes-section {
    width: 100%;
    max-width: 820px;
    margin-top: 2rem;
    animation: fadeIn 1s ease forwards;
    animation-delay: 0.5s;
    opacity: 0;
}

.notes-container {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    padding: 1.5rem;
    backdrop-filter: blur(20px);
}

.notes-title {
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 400;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    text-align: center;
    letter-spacing: 0.02em;
}

.notes-wall {
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    scrollbar-width: thin;
    scrollbar-color: var(--border-subtle) transparent;
}

.notes-wall::-webkit-scrollbar {
    width: 4px;
}

.notes-wall::-webkit-scrollbar-thumb {
    background: var(--border-subtle);
    border-radius: 2px;
}

.note-item {
    padding: 0.7rem 1rem;
    background: rgba(255, 255, 255, 0.025);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.88rem;
    line-height: 1.5;
    animation: noteIn 0.35s ease forwards;
    opacity: 0;
    transform: translateY(6px);
}

@keyframes noteIn {
    to { opacity: 1; transform: translateY(0); }
}

.notes-input-area {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
}

.note-textarea {
    flex: 1;
    padding: 0.7rem 1rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.88rem;
    resize: none;
    outline: none;
    transition: var(--ease);
    -webkit-appearance: none;
}

.note-textarea::placeholder {
    color: var(--text-muted);
    font-style: italic;
}

.note-textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

.note-btn {
    padding: 0.7rem 1.25rem;
    background: rgba(212, 165, 116, 0.12);
    border: 1px solid var(--border-accent);
    border-radius: var(--radius-sm);
    color: var(--accent);
    font-family: var(--font-body);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--ease);
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
}

.note-btn:hover {
    background: rgba(212, 165, 116, 0.22);
    transform: translateY(-1px);
}

.note-btn:active {
    transform: translateY(0);
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */
@media (max-width: 860px) {
    .chess-main {
        flex-direction: column;
        align-items: center;
    }

    .side-panel {
        min-width: 100%;
        max-width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
    }

    .side-panel .panel-card {
        flex: 1 1 45%;
        min-width: 140px;
    }

    .side-panel .reset-btn {
        flex: 1 1 100%;
    }
}

@media (max-width: 540px) {
    .chess-container {
        padding: 1rem 0.75rem 2rem;
    }

    .chess-title {
        font-size: 1.35rem;
    }

    .board-wrapper {
        padding: 0.4rem;
        border-radius: 12px;
    }

    .side-panel {
        flex-direction: column;
    }

    .side-panel .panel-card {
        flex: 1 1 100%;
    }

    .notes-container {
        padding: 1rem;
    }

    .notes-input-area {
        flex-direction: column;
    }

    .note-btn {
        width: 100%;
        text-align: center;
    }

    .waiting-text {
        font-size: 1rem;
    }

    .toast {
        font-size: 0.8rem;
        padding: 0.6rem 1.2rem;
        max-width: calc(100vw - 2rem);
        white-space: normal;
        text-align: center;
    }
}

@media (max-width: 380px) {
    .login-card {
        padding: 2rem 1.5rem;
    }

    .login-question {
        font-size: 1.2rem;
    }

    .login-input {
        padding: 0.85rem 1rem;
        font-size: 0.95rem;
    }

    .chess-header {
        margin-bottom: 0.75rem;
    }

    .chess-title {
        font-size: 1.2rem;
    }

    .info-badge {
        font-size: 0.75rem;
        padding: 0.3rem 0.65rem;
    }

    .game-over-card {
        padding: 2rem 1.5rem 1.5rem;
    }

    .game-over-title {
        font-size: 1.3rem;
    }
}
