#pgn-name,
#pgn-text {
    padding: 8px;
    width: 100%;
}
.page-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}
.main-container {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    width: 100%;
}
.content-container {
    flex-grow: 1;
}
.analysis-wrapper.training-panel {
    background-color: #2c2c2c;
    border-radius: 8px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    font-family: var(--font-family-sans, "Inter", sans-serif);
}


.btn {
    display: inline-block;
    font-weight: 400;
    text-align: center;
    white-space: nowrap;
    vertical-align: middle;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    border: 1px solid transparent;
    padding: 0.375rem 0.75rem;
    font-size: 1rem;
    line-height: 1.5;
    border-radius: 0.25rem;
    transition:
        color 0.15s ease-in-out,
        background-color 0.15s ease-in-out,
        border-color 0.15s ease-in-out,
        box-shadow 0.15s ease-in-out;
}

.btn-lg {
    padding: 12px 24px;
    font-size: 1.1em;
    font-weight: 500;
}
.btn-primary {
    background-color: #4a77e5;
    color: #fff;
    border: none;
    border-radius: 4px;
    transition:
        background-color 0.2s,
        transform 0.2s;
}
.btn-primary:hover {
    background-color: #3a67d5;
    transform: translateY(-1px);
}
.btn-outline-primary {
    background-color: transparent;
    color: #4a77e5;
    border: 1px solid #4a77e5;
    border-radius: 4px;
    transition: 0.2s;
}
.btn-outline-primary:hover {
    background-color: rgba(74, 119, 229, 0.1);
}
.btn-outline-primary.active {
    background-color: #4a77e5;
    color: #fff;
}
.btn-outline-primary[data-color="black"],
.btn-outline-primary[data-mode="deep"] {
    color: #ffb74d;
    border-color: #ffb74d;
}
.btn-outline-primary[data-color="black"]:hover,
.btn-outline-primary[data-mode="deep"]:hover {
    background-color: rgba(255, 183, 77, 0.1);
    color: #ffb74d;
}
.btn-outline-primary[data-color="black"].active,
.btn-outline-primary[data-mode="deep"].active {
    background-color: #ffb74d;
    border-color: #ffb74d;
    color: #1a1a1a;
}

.training-controls {
    margin-top: auto;
    padding-top: 20px;
}

