/* ============================================
   DAMESFURY — Stylesheet
   Design: Warm mahogany & gold — premium board game
   © 2024-2026 PRESTATIC (SARL) — SOUILAH AKIM
   ============================================ */

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

:root {
    --bg-deep: #0d0907;
    --bg-warm: #1a0f07;
    --wood-light: #d4a76a;
    --wood-dark: #7b4230;
    --gold: #d4a843;
    --gold-light: #f0c040;
    --gold-dim: #a07c28;
    --copper: #c4724e;
    --cream: #f5e6d3;
    --text: #ede0d0;
    --text-dim: #9a8878;
    --fury: #ff6b35;
    --danger: #e74c3c;
    --ice: #00bcd4;
    --success: #4caf50;
    --purple: #3a2855;
    --radius: 12px;
    --shadow: 0 4px 24px rgba(0,0,0,0.5);
}

html, body {
    width: 100%; height: 100%;
    overflow: hidden;
    font-family: 'Nunito', sans-serif;
    background: var(--bg-deep);
    color: var(--text);
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

/* ==========================================
   SCREENS
   ========================================== */

.screen {
    position: fixed; inset: 0;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1;
}
.screen.active { display: flex; }

/* ==========================================
   MENU
   ========================================== */

.menu-bg {
    position: absolute; inset: 0;
    background:
        radial-gradient(ellipse at 30% 20%, rgba(212,168,67,0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 70% 80%, rgba(196,114,78,0.06) 0%, transparent 50%),
        linear-gradient(160deg, #0d0907 0%, #1a0f07 50%, #0d0907 100%);
    z-index: -1;
}
.menu-bg::before {
    content: '';
    position: absolute; inset: 0;
    background: repeating-linear-gradient(
        90deg,
        transparent 0px, transparent 60px,
        rgba(212,168,67,0.02) 60px, rgba(212,168,67,0.02) 61px
    );
}

.menu-container {
    text-align: center;
    padding: 40px 30px;
    max-width: 500px;
    width: 90%;
}

.menu-emblem {
    font-size: 64px;
    color: var(--gold);
    text-shadow: 0 0 30px rgba(212,168,67,0.4), 0 4px 12px rgba(0,0,0,0.5);
    margin-bottom: 8px;
    animation: emblemFloat 3s ease-in-out infinite;
}
@keyframes emblemFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.menu-title {
    font-family: 'Cinzel Decorative', serif;
    font-size: 48px;
    font-weight: 900;
    color: var(--cream);
    letter-spacing: 2px;
    text-shadow: 0 2px 12px rgba(0,0,0,0.5);
}
.menu-title span {
    color: var(--fury);
    text-shadow: 0 0 20px rgba(255,107,53,0.4);
}

.menu-subtitle {
    font-size: 16px;
    color: var(--text-dim);
    margin: 12px 0 36px;
    font-weight: 300;
    letter-spacing: 1px;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.menu-btn {
    display: block;
    width: 100%;
    padding: 16px 24px;
    border: 2px solid var(--gold-dim);
    border-radius: var(--radius);
    background: rgba(212,168,67,0.06);
    color: var(--cream);
    font-family: 'Nunito', sans-serif;
    font-size: 17px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.25s ease;
    letter-spacing: 0.5px;
}
.menu-btn:hover {
    background: rgba(212,168,67,0.15);
    border-color: var(--gold);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(212,168,67,0.15);
}
.menu-btn.primary {
    background: linear-gradient(135deg, var(--gold) 0%, var(--gold-dim) 100%);
    border-color: var(--gold-light);
    color: #1a0f07;
    font-size: 19px;
    text-shadow: 0 1px 0 rgba(255,255,255,0.2);
}
.menu-btn.primary:hover {
    background: linear-gradient(135deg, var(--gold-light) 0%, var(--gold) 100%);
    box-shadow: 0 6px 24px rgba(212,168,67,0.3);
}
.menu-btn.danger {
    border-color: var(--danger);
    color: var(--danger);
}
.menu-btn.danger:hover {
    background: rgba(231,76,60,0.15);
}

.menu-footer {
    margin-top: 40px;
    font-size: 12px;
    color: var(--text-dim);
}
.menu-footer p { margin-top: 8px; }
.back-link {
    color: var(--gold-dim);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s;
}
.back-link:hover { color: var(--gold); }

/* ==========================================
   HOW TO PLAY
   ========================================== */

.howto-container, .scores-container {
    position: relative;
    width: 100%; height: 100%;
    overflow-y: auto;
    padding: 24px;
    background: var(--bg-deep);
}
.howto-container h2, .scores-container h2 {
    font-family: 'Cinzel Decorative', serif;
    font-size: 28px;
    color: var(--gold);
    text-align: center;
    margin-bottom: 24px;
}

.back-btn {
    display: inline-block;
    padding: 10px 20px;
    background: none;
    border: 1px solid var(--gold-dim);
    border-radius: 8px;
    color: var(--gold);
    font-family: 'Nunito', sans-serif;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    margin-bottom: 16px;
    transition: all 0.2s;
}
.back-btn:hover {
    background: rgba(212,168,67,0.1);
    border-color: var(--gold);
}

.howto-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    max-width: 960px;
    margin: 0 auto;
    padding-bottom: 40px;
}

.howto-card {
    background: linear-gradient(135deg, rgba(26,15,7,0.95), rgba(42,28,16,0.9));
    border: 1px solid rgba(212,168,67,0.15);
    border-radius: var(--radius);
    padding: 20px;
    transition: border-color 0.3s, transform 0.3s;
}
.howto-card:hover {
    border-color: rgba(212,168,67,0.35);
    transform: translateY(-3px);
}
.howto-icon {
    font-size: 32px;
    margin-bottom: 8px;
}
.howto-card h3 {
    font-family: 'Cinzel Decorative', serif;
    font-size: 16px;
    color: var(--gold);
    margin-bottom: 8px;
}
.howto-card p {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-dim);
}
.howto-card p strong { color: var(--cream); }

/* ==========================================
   SCORES
   ========================================== */

.scores-list {
    max-width: 600px;
    margin: 0 auto;
}
.scores-empty {
    text-align: center;
    color: var(--text-dim);
    font-size: 16px;
    padding: 40px;
}

.score-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    background: linear-gradient(135deg, rgba(26,15,7,0.9), rgba(42,28,16,0.8));
    border: 1px solid rgba(212,168,67,0.12);
    border-radius: 10px;
    margin-bottom: 10px;
    transition: border-color 0.2s;
}
.score-row:hover { border-color: rgba(212,168,67,0.3); }
.score-rank { font-size: 22px; min-width: 36px; text-align: center; }
.score-pts {
    font-family: 'Cinzel Decorative', serif;
    font-size: 18px;
    color: var(--gold);
    font-weight: 700;
    min-width: 80px;
}
.score-detail {
    flex: 1;
    font-size: 13px;
    color: var(--text-dim);
}
.score-result {
    font-size: 12px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.score-result.win { background: rgba(76,175,80,0.2); color: var(--success); }
.score-result.lose { background: rgba(231,76,60,0.2); color: var(--danger); }
.score-date { font-size: 12px; color: var(--text-dim); min-width: 70px; text-align: right; }

/* ==========================================
   GAME SCREEN
   ========================================== */

#screenGame {
    justify-content: flex-start;
    background: var(--bg-deep);
}

/* ---- HUD ---- */

.game-hud {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 8px 16px;
    background: linear-gradient(180deg, rgba(26,15,7,0.95) 0%, rgba(13,9,7,0.9) 100%);
    border-bottom: 1px solid rgba(212,168,67,0.15);
    flex-shrink: 0;
    z-index: 5;
}

.hud-left, .hud-right { display: flex; align-items: center; gap: 10px; }
.hud-center { display: flex; align-items: center; justify-content: center; }

.hud-btn {
    width: 40px; height: 40px;
    border: 1px solid rgba(212,168,67,0.25);
    border-radius: 8px;
    background: rgba(212,168,67,0.08);
    color: var(--cream);
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex; align-items: center; justify-content: center;
}
.hud-btn:hover {
    background: rgba(212,168,67,0.2);
    border-color: var(--gold);
}

.turn-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 16px;
    background: rgba(212,168,67,0.08);
    border: 1px solid rgba(212,168,67,0.2);
    border-radius: 20px;
}
.turn-dot {
    width: 14px; height: 14px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.3);
    transition: all 0.3s;
}
.turn-dot.white { background: var(--cream); box-shadow: 0 0 8px rgba(245,230,211,0.4); }
.turn-dot.black { background: var(--purple); box-shadow: 0 0 8px rgba(58,40,85,0.6); }
.turn-text {
    font-size: 14px;
    font-weight: 700;
    color: var(--cream);
    letter-spacing: 0.5px;
}

