@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700;800&display=swap');
:root {
    --primary: #d4a36b;
    --secondary: #f0d9b5;
    --bg-color: #1f140d;
    --bg-2: #2c1f16;
    --glass-bg: rgba(245, 220, 180, 0.06);
    --glass-strong: rgba(245, 220, 180, 0.10);
    --glass-border: rgba(180, 110, 60, 0.35);
    --board-light: #f0d9b5;
    --board-dark: #b58863;
    --text-soft: #e8d5c0;
    --danger: #c97a5f;
    --success: #c9a06b;
    --warning: #e8c9a2;
}
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Poppins', sans-serif;
}
html, body {
    min-height: 100%;
}
body {
    background-color: var(--bg-color);
    color: white;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}
button {
    border: 0;
    outline: none;
}
.bg-animation {
    position: fixed;
    inset: 0;
    z-index: -3;
    background:
        radial-gradient(circle at 50% 50%, #2c1f16 0%, #1f140d 100%);
}
.bg-glow,
.bg-glow-two,
.bg-glow-three {
    position: fixed;
    border-radius: 50%;
    filter: blur(12px);
    z-index: -2;
    animation: pulse 10s infinite alternate ease-in-out;
}
.bg-glow {
    width: 640px;
    height: 640px;
    background: radial-gradient(circle, rgba(212, 140, 80, 0.22) 0%, transparent 72%);
    top: 48%;
    left: 55%;
    transform: translate(-50%, -50%);
}
.bg-glow-two {
    width: 460px;
    height: 460px;
    background: radial-gradient(circle, rgba(240, 180, 110, 0.16) 0%, transparent 70%);
    top: 18%;
    left: 18%;
    animation-duration: 13s;
}
.bg-glow-three {
    width: 520px;
    height: 520px;
    background: radial-gradient(circle, rgba(200, 130, 70, 0.14) 0%, transparent 68%);
    bottom: -80px;
    right: -60px;
    animation-duration: 11s;
}
@keyframes pulse {
    0% { transform: translate(-50%, -50%) scale(1); opacity: 0.52; }
    100% { transform: translate(-50%, -50%) scale(1.35); opacity: 1; }
}
@keyframes shine {
    0% { transform: translateX(-120%) skewX(-25deg); }
    100% { transform: translateX(260%) skewX(-25deg); }
}
@keyframes spin {
    100% { transform: rotate(360deg); }
}
@keyframes pulseRing {
    0% { box-shadow: 0 0 0 0 rgba(232, 190, 120, 0.45); }
    100% { box-shadow: 0 0 0 20px rgba(232, 190, 120, 0); }
}
.app {
    width: 100%;
    min-height: 100vh;
    padding: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.screen {
    width: 100%;
    max-width: 1320px;
    display: none;
    opacity: 0;
    transform: translateY(26px) scale(0.98);
    transition: all .45s cubic-bezier(.2,.8,.2,1);
}
.screen.active {
    display: block;
    opacity: 1;
    transform: translateY(0) scale(1);
}
.panel {
    background: linear-gradient(180deg, rgba(245,220,180,.06), rgba(245,220,180,.02));
    border: 1px solid var(--glass-border);
    border-radius: 30px;
    backdrop-filter: blur(14px);
    box-shadow: 0 20px 50px rgba(0,0,0,.45), inset 0 1px 0 rgba(245,220,180,.08);
    position: relative;
    overflow: hidden;
}
.panel::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(120deg, transparent 0%, rgba(245,220,180,.04) 45%, transparent 100%);
    pointer-events: none;
}
.home-panel {
    max-width: 860px;
    margin: 0 auto;
    padding: 48px 42px 42px;
    text-align: center;
}
.title {
    font-size: clamp(3rem, 8vw, 5.2rem);
    font-weight: 800;
    letter-spacing: 2px;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 38px rgba(212,140,80,.32);
}
.subtitle {
    margin-top: 18px;
    font-size: clamp(1rem, 2vw, 1.32rem);
    color: var(--text-soft);
    opacity: .96;
}
.home-actions {
    display: flex;
    justify-content: center;
    margin-top: 34px;
    gap: 16px;
    flex-wrap: wrap;
}
.btn {
    position: relative;
    padding: 14px 26px;
    border-radius: 16px;
    color: white;
    cursor: pointer;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    font-size: 1rem;
    font-weight: 600;
    transition: transform .25s ease, box-shadow .25s ease, border-color .25s ease, background .25s ease;
    overflow: hidden;
}
.btn::before {
    content: "";
    position: absolute;
    top: 0;
    left: -120%;
    width: 40%;
    height: 100%;
    background: linear-gradient(to right, transparent, rgba(255,255,255,.14), transparent);
    transform: skewX(-25deg);
}
.btn:hover {
    transform: translateY(-4px);
    box-shadow: 0 14px 30px rgba(0,0,0,.38);
    border-color: rgba(232,190,120,.45);
    background: rgba(245,220,180,.09);
}
.btn:hover::before {
    animation: shine .7s ease;
}
.btn-primary {
    background: linear-gradient(45deg, var(--primary), var(--secondary));
    border: none;
    box-shadow: 0 0 20px rgba(212,140,80,.32);
}
.btn-primary:hover {
    box-shadow: 0 0 30px rgba(212,140,80,.48);
}
.btn-ghost {
    background: rgba(245,220,180,.03);
}
.mode-wrap, .difficulty-wrap, .training-wrap {
    padding: 28px;
}
.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 20px;
}
.section-title {
    font-size: clamp(1.7rem, 3.4vw, 2.5rem);
    font-weight: 700;
    color: #fff;
}
.section-subtitle {
    color: var(--text-soft);
    opacity: .9;
    margin-top: 5px;
    font-size: .98rem;
}
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 18px;
}
.mode-card, .lesson-card, .difficulty-card {
    background: linear-gradient(180deg, rgba(245,220,180,.07), rgba(245,220,180,.025));
    border: 1px solid var(--glass-border);
    border-radius: 22px;
    padding: 22px;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    transition: transform .35s ease, box-shadow .35s ease, border-color .35s ease;
}
.mode-card::before, .lesson-card::before, .difficulty-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: -120%;
    width: 46%;
    height: 100%;
    background: linear-gradient(to right, transparent, rgba(245,220,180,.09), transparent);
    transform: skewX(-24deg);
}
.mode-card:hover, .lesson-card:hover, .difficulty-card:hover {
    transform: translateY(-8px);
    border-color: rgba(232,190,120,.5);
    box-shadow: 0 18px 34px rgba(0,0,0,.38), 0 0 20px rgba(212,140,80,.14);
}
.mode-card:hover::before, .lesson-card:hover::before, .difficulty-card:hover::before {
    animation: shine .8s ease;
}
.mode-icon {
    font-size: 2.4rem;
    margin-bottom: 16px;
    display: inline-block;
}
.card-title {
    font-size: 1.22rem;
    font-weight: 700;
    color: var(--secondary);
}
.card-desc {
    font-size: .94rem;
    line-height: 1.6;
    margin-top: 10px;
    color: #e8d5c0;
    opacity: .92;
}
.mode-card:hover .card-title,
.lesson-card:hover .card-title,
.difficulty-card:hover .card-title {
    color: white;
}
.training-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 14px;
    max-height: 68vh;
    overflow: auto;
    padding-right: 6px;
}
.training-grid::-webkit-scrollbar { width: 10px; }
.training-grid::-webkit-scrollbar-thumb {
    background: rgba(212,140,80,.25);
    border-radius: 999px;
}
.lesson-card {
    padding: 18px 16px;
}
.lesson-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.lesson-index {
    font-size: 1.25rem;
    font-weight: 800;
}
.lesson-badge {
    font-size: .7rem;
    font-weight: 700;
    padding: 5px 8px;
    border-radius: 999px;
    background: rgba(245,220,180,.08);
    border: 1px solid rgba(245,220,180,.08);
}
.lesson-card.completed {
    border-color: rgba(200,140,70,.45);
    box-shadow: 0 0 0 1px rgba(200,140,70,.12), 0 12px 24px rgba(0,0,0,.28);
}
.lesson-card.completed .lesson-badge {
    color: #f0d9b5;
    background: rgba(200,140,70,.18);
}
.difficulty-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
}
.difficulty-card {
    text-align: center;
    padding: 24px 18px;
}
.difficulty-rank {
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 12px;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.game-shell {
    display: grid;
    grid-template-columns: minmax(560px, 820px) 360px;
    gap: 22px;
    align-items: start;
}
.board-panel {
    padding: 24px;
}
.board-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}
.brand-row {
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.brand-name {
    font-size: 1.7rem;
    font-weight: 800;
    letter-spacing: .8px;
}
.brand-meta {
    color: var(--text-soft);
    font-size: .95rem;
}
.board-wrap {
    display: grid;
    grid-template-columns: 28px minmax(520px, 760px);
    gap: 10px;
    align-items: stretch;
}
.files-col, .ranks-row {
    display: grid;
}
.files-col {
    grid-template-rows: repeat(8, 1fr);
    color: rgba(232,200,160,.85);
    font-size: .88rem;
    font-weight: 700;
}
.files-col div {
    display: flex;
    align-items: center;
    justify-content: center;
}
.board-and-files {
    display: grid;
    grid-template-rows: minmax(520px, 760px) 28px;
    gap: 10px;
}
.ranks-row {
    grid-template-columns: repeat(8, 1fr);
    color: rgba(232,200,160,.85);
    font-size: .88rem;
    font-weight: 700;
}
.ranks-row div {
    display: flex;
    align-items: center;
    justify-content: center;
}
.board {
    width: 100%;
    aspect-ratio: 1 / 1;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    border-radius: 24px;
    overflow: hidden;
    border: 1px solid rgba(180,110,60,.25);
    box-shadow: 0 22px 46px rgba(0,0,0,.42), inset 0 0 0 1px rgba(245,220,180,.12);
    background: rgba(30,20,15,.25);
}
.square {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    user-select: none;
    transition: transform .12s ease, filter .2s ease;
}
.square.light { background: linear-gradient(180deg, rgba(245,220,180,.08), rgba(245,220,180,.03)), var(--board-light); }
.square.dark { background: linear-gradient(180deg, rgba(180,110,60,.12), rgba(30,20,15,.15)), var(--board-dark); }
.square:hover {
    filter: brightness(1.09);
}
.square.selected::after,
.square.move::after,
.square.capture::after,
.square.hint-from::after,
.square.hint-to::after,
.square.enemy-last::after,
.square.check::after {
    content: "";
    position: absolute;
    inset: 8%;
    border-radius: 16px;
    pointer-events: none;
}
.square.selected::after {
    border: 3px solid rgba(245,230,200,.85);
    box-shadow: 0 0 0 4px rgba(245,230,200,.18);
}
.square.move::after {
    background: radial-gradient(circle, rgba(232,190,120,.52) 0%, rgba(232,190,120,.14) 38%, transparent 42%);
}
.square.capture::after {
    border: 3px solid rgba(201,122,95,.85);
    box-shadow: inset 0 0 0 5px rgba(201,122,95,.18);
}
.square.hint-from::after {
    border: 3px solid rgba(232,200,130,.92);
    animation: pulseRing 1.1s infinite;
}
.square.hint-to::after {
    background: radial-gradient(circle, rgba(232,200,130,.62) 0%, rgba(232,200,130,.18) 45%, transparent 52%);
}
.square.enemy-last::after {
    border: 3px dashed rgba(232,190,120,.92);
    box-shadow: 0 0 18px rgba(232,190,120,.45);
}
.square.check::after {
    border: 3px solid rgba(201,90,65,.92);
    box-shadow: 0 0 20px rgba(201,90,65,.48), inset 0 0 16px rgba(201,90,65,.22);
}
.piece {
    font-size: clamp(2.1rem, 4.6vw, 3.6rem);
    line-height: 1;
    text-shadow: 0 6px 18px rgba(0,0,0,.38), 0 0 12px rgba(245,230,200,.08);
    transition: transform .18s ease, filter .18s ease;
    z-index: 2;
}
.square:hover .piece {
    transform: scale(1.04);
}
.piece.white {
    color: #f8f1e0;
    filter: drop-shadow(0 2px 8px rgba(245,230,200,.08));
}
.piece.black {
    color: #2c1f16;
    text-shadow: 0 4px 14px rgba(245,230,200,.08), 0 8px 18px rgba(0,0,0,.38);
}
.hidden-piece-mark {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(232,190,120,.95) 0%, rgba(232,190,120,.35) 52%, transparent 58%);
    box-shadow: 0 0 16px rgba(232,190,120,.55);
    z-index: 2;
}
.side-panel {
    padding: 22px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-height: 720px;
}
.info-card {
    background: linear-gradient(180deg, rgba(245,220,180,.06), rgba(245,220,180,.02));
    border: 1px solid rgba(245,220,180,.08);
    border-radius: 22px;
    padding: 16px;
}
.info-title {
    font-size: .92rem;
    color: var(--text-soft);
    opacity: .92;
    margin-bottom: 8px;
}
.status-box {
    min-height: 88px;
    line-height: 1.6;
    color: #e8d5c0;
    font-size: .95rem;
}
.status-box strong {
    color: white;
}
.action-stack {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.action-stack .btn {
    width: 100%;
    padding: 14px 14px;
}
.move-log {
    max-height: 270px;
    overflow: auto;
    padding-right: 4px;
    display: grid;
    gap: 8px;
}
.move-log::-webkit-scrollbar { width: 8px; }
.move-log::-webkit-scrollbar-thumb {
    background: rgba(212,140,80,.22);
    border-radius: 999px;
}
.move-entry {
    display: grid;
    grid-template-columns: 44px 1fr 1fr;
    gap: 10px;
    align-items: center;
    padding: 10px 12px;
    border-radius: 14px;
    background: rgba(245,220,180,.04);
    font-size: .9rem;
    color: #e8d5c0;
}
.move-num {
    color: var(--secondary);
    font-weight: 700;
}
.loader-wrap {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: .95rem;
    color: var(--text-soft);
}
.loader {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid rgba(245,220,180,.22);
    border-top-color: var(--secondary);
    animation: spin .8s linear infinite;
}
.pill-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}
.pill {
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(245,220,180,.06);
    border: 1px solid rgba(245,220,180,.09);
    font-size: .84rem;
    color: #e8d5c0;
}
.top-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}
.overlay {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(15,9,6,.68);
    backdrop-filter: blur(8px);
    z-index: 50;
    padding: 20px;
}
.overlay.active {
    display: flex;
}
.overlay-card {
    width: min(540px, 100%);
    padding: 28px;
    text-align: center;
}
.overlay-title {
    font-size: clamp(1.8rem, 4vw, 2.5rem);
    font-weight: 800;
    margin-bottom: 12px;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.overlay-text {
    color: #e8d5c0;
    line-height: 1.7;
    margin-bottom: 24px;
}
.small-note {
    color: var(--text-soft);
    font-size: .88rem;
}
.footer-credit {
    margin-top: 26px;
    color: rgba(232,200,160,.78);
    font-size: .9rem;
}
@media (max-width: 1180px) {
    .game-shell {
        grid-template-columns: 1fr;
    }
    .side-panel {
        min-height: 0;
    }
}
@media (max-width: 760px) {
    .app { padding: 14px; }
    .home-panel { padding: 34px 22px 26px; }
    .board-wrap { grid-template-columns: 22px 1fr; }
    .board-and-files { grid-template-rows: 1fr 22px; }
    .square.selected::after,
    .square.move::after,
    .square.capture::after,
    .square.hint-from::after,
    .square.hint-to::after,
    .square.enemy-last::after,
    .square.check::after { border-radius: 10px; }
}
.footer-legal {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 100;
    font-size: 0.88rem;
    color: rgba(232, 200, 160, 0.65);
}
.legal-link {
    color: rgba(232, 200, 160, 0.85);
    text-decoration: none;
    transition: all 0.25s ease;
    padding: 6px 12px;
    border-radius: 12px;
}
.legal-link:hover {
    color: var(--secondary);
    background: rgba(245, 220, 180, 0.08);
    text-decoration: none;
}
.separator {
    color: rgba(232, 200, 160, 0.4);
}
@media (max-width: 760px) {
    .footer-legal {
        bottom: 16px;
        font-size: 0.82rem;
        gap: 10px;
    }
}
.lang-switcher {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 9999px;
    display: flex;
    padding: 4px;
    box-shadow: 0 10px 30px rgba(0,0,0,.3);
    z-index: 1000;
}
.lang-btn {
    padding: 6px 14px;
    border-radius: 9999px;
    background: transparent;
    border: none;
    font-weight: 600;
    font-size: 0.85rem;
    color: #e8d5c0;
    transition: all .2s ease;
}
.lang-btn:hover {
    background: rgba(245,220,180,.12);
}
.lang-btn.active {
    background: linear-gradient(45deg, var(--primary), var(--secondary));
    color: #111;
    box-shadow: 0 0 12px rgba(212,140,80,.5);
}
@media (max-width: 760px) {
    .lang-switcher {
        top: 14px;
        right: 14px;
        padding: 3px;
    }
    .lang-btn {
        padding: 5px 12px;
        font-size: 0.8rem;
    }
}