@font-face {
    font-family: 'Outfit';
    src: url('../fonts/outfit-400.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
}

@font-face {
    font-family: 'Outfit';
    src: url('../fonts/outfit-600.woff2') format('woff2');
    font-weight: 600;
    font-style: normal;
}

@font-face {
    font-family: 'Outfit';
    src: url('../fonts/outfit-800.woff2') format('woff2');
    font-weight: 800;
    font-style: normal;
}

:root {
    /* Brand & Layout */
    --color-bg: #e9e9e9;
    --color-panel-bg: #d4d4d4;
    --color-header-bg: rgba(255, 255, 255, 0.03);
    --color-header-border: rgba(255, 255, 255, 0.05);

    /* Text */
    --color-primary: #444444;
    --color-text-main: #f8fafc;
    --color-text-muted: #8d8c8c;

    /* Buttons */
    --color-primary-hover: #3d3d3d;
    --color-secondary-bg: rgba(100, 100, 100, 0.2);
    --color-secondary-hover: rgba(100, 100, 100, 0.3);
    --color-btn-icon-hover: rgba(255, 255, 255, 0.1);

    /* Board */
    --color-sq-white: #f7f7f7;
    --color-sq-black: #b6b6b6;
    --color-board-border: #ffffff;

    /* Interaction & Feedback */
    --color-wrong: rgba(239, 68, 68, 0.7);
    --color-hint: rgba(16, 231, 62, 0.4);
    --color-selected: rgba(16, 231, 62, 0.4);
    --color-check-ring: #ef4444;
    --color-victory-success: #4ade80;
    --color-accent-gold: #da470dff;

    /* Overlays & Shadows */
    --color-overlay-bg: rgba(15, 23, 42, 0.85);
    --shadow-app: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    --shadow-board: 0 10px 25px rgba(0, 0, 0, 0.3);
    --shadow-piece: 0 4px 4px rgba(0, 0, 0, 0.4);
}

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

body {
    background-color: var(--color-bg);
    color: var(--color-text-main);
    font-family: 'Outfit', sans-serif;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 1rem;
    gap: 1.5rem;
    overflow-x: hidden;
    position: relative;
}

.logo-placeholder,
.info-placeholder {
    padding: 1.5rem;
    border-radius: 1rem;
    text-align: left;
    width: 100%;
    max-width: 500px;
    color: var(--color-text-muted);
    font-weight: 400;
}

.copyright-placeholder {
    padding: 1.5rem;
    border-radius: 1rem;
    text-align: right;
    width: 100%;
    max-width: 500px;
    color: var(--color-text-muted);
    font-weight: 400;
}

a {
    text-decoration: none;
    color: var(--color-text-muted);
}

@media (min-width: 1100px) {
    .logo-placeholder {
        position: absolute;
        top: 2rem;
        left: 2rem;
        width: 280px;
        margin: 0;
    }

    .info-placeholder {
        position: absolute;
        bottom: 2rem;
        left: 2rem;
        width: 280px;
        margin: 0;
    }

    .copyright-placeholder {
        position: absolute;
        bottom: 2rem;
        right: 2rem;
        width: 280px;
        margin: 0;
    }
}

.app-container {
    width: 100%;
    max-width: 500px;
    background: var(--color-panel-bg);
    border-radius: 1.5rem;
    box-shadow: var(--shadow-app);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    background: var(--color-header-bg);
    border-bottom: 1px solid var(--color-header-border);
}

h1 {
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: -0.025em;
    color: var(--color-primary);
}

.btn-icon {
    background: transparent;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    transition: all 0.2s;
    display: flex;
}

@media (hover: hover) {
    .btn-icon:hover {
        background: var(--color-btn-icon-hover);
        color: var(--color-text-main);
    }
}

.btn-icon:active {
    background: var(--color-btn-icon-hover);
    transition: none;
}

.btn-icon:focus {
    outline: none;
}

.hidden {
    display: none !important;
}

main {
    padding: 1.5rem;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.board-wrapper {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--shadow-board);
    border: 4px solid var(--color-board-border);
    position: relative;
}

.chess-board {
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    position: relative;
    user-select: none;
}

.square {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

.square.light {
    background-color: var(--color-sq-white);
}

.square.dark {
    background-color: var(--color-sq-black);
}

.square-coord-file {
    position: absolute;
    bottom: 2px;
    right: 4px;
    font-size: 0.6rem;
    font-weight: 600;
    opacity: 0.7;
    pointer-events: none;
}

.square-coord-rank {
    position: absolute;
    top: 2px;
    left: 4px;
    font-size: 0.6rem;
    font-weight: 600;
    opacity: 0.7;
    pointer-events: none;
}


.coord-light {
    color: var(--color-sq-black);   
}

.coord-dark {
    color: var(--color-sq-white); 
}




.piece {
    width: 100%;
    height: 100%;
    background-size: 85%;
    background-repeat: no-repeat;
    background-position: center;
    position: absolute;
    z-index: 10;
    cursor: grab;
    filter: drop-shadow(var(--shadow-piece));
    touch-action: none;
    transition: transform 0.1s;
}

.piece:active {
    cursor: grabbing;
}

.is-dragging {
    z-index: 1000 !important;
    pointer-events: none;
    transform: scale(1.2);
}

.highlight-wrong {
    animation: flashWrong 0.5s ease;
}

.highlight-hint {
    background-color: var(--color-hint) !important;
}

.highlight-selected {
    background-color: var(--color-selected) !important;
    box-shadow: inset 0 0 0 3px var(--color-primary);
}

@keyframes flashWrong {

    0%,
    100% {
        background-color: inherit;
    }

    50% {
        background-color: var(--color-wrong);
    }
}

.check-marker {
    position: absolute;
    width: 90%;
    height: 90%;
    border: 4px solid var(--color-check-ring);
    border-radius: 50%;
    box-sizing: border-box;
    z-index: 5;
    animation: ping 1.5s cubic-bezier(0, 0, 0.2, 1) infinite;
    pointer-events: none;
}

.animating {
    transition: top 0.3s ease-in-out, left 0.3s ease-in-out;
    z-index: 100;
}

@keyframes ping {

    75%,
    100% {
        transform: scale(1.2);
        opacity: 0;
    }
}

.controls {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.quiz-text {
    font-size: 1.1rem;
    line-height: 1.2;
    color: var(--color-primary);
    padding-top: 1rem;
    height: calc(1.5 * 1.1rem * 3 + 2rem);
    overflow-y: auto;
}

.timer {
    font-size: 1.1rem;
    color: var(--color-primary);
    font-weight: 400;
}

.action-buttons {
    display: flex;
    gap: 1rem;
}

.btn {
    flex: 1;
    padding: 0.875rem 1.5rem;
    border-radius: 0.75rem;
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.btn-primary {
    background: var(--color-primary);
    color: white;
    box-shadow: 0 4px 6px -1px rgba(156, 156, 156, 0.5);
    flex: 2;
}

.btn-primary:active {
    background: var(--color-primary-hover);
    transform: translateY(2px);
}

.btn-secondary {
    background: var(--color-secondary-bg);
    color: var(--color-text-main);
    flex: 1;
}

.btn-secondary:hover {
    background: var(--color-secondary-hover);
}

.victory-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--color-overlay-bg);
    backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 50;
    border-radius: 8px;
    animation: fadeIn 0.4s ease;
}

.victory-content {
    background: var(--color-panel-bg);
    padding: 2rem;
    border-radius: 1rem;
    text-align: center;
    box-shadow: var(--shadow-app);
    border: 1px solid var(--color-header-border);
}

.victory-content h2 {
    font-size: 2rem;
    color: var(--color-victory-success);
    margin-bottom: 0.5rem;
}

.victory-content p {
    color: var(--color-text-muted);
    margin-bottom: 1.5rem;
}