.hud-stat {
    text-align: center;
}
.hud-label {
    display: block;
    font-size: 10px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1px;
}
.hud-value {
    display: block;
    font-family: 'Cinzel Decorative', serif;
    font-size: 18px;
    font-weight: 700;
    color: var(--gold);
}

/* ---- SCORE BAR ---- */

.score-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    width: 100%;
    padding: 8px 16px;
    background: rgba(26,15,7,0.8);
    border-bottom: 1px solid rgba(212,168,67,0.08);
    flex-shrink: 0;
    z-index: 4;
}

.player-side {
    display: flex;
    align-items: center;
    gap: 8px;
}
.side-piece {
    width: 22px; height: 22px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.2);
}
.white-piece { background: linear-gradient(135deg, #fff8ee, #c4a47a); }
.black-piece { background: linear-gradient(135deg, #5a4575, #1a1230); }
.side-count {
    font-size: 16px;
    font-weight: 800;
    color: var(--cream);
    min-width: 20px;
    text-align: center;
}
.side-score {
    font-family: 'Cinzel Decorative', serif;
    font-size: 20px;
    font-weight: 700;
    color: var(--gold);
}
.side-label {
    font-size: 11px;
    color: var(--text-dim);
    text-transform: uppercase;
}

.vs-sep {
    font-family: 'Cinzel Decorative', serif;
    font-size: 14px;
    color: var(--fury);
    font-weight: 700;
    letter-spacing: 2px;
}

/* ---- EVENT LOG ---- */

.event-log {
    position: fixed;
    top: 110px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    pointer-events: none;
    width: 90%;
    max-width: 400px;
}

.event-item {
    padding: 8px 18px;
    background: rgba(13,9,7,0.92);
    border: 1px solid rgba(212,168,67,0.25);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--cream);
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.3s, transform 0.3s;
    text-align: center;
    backdrop-filter: blur(8px);
}
.event-item.show { opacity: 1; transform: translateY(0); }
.event-item.hide { opacity: 0; transform: translateY(10px); }

/* ---- MODE TEXT ---- */

.mode-text {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 15;
    padding: 8px 20px;
    background: rgba(255,107,53,0.15);
    border: 1px solid var(--fury);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    color: var(--fury);
    text-align: center;
    animation: modePulse 1.5s ease-in-out infinite;
}
@keyframes modePulse {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 1; }
}

/* ---- GAME AREA ---- */

.game-area {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 8px;
    min-height: 0;
}

#gameCanvas {
    border: 3px solid var(--wood-dark);
    border-radius: 4px;
    box-shadow:
        0 0 0 1px rgba(212,168,67,0.2),
        0 8px 32px rgba(0,0,0,0.5),
        inset 0 0 20px rgba(0,0,0,0.1);
    max-width: 100%;
    max-height: 100%;
}

/* ---- ABILITY BAR ---- */

.ability-bar {
    display: flex;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 10px 16px;
    background: linear-gradient(0deg, rgba(26,15,7,0.95) 0%, rgba(13,9,7,0.9) 100%);
    border-top: 1px solid rgba(212,168,67,0.15);
    flex-shrink: 0;
    z-index: 5;
}

.ability-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 18px;
    border: 2px solid rgba(212,168,67,0.2);
    border-radius: 10px;
    background: rgba(212,168,67,0.05);
    color: var(--cream);
    font-family: 'Nunito', sans-serif;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.25s;
    position: relative;
    min-width: 80px;
}
.ability-btn:hover:not(:disabled) {
    background: rgba(212,168,67,0.15);
    border-color: var(--gold);
    transform: translateY(-2px);
}
.ability-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    filter: grayscale(60%);
}
.ability-btn.active-mode {
    border-color: var(--fury);
    background: rgba(255,107,53,0.15);
    box-shadow: 0 0 12px rgba(255,107,53,0.2);
}