.board-area,
.repertoire-viewer h3 {
    display: flex;
    justify-content: center;
}
.training-header {
    margin-bottom: 20px;
    text-align: center;
}
.training-header h2 {
    margin: 0 0 15px;
    font-size: 1.8rem;
    font-weight: 700;
    font-family: "Playfair Display", serif;
}
#opening-name {
    white-space: normal;
    word-wrap: break-word;
    height: auto;
    line-height: 1.2;
}
.board-area {
    align-items: center;
    position: relative;
    flex-grow: 1;
    min-width: 0;
}
.board-wrapper {
    position: relative;
    width: 100%;
    max-width: 600px;
    aspect-ratio: 1/1;
    margin: 0 auto 75px;
}
.cg-square-mark {
    position: absolute;
    top: 5%;
    right: 5%;
    width: 60%;
    height: 60%;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 28px;
    z-index: 10;
    pointer-events: none;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
}
.main-line,
.move-line,
.variation {
    position: relative;
}
.cg-square-mark.correct {
    background-color: #15781b;
    color: #fff;
}
.cg-square-mark.incorrect {
    background-color: #882020;
    color: #fff;
}
@keyframes fadeOutMarkSmooth {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}
.mark-fade-out {
    animation: 0.3s ease-out forwards fadeOutMarkSmooth;
}
.training-stats {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
}
.stat-item {
    background-color: #3a3a3a;
    border-radius: 4px;
    padding: 8px 12px;
    flex: 1;
}
.stat-label {
    font-size: 0.85rem;
    color: #b0b0b0;
    display: block;
    margin-bottom: 2px;
}
.stat-value {
    font-size: 1.1rem;
    font-weight: 500;
}
.repertoire-viewer {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 20px;
}
.repertoire-viewer h3 {
    margin: 0 0 10px;
    font-size: 1.1rem;
    color: #e0e0e0;
    text-align: center;
    align-items: center;
}
.toggle-tree-btn {
    margin-left: 8px;
    width: 22px;
    height: 22px;
    font-size: 16px;
    line-height: 1;
    padding: 0;
    border: none;
    border-radius: 4px;
    background-color: #3a3a3a;
    color: #e0e0e0;
    cursor: pointer;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    transition: background-color 0.2s;
}
.toggle-tree-btn:hover {
    background-color: #4a4a4a;
}
#pgn-name,
#pgn-text,
.pgn-container {
    background-color: #222;
}
.toggle-tree-btn.collapsed {
    transform: rotate(45deg);
}
.pgn-container {
    border-radius: 4px;
    padding: 15px;
    font-family: Inter, sans-serif;
    max-height: 100%;
    overflow-y: auto;
    color: #ddd;
    font-size: 14px;
    text-align: left;
}
.pgn-container.loading {
    background-color: #222;
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center !important;
}
.move-line {
    margin: 2px 0;
    padding: 2px 0;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
}
.variation {
    margin-left: 20px;
    padding-left: 10px;
    border-left: 1px solid #444;
    display: block;
    width: calc(100% - 30px);
}
.variation.collapsed .move-node:not(:first-of-type),
.variation.collapsed .variation {
    display: none;
}
.move-number {
    color: #888;
    margin-right: 3px;
    font-weight: 400;
}
.move,
.toggle-btn {
    display: inline-block;
    border-radius: 3px;
    margin-right: 5px;
    cursor: pointer;
}
.move {
    padding: 1px 4px;
}
.move:hover,
.ot-move-text:hover {
    background-color: #444;
}
.move.active,
.ot-move-text.active {
    background-color: #3a7a9f;
    color: #fff;
}
.toggle-btn {
    width: 16px;
    height: 16px;
    line-height: 16px;
    text-align: center;
    color: #aaa;
    background-color: #333;
    font-size: 12px;
}
.toggle-btn:hover {
    background-color: #444;
    color: #fff;
}
.move-actions {
    margin-left: 10px;
}
.move-container {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
}
.comment {
    color: #7b7;
    margin-left: 5px;
    font-style: italic;
}
.nag {
    color: #b77;
    margin-left: 2px;
}
.feedback-container {
    background-color: #3a3a3a;
    border-radius: 4px;
    padding: 15px;
    margin-top: auto;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.feedback-item {
    display: flex;
    align-items: center;
    gap: 8px;
}
.feedback-correct,
.feedback-wrong {
    align-items: center;
    display: flex;
    font-weight: 500;
}
.feedback-correct {
    color: #78ff9d;
}
.feedback-wrong {
    color: #ff7878;
}
.feedback-hint {
    color: #ffde78;
    font-weight: 500;
}
.feedback-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    margin-right: 8px;
}
.correct .feedback-icon {
    color: #4cff71;
    text-shadow: 0 0 5px #0f0;
}
.incorrect .feedback-icon {
    color: #ff4c4c;
    text-shadow: 0 0 5px red;
}
.blurred-move {
    filter: blur(5px);
    cursor: pointer;
    user-select: none;
    transition: filter 0.3s;
    display: inline-block;
    padding: 0 3px;
}
.blurred-move:hover {
    filter: blur(3px);
}
.blurred-move.revealed {
    filter: blur(0);
}
@keyframes pulse {
    0%,
    100% {
        opacity: 0.6;
        background-color: rgba(255, 217, 0, 0.3);
    }
    50% {
        opacity: 1;
        background-color: rgba(255, 217, 0, 0.6);
    }
}
.back-link {
    font-family: var(--font-family-sans, "Inter", sans-serif);
    color: #b0b0b0;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border: 1px solid #4a4a4a;
    border-radius: 6px;
    transition: 0.2s;
    font-size: 0.9rem;
    white-space: nowrap;
}
.back-link:hover {
    background-color: #3f3b38;
    color: var(--text-color);
    border-color: #666;
}
@media screen and (min-width: 769px) {
    .back-link {
        position: absolute;
        top: 50%;
        transform: translateY(-50%);
        right: 2rem;
    }
}
@media screen and (max-width: 768px) {
    .back-link {
        display: none;
    }
}
.pgn-import {
    margin-top: 30px;
    padding: 15px;
    background-color: #262626;
    border-radius: 8px;
}
.pgn-import h3 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 1rem;
    color: #ddd;
}
#pgn-import-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
#pgn-text {
    height: 120px;
    border: 1px solid #444;
    border-radius: 4px;
    color: #ddd;
    font-family: monospace;
    resize: vertical;
}
#pgn-name {
    border: 1px solid #444;
    border-radius: 4px;
    color: #ddd;
}
#pgn-import-form .btn {
    background-color: #4a7dff;
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 8px;
    cursor: pointer;
    font-weight: 500;
}
#pgn-import-form .btn:hover {
    background-color: #3a66cc;
}
#pgn-import-form .btn-secondary {
    background-color: #555;
    margin-top: 5px;
}
#pgn-import-form .btn-secondary:hover {
    background-color: #666;
}
.ot-move-text {
    cursor: pointer;
    padding: 1px 4px;
    border-radius: 3px;
    margin-right: 2px;
    display: inline-block;
}
.ot-children {
    margin-left: 20px;
    border-left: 1px solid #ccc;
}
.cg-correct-mark {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.2em;
    color: #fff;
    text-shadow: 0 0 6px #0f0;
    pointer-events: none;
    animation: 0.8s forwards fadeOut;
    z-index: 10;
}
@keyframes fadeOut {
    0% {
        opacity: 1;
    }
    100% {
        opacity: 0;
    }
}
.cg-wrong {
    animation: 0.3s shake;
}
@keyframes shake {
    0%,
    100% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-4px);
    }
    75% {
        transform: translateX(4px);
    }
}
.progress-bar-container {
    width: 100%;
    height: 30px;
    border-radius: 4px;
    overflow: hidden;
    margin: 10px 0;
    display: flex;
    transition: 0.5s;
}
.progress-segment {
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #fff;
    font-weight: 500;
    position: relative;
    transition: width 0.5s;
    min-width: 30px;
}
.progress-segment-not-started {
    background-color: rgba(100, 116, 139, 0.2);
    border-left: 3px solid #64748b;
}
.legend-sample.learning,
.progress-segment-learning {
    background-color: rgba(234, 179, 8, 0.2);
    border-left: 3px solid #eab308;
}
.legend-sample.learned,
.progress-segment-learned {
    background-color: rgba(34, 197, 94, 0.2);
    border-left: 3px solid #22c55e;
}
.progress-legend {
    margin-top: 15px;
    background-color: #333;
    padding: 10px;
    border-radius: 4px;
}
.legend-title {
    font-weight: 500;
    margin-bottom: 12px;
    color: #e0e0e0;
}
.legend-items {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.legend-item {
    display: flex;
    align-items: center;
    color: #ddd;
}
.legend-swatch {
    display: flex;
    align-items: center;
    width: 24px;
    height: 24px;
    margin-right: 10px;
}
.legend-sample {
    display: inline-block;
    width: 24px;
    height: 20px;
    border-radius: 3px;
}
.legend-sample.not-started {
    background-color: rgba(100, 116, 139, 0.1);
    border-left: 3px solid #64748b;
}
.ot-move-text.opponent-move {
    color: #999;
    background-color: transparent;
    border-left-color: #555 !important;
}
.ot-move-text.opponent-move:hover {
    color: #ccc;
    background-color: #444;
}
@media screen and (max-width: 48rem) {
    .board-wrapper {
        width: 100%;
        margin: 0 0 4.5rem;
    }
    .board-area {
        flex-grow: 0;
    }
}
@media screen and (max-width: 48rem) and (orientation: landscape) {
    .board-area {
        flex: 2;
        max-width: 40%;
        padding: 0 0 0 1rem;
        flex-grow: 1;
    }
    .content-container {
        display: flex;
        flex-direction: row;
        align-items: flex-start;
        justify-content: space-between;
        gap: 1rem;
        padding: 0.5rem;
        height: calc(100vh - 120px);
    }
    .board-wrapper {
        width: 100%;
        max-width: none;
        margin: 0;
    }
    .analysis-wrapper.training-panel {
        max-width: 60%;
        height: 80vh;
        max-height: 80vh;
        overflow-y: auto;
        padding: 15px;
    }
    .progress-legend {
        margin-top: 10px;
        padding: 8px;
    }
    .legend-items {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 10px 20px;
    }
    .training-header {
        margin-bottom: 10px;
    }
    .training-header h2 {
        font-size: 1.4rem;
        margin-bottom: 10px;
    }
    .feedback-container {
        max-height: 20vh;
        overflow-y: auto;
        margin-top: 10px;
    }
}
@media screen and (max-width: 667px) and (max-height: 375px) and (orientation: landscape) {
    body {
        --board-size: min(36vw, 65vh);
    }
    .board-area {
        max-width: 36%;
    }
    .analysis-wrapper.training-panel {
        max-width: 64%;
    }
    .cg-wrap piece {
        background-size: 90%;
        transform: none !important;
    }
    .training-header h2 {
        font-size: 1.2rem;
        margin-bottom: 5px;
    }
    .repertoire-viewer {
        margin-bottom: 10px;
    }
}
@media screen and (min-width: 48.0625rem) and (max-width: 75rem) and (orientation: landscape) {
    .content-container {
        display: flex;
        flex-direction: row;
        align-items: flex-start;
    }
    .board-area {
        flex: 2;
        max-width: 40%;
        padding-left: 1rem;
    }
    .analysis-wrapper.training-panel {
        flex: 3;
        max-width: 60%;
    }
}

.training-header {
    text-align: center;
    padding: 15px;
    border-bottom: 1px solid #333;
}




.site-header {
    display: flex;
    justify-content: center; 
    align-items: center;
    position: relative;
    padding: 10px 20px;
}

.site-header .auth-container {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
}


@media (max-width: 768px) {
    .mobile-header {
        display: grid;
        grid-template-columns: 1fr auto 1fr;
        align-items: center;
    }

    .mobile-header .mobile-title {
        grid-column: 2;
        text-align: center;
    }

    .mobile-header .auth-container {
        grid-column: 3;
        justify-self: end;
    }
}
