:root {
    --ls-color: #4a90d9;
    --light-square: #f0d9b5;
    --dark-square: #b58863;
    --highlight: rgba(255, 255, 0, 0.5);
    --board-size: 480px;
    --square-size: 60px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #1a1a2e;
    color: #eee;
    display: flex;
    justify-content: center;
    padding: 20px;
}

.container {
    max-width: 600px;
    width: 100%;
    text-align: center;
}

h1 {
    color: var(--ls-color);
    margin-bottom: 20px;
    font-size: 28px;
}

h3 {
    color: var(--ls-color);
    margin: 10px 0;
}

#puzzle-info {
    background: #16213e;
    border: 2px solid var(--ls-color);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
    font-size: 16px;
    text-align: left;
    line-height: 1.6;
}

#puzzle-info .puzzle-title {
    font-size: 20px;
    font-weight: bold;
    color: var(--ls-color);
    margin-bottom: 8px;
}

#puzzle-info .puzzle-task {
    color: #ff6b6b;
    font-weight: bold;
    font-size: 18px;
    margin-bottom: 8px;
}

#board-container {
    position: relative;
    display: inline-block;
    margin: 0 auto 20px;
}

#board {
    display: grid;
    grid-template-columns: repeat(8, var(--square-size));
    grid-template-rows: repeat(8, var(--square-size));
    border: 3px solid var(--ls-color);
    border-radius: 4px;
    overflow: hidden;
    margin-left: 25px;
    margin-bottom: 25px;
}

.square {
    width: var(--square-size);
    height: var(--square-size);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 42px;
    cursor: pointer;
    user-select: none;
    position: relative;
}

.square.light {
    background-color: var(--light-square);
}

.square.dark {
    background-color: var(--dark-square);
}

.square.highlight {
    background-color: var(--highlight) !important;
}

.square.selected {
    outline: 3px solid var(--ls-color);
    outline-offset: -3px;
}

.square.last-move {
    background-color: rgba(74, 144, 217, 0.3) !important;
}

#coordinates-bottom {
    position: absolute;
    bottom: 0;
    left: 25px;
    display: flex;
    width: calc(var(--square-size) * 8);
}

#coordinates-bottom span {
    width: var(--square-size);
    text-align: center;
    font-size: 14px;
    color: var(--ls-color);
    font-weight: bold;
}

#coordinates-left {
    position: absolute;
    top: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    height: calc(var(--square-size) * 8);
}

#coordinates-left span {
    height: var(--square-size);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: var(--ls-color);
    font-weight: bold;
    width: 25px;
}

#move-info {
    background: #16213e;
    border: 2px solid var(--ls-color);
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 15px;
    font-size: 18px;
    font-weight: bold;
}

.white-turn {
    color: #ffffff;
}

.black-turn {
    color: #888;
}

#moves-container {
    background: #16213e;
    border: 2px solid var(--ls-color);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
}

#move-inputs {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 10px 0;
}

.move-row {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
}

.move-row label {
    font-size: 16px;
    min-width: 120px;
    text-align: right;
}

.move-row select,
.move-row input {
    padding: 8px 12px;
    border: 2px solid var(--ls-color);
    border-radius: 5px;
    background: #0f3460;
    color: #eee;
    font-size: 16px;
    width: 100px;
}

.move-row select option {
    background: #0f3460;
    color: #eee;
}

button {
    padding: 10px 25px;
    margin: 5px;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    cursor: pointer;
    font-weight: bold;
    transition: background 0.3s;
}

#check-btn {
    background-color: var(--ls-color);
    color: white;
}

#check-btn:hover {
    background-color: #3a7bc8;
}

#reset-btn {
    background-color: #e74c3c;
    color: white;
}

#reset-btn:hover {
    background-color: #c0392b;
}

#result {
    padding: 15px;
    margin: 10px 0;
    border-radius: 8px;
    font-size: 20px;
    font-weight: bold;
    display: none;
}

#result.correct {
    display: block;
    background: #27ae60;
    color: white;
    border: 2px solid #2ecc71;
}

#result.incorrect {
    display: block;
    background: #e74c3c;
    color: white;
    border: 2px solid #ff6b6b;
}

#history {
    background: #16213e;
    border: 2px solid var(--ls-color);
    border-radius: 8px;
    padding: 15px;
    text-align: left;
}

#history-list {
    margin-top: 10px;
}

.history-entry {
    padding: 5px 10px;
    margin: 3px 0;
    background: #0f3460;
    border-radius: 4px;
    font-size: 14px;
}

.history-entry.white-move {
    border-left: 3px solid #fff;
}

.history-entry.black-move {
    border-left: 3px solid #888;
}

@media (max-width: 520px) {
    :root {
        --square-size: 40px;
    }

    .square {
        font-size: 28px;
    }

    h1 {
        font-size: 22px;
    }
}

.square {
    width: var(--square-size);
    height: var(--square-size);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 42px;
    cursor: pointer;
    user-select: none;
    position: relative;
}

/* Белые фигуры — светлые с тёмной обводкой */
.square .piece-white {
    color: #ffffff;
    text-shadow:
            -1px -1px 0 #000,
            1px -1px 0 #000,
            -1px 1px 0 #000,
            1px 1px 0 #000,
            0 0 3px #000;
    font-size: 44px;
}

/* Чёрные фигуры — тёмные с светлой обводкой */
.square .piece-black {
    color: #1a1a1a;
    text-shadow:
            -1px -1px 0 #fff,
            1px -1px 0 #fff,
            -1px 1px 0 #fff,
            1px 1px 0 #fff,
            0 0 3px rgba(255,255,255,0.5);
    font-size: 44px;
}

.piece-img {
    width: 85%;
    height: 85%;
    pointer-events: none;
    filter: drop-shadow(1px 1px 1px rgba(0, 0, 0, 0.3));
}