.ability-icon { font-size: 22px; }
.ability-name { font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; }
.ability-badge {
    position: absolute;
    top: -6px; right: -6px;
    background: var(--gold);
    color: #1a0f07;
    font-size: 11px;
    font-weight: 800;
    padding: 2px 7px;
    border-radius: 10px;
    min-width: 22px;
    text-align: center;
}

/* ==========================================
   OVERLAYS
   ========================================== */

.overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(4px);
}

.overlay-panel {
    background: linear-gradient(145deg, #1a0f07, #2a1c10);
    border: 2px solid rgba(212,168,67,0.25);
    border-radius: 16px;
    padding: 36px 40px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}
.overlay-panel h2 {
    font-family: 'Cinzel Decorative', serif;
    font-size: 28px;
    color: var(--gold);
    margin-bottom: 24px;
}
.overlay-panel .menu-btn { margin-bottom: 10px; }

/* ---- GAME OVER ---- */

.go-title { transition: color 0.3s; }
.go-title.win { color: var(--success); }
.go-title.lose { color: var(--danger); }

.go-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 28px;
}
.go-stat {
    background: rgba(212,168,67,0.06);
    border: 1px solid rgba(212,168,67,0.12);
    border-radius: 10px;
    padding: 12px;
}
.go-label {
    display: block;
    font-size: 11px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 4px;
}
.go-value {
    font-family: 'Cinzel Decorative', serif;
    font-size: 22px;
    font-weight: 700;
    color: var(--gold);
}

/* ==========================================
   MOBILE RESPONSIVE
   ========================================== */

@media (max-width: 600px) {
    .menu-title { font-size: 36px; }
    .menu-emblem { font-size: 48px; }
    .menu-subtitle { font-size: 14px; }
    .menu-btn { padding: 14px 20px; font-size: 15px; }
    .menu-btn.primary { font-size: 17px; }

    .game-hud { padding: 6px 10px; }
    .hud-btn { width: 36px; height: 36px; font-size: 16px; }
    .turn-indicator { padding: 4px 12px; }
    .turn-text { font-size: 12px; }
    .hud-value { font-size: 16px; }

    .score-bar { padding: 6px 12px; gap: 10px; }
    .side-score { font-size: 17px; }

    .event-log { top: 95px; }
    .event-item { font-size: 12px; padding: 6px 14px; }

    .game-area { padding: 4px; }

    .ability-bar { padding: 8px 10px; gap: 8px; }
    .ability-btn { padding: 6px 12px; min-width: 65px; }
    .ability-icon { font-size: 18px; }
    .ability-name { font-size: 10px; }

    .mode-text { bottom: 68px; font-size: 12px; }

    .overlay-panel { padding: 28px 24px; }
    .overlay-panel h2 { font-size: 24px; }
    .go-value { font-size: 18px; }

    .howto-grid { grid-template-columns: 1fr; }
    .howto-container, .scores-container { padding: 16px; }
    .howto-container h2, .scores-container h2 { font-size: 24px; }

    .score-row { padding: 10px 12px; gap: 8px; flex-wrap: wrap; }
    .score-pts { font-size: 16px; }
    .score-detail { font-size: 11px; min-width: 100%; order: 5; }
}

@media (max-width: 380px) {
    .menu-title { font-size: 30px; }
    .hud-stat { display: none; }
    .hud-center { flex: 1; }
    .turn-text { font-size: 11px; }
    .side-label { display: none; }
    .ability-name { display: none; }
    .ability-btn { min-width: 55px; padding: 6px 10px; }
}

/* ==========================================
   AI ACTION BANNER
   ========================================== */

.ai-action-banner {
    position: fixed;
    top: 8px;
    left: 50%;
    transform: translateX(-50%) translateY(-60px);
    background: rgba(15,10,25,0.94);
    color: #ff6b35;
    font-family: 'Cinzel Decorative', serif;
    font-size: 1rem;
    font-weight: 700;
    padding: 8px 22px;
    border-radius: 10px;
    border: 1.5px solid rgba(255,107,53,0.5);
    box-shadow: 0 4px 18px rgba(255,107,53,0.25);
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    text-align: center;
    white-space: nowrap;
    letter-spacing: 0.04em;
}
.ai-action-banner.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

@media (max-width: 500px) {
    .ai-action-banner { font-size: 0.85rem; padding: 6px 16px; }
}

/* ==========================================
   SCROLLBAR
   ========================================== */

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-deep); }
::-webkit-scrollbar-thumb { background: var(--wood-dark); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gold-dim); }
