:root {
    --bg: #f8f8fb;
    --surface: #ffffff;
    --border: #e5e7f0;
    --text: #1d1d29;
    --muted: #70758c;
    --accent: #2f62f3;
    --accent-soft: #eff2ff;
    --square-light: #f3dcb4;
    --square-dark: #c49062;
    --badge-bg: #f1f3f9;
    --radius-xl: 28px;
    --radius-lg: 20px;
    --shadow-soft: 0 12px 30px rgba(16, 24, 40, 0.08);
    --square-size: 76px;
}

* {
    box-sizing: border-box;
}

html {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: "Poppins", "Roboto", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
    margin: 0;
    min-height: 100%;
    overflow: hidden;
}

#app-root {
    min-height: 100%;
}

.app-shell {
    min-height: 100%;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1;
    overflow: hidden;
    padding: 1rem clamp(1.5rem, 5vw, 4rem) 2rem;
}

body > noscript {
    display: block;
    padding: 0.5rem 1rem;
    background: #fef3c7;
    color: #92400e;
    text-align: center;
    font-weight: 500;
}

.app-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem clamp(1.5rem, 4vw, 4rem);
    position: sticky;
    top: 0;
    z-index: 5;
}

.app-header__brand {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
}

.app-header__left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo {
    font-weight: 700;
    font-size: 1.2rem;
    letter-spacing: 0.02em;
}

.tagline {
    color: var(--muted);
    font-size: 0.9rem;
}

.app-header__actions {
    display: flex;
    gap: 0.5rem;
}

.sidebar-button-header {
    display: inline-flex;
    margin-right: 0.75rem;
    border: none;
    background: transparent;
    color: inherit;
    cursor: pointer;
    width: 44px;
    height: 44px;
    align-items: center;
    justify-content: center;
}

.variant-panel-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    z-index: 14;
}

.variant-panel-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.variant-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: min(360px, 88vw);
    height: 100vh;
    background: var(--surface);
    box-shadow: 0 10px 40px rgba(0,0,0,0.25);
    transform: translateX(-110%);
    transition: transform 0.3s ease;
    z-index: 15;
    display: flex;
    flex-direction: column;
}

.variant-panel.active {
    transform: translateX(0);
}

.variant-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    height: 56px;
    background: #222;
    color: #fff;
}

.variant-panel__title {
    font-weight: 700;
    font-size: 1rem;
    color: #ffe27a;
}

.back_variant,
.variant-panel__header .back-button {
    width: 36px;
    height: 36px;
    border: 1px solid #222;
    background: #ffe27a;
    color: #111;
    cursor: pointer;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.variant-panel__content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0.75rem 1.5rem;
}

.lessons-container,
.course-lessons-container,
.course-lessons-list {
    width: 100%;
}

.lessons-list-accordion {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.lessons-list-accordion .chapter-item {
    background: #f8f8f8;
    border-color: transparent;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.35rem 0.6rem;
}

.lessons-list-accordion .chapter-item.active {
    background: #fff0ba;
    border-color: #ffe27a;
}

.course-lesson-name {
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.25rem;
    cursor: pointer;
    font: inherit;
    color: inherit;
}

.course-lesson-name:focus {
    outline: none;
}

.lesson-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.badge {
    padding: 0.35rem 0.9rem;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 600;
    background: var(--accent);
    color: white;
}

.badge-link {
    text-decoration: none;
    display: inline-block;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.badge-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(47, 98, 243, 0.3);
}

.badge--soft {
    background: var(--badge-bg);
    color: var(--text);
}

.page-hero {
    padding: 2.5rem clamp(1.5rem, 5vw, 4rem) 1rem;
    background: transparent;
}

.page-hero__text {
    max-width: 720px;
}

.page-hero__eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.15em;
    font-size: 0.8rem;
    color: var(--muted);
    margin-bottom: 0.3rem;
}

.page-hero h1 {
    margin: 0 0 0.5rem;
    font-size: clamp(1.8rem, 4vw, 2.6rem);
}

.page-hero p {
    margin: 0;
    color: var(--muted);
}

main {
    padding: 1rem clamp(1.5rem, 5vw, 4rem) 2rem;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.openings {
    display: grid;
    gap: 1.5rem;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.opening-card {
    position: relative;
    background: var(--surface);
    border-radius: var(--radius-xl);
    min-height: 240px;
    border: 1px solid var(--border);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 1.5rem;
    cursor: pointer;
    box-shadow: var(--shadow-soft);
    transition: transform 0.25s ease, box-shadow 0.3s ease;
}

.opening-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.1);
}

.opening-card__thumb {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    opacity: 0.25;
}

.opening-card__body {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.opening-card__meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    color: var(--muted);
}

.chips span {
    display: inline-flex;
    padding: 0.2rem 0.7rem;
    border-radius: 999px;
    background: var(--badge-bg);
    margin-left: 0.35rem;
}

.opening-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}

.opening-header {
    text-align: center;
    margin-bottom: 0.5rem;
}

.opening-header h1 {
    margin: 0;
    font-size: clamp(1.5rem, 2.5vw, 2rem);
}

.opening-header p {
    margin: 0.2rem 0 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.opening-tabs {
    display: inline-flex;
    gap: 0.5rem;
    align-self: center;
    background: #f2f2f2;
    padding: 0.3rem;
    border-radius: 999px;
    margin-bottom: 1rem;
}

.opening-tab {
    border: none;
    background: transparent;
    padding: 0.45rem 1.6rem;
    border-radius: 999px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    color: #666;
}

.opening-tab.active {
    background: #ffe27a;
    color: #111;
    box-shadow: inset 0 -3px 0 #d0a600;
}

.opening-panels {
    flex: 1;
    min-height: 0;
    position: relative;
}

.opening-panel {
    position: absolute;
    inset: 0;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    display: flex;
    min-height: 0;
}

.opening-panel.active {
    opacity: 1;
    pointer-events: auto;
}

.study-layout {
    display: grid;
    grid-template-columns: minmax(250px, 1fr) minmax(400px, 650px) minmax(300px, 1fr);
    gap: 1rem;
    width: 100%;
    height: 100%;
    min-height: 0;
    align-items: stretch;
}

.training-layout {
    gap: 1rem;
}


.training-sidebar-card {
    height: 100%;
}

.training-study-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    overflow: auto;
    min-height: 0;
    font-family: 'Poppins', sans-serif !important;
}

.mobile-selector {
    display: none;
    width: 100%;
    position: relative;
    margin-bottom: 0.75rem;
}

.smaller-chapter-title-container {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 48px;
}

.mobile-selector-trigger {
    width: 100%;
    justify-content: flex-start;
    border-radius: 999px;
    padding: 0.35rem 0.85rem;
}

.chapters-button {
    display: flex;
    flex-flow: row;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 0.75rem;
}

.mobile-selector .chapter-title-text {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    overflow: hidden;
}

.mobile-selector .chapter-name {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.chapters-arrow {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.white-color {
    color: #fff;
}

.soft-primary-background {
    background: #111;
}

.mobile-selector-dropdown {
    position: absolute;
    top: calc(100% + 0.4rem);
    left: 0;
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-soft);
    border-radius: 16px;
    padding: 0.5rem 0;
    display: none;
    max-height: 260px;
    overflow-y: auto;
    z-index: 25;
}

.mobile-selector.open .mobile-selector-dropdown {
    display: block;
}

.mobile-selector-options {
    list-style: none;
    margin: 0;
    padding: 0;
}

.mobile-selector-option {
    width: 100%;
    border: none;
    background: transparent;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    font-size: 0.95rem;
    cursor: pointer;
    color: var(--text);
}

.mobile-selector-option:hover,
.mobile-selector-option:focus {
    background: #fff6c7;
    outline: none;
}


.training-board {
    width: 100%;
    height: calc(100vh - 270px);
    max-width: calc(100vh - 266px);
    margin: 0 auto;
    position: relative;
    aspect-ratio: 1 / 1;
    touch-action: none;
}

#training-board.chessboard-63f37,
#important-board.chessboard-63f37,
.training-board .chessboard-63f37 {
    touch-action: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    user-select: none;
}

#training-board img,
#important-board img {
    pointer-events: auto;
    -webkit-user-drag: element;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
}

#training-board,
#important-board {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    user-select: none;
}

#training-board *,
#important-board * {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    user-select: none;
}

.training-board-card .chess-board {
    position: relative;
}

#training-board [data-square] {
    position: relative;
}

#training-board .move-option::after,
#important-board .move-option::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    background: #507c65;
    box-shadow: 0 0 6px rgba(80, 124, 101, 0.6);
}

#training-board .selected-square,
#important-board .selected-square {
    box-shadow: inset 0 0 0 3px rgba(240, 206, 21, 0.8) !important;
    background-color: rgba(240, 206, 21, 0.2) !important;
}

.training-status-panel {
    border-radius: 28px;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.moves-card.training-status-panel {
    height: calc(50% - 90px - 1rem);
}

.training-feedback {
    min-height: 110px;
    font-weight: 600;
    border-radius: 12px;
    padding: 0.75rem 1rem;
    background: #f4f6fb;
    color: #555;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.training-feedback.success {
    background: #dff7e7;
    color: #1b8c3f;
}

.training-feedback.error {
    background: #fde8e8;
    color: rgb(194, 47, 47);
}

.training-feedback.info {
    background: #f2f2ee;
    color: #f3b92f;
}

.training-feedback.complete {
    background: #fff7d6;
    color: #b98500;
}

.training-feedback .next-study-btn {
    border-radius: 0px !important;
    padding: 0.65rem 1.8rem;
    border: 1px solid #111;
    background: #eccb4a;
    color: #000;
    cursor: pointer;
    font-size: 0.95rem;
    letter-spacing: 0.08em;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.training-feedback .next-study-btn svg {
    fill: currentColor;
}

.training-history {
    border-radius: 14px;
    font-family: 'Poppins', sans-serif;
    font-size: 0.95rem;
    flex-wrap: wrap;
    gap: 0.35rem;
    align-content: flex-start;
}

.training-history-entry {
    background: transparent;
    border: none;
    padding: 0;
    align-items: flex-start;
}

.training-history-entry .movement-number {
    font-size: 0.75rem;
    font-weight: 600;
    color: #9ca3af;
}

.training-history-entry .movement-notation {
    font-size: 0.95rem;
    font-weight: 600;
}

.training-history-entry .movement-comment-text {
    font-size: 0.8rem;
    color: #6b7280;
    font-style: italic;
}

.training-history-entry.active {
    background: rgba(255, 229, 138, 0.35);
    border-radius: 12px;
    padding: 0.2rem 0.6rem;
}

.training-history .history-placeholder {
    background: transparent;
    color: #9ca3af;
    padding: 0;
}

.training-hint-actions {
    display: flex;
    justify-content: space-between;
    gap: 0.65rem;
    margin-bottom: 0.75rem;
}

.btn-icon {
    width: 60px;
    height: 35px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: #fff;
    color: #111;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: border 0.2s ease, transform 0.2s ease;
    position: relative;
    z-index: 10;
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
}

.btn-icon:hover,
.btn-icon.active {
    border-color: #d0a601;
    transform: translateY(-1px);
}

.btn-icon svg,
.training-review-controls svg {
    fill: currentColor;
}

.btn-icon svg,
.training-review-controls svg {
    fill: currentColor;
}

.training-review-controls {
    display: none;
    justify-content: center;
    gap: 0.85rem;
    margin: 0.75rem 0;
}

.training-controls {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.training-controls .btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: inherit;
}

#training-board .highlight-correct {
    box-shadow: inset 0 0 0 3px rgba(43, 164, 58, 0.8);
}

.highlight-from,
.highlight-to {
    box-shadow: none !important;
}

#training-board .hint-origin,
#important-board .hint-origin {
    box-shadow: none;
}

#training-board .hint-destination,
#important-board .hint-destination {
    box-shadow: inset 0 0 0 3px rgba(43, 164, 58, 0.7);
    position: relative;
}

#training-board .hint-origin::after,
#important-board .hint-origin::after {
    content: '';
    position: absolute;
    inset: 3px;
    border: 4px solid #65a26b;
    border-radius: 50%;
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.35) inset;
    pointer-events: none;
}

#training-board #training-arrow-overlay,
#important-board #important-arrow-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 5;
}

#training-board #training-arrow-overlay .arrow-line,
#important-board #important-arrow-overlay .arrow-line {
    position: absolute;
    height: 6px;
    background: #65a26b;
    border-radius: 4px;
    transform-origin: 0 50%;
}

#training-board #training-arrow-overlay .arrow-line::after,
#important-board #important-arrow-overlay .arrow-line::after {
    content: '';
    position: absolute;
    right: -10px;
    top: 50%;
    transform: translateY(-50%);
    border-left: 16px solid #65a26b;
    border-top: 9px solid transparent;
    border-bottom: 9px solid transparent;
}

#training-board .hint-destination::after {
    content: '';
    position: absolute;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 12px solid rgba(43, 164, 58, 0.8);
    top: 4px;
    left: 50%;
    transform: translateX(-50%);
}

[data-training-panel] button {
    border-radius: 999px;
}

.review-btn {
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  background: #ffe27a;
  cursor: pointer;
  transition: opacity 0.2s ease, transform 0.2s ease;
  border-radius: 0px !important;
}

/* PGN Mode Container */
.pgn-mode-container {
    width: 100%;
    height: calc(50% - 90px - 1rem);
    display: flex;
    flex-flow: column;
    align-items: center;
    justify-content: flex-start;
    padding: 1rem;
    position: relative;
    z-index: 2;
    pointer-events: auto;
}

.next-button-web-pgn-container {
    margin-bottom: 1rem;
    order: 0;
}


.study-pgn-right-column-web {
    width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    pointer-events: auto;
}

.pgn-right-column {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
    flex: 1;
    overflow: hidden;
}

.extra-container {
    display: flex;
    flex-direction: column;
}

.extra-container_bottom {
    gap: 0.5rem;
    order: 3;
    flex-flow: column;
}

.movement-actions-container {
    width: 100%;
    display: flex;
    flex-direction: row;
}

.actions_web {
    flex: 1;
    display: flex;
    flex-direction: row;
    justify-content: center;
    max-width: 100%;
}

.buttons-container {
    display: flex;
    flex-flow: row wrap;
    align-items: center;
    justify-content: space-between;
    order: 2;
    gap: 0.5rem;
}

.moves-buttons-container {
    display: flex;
    flex-flow: row;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.button-container-aux {
    width: 25%;
    min-width: 0;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
}


.movement-list-web-container {
    width: 100%;
    max-height: 250px;
    overflow: hidden;
    flex: 1;
}

.movement-list-web-container_bottom {
    margin-top: 0.5rem;
    order: 2;
}


#next-mov-button,
#prev-mov-button,
#important-next-mov-button,
#important-prev-mov-button {
    color: #f0ce15;
    background-color: #111;
    width: 64px;
    height: 40px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 .125rem;
    transition: opacity 0.2s ease;
}

#next-mov-button:disabled,
#prev-mov-button:disabled,
#important-next-mov-button:disabled,
#important-prev-mov-button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

#next-mov-button svg,
#prev-mov-button svg,
#important-next-mov-button svg,
#important-prev-mov-button svg {
    display: block;
}

#next-button-web-pgn,
#important-next-button-web-pgn {
    background-color: #f0ce15;
    border: none;
    padding: 0.65rem 1.5rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: transform 0.2s ease;
}

#next-button-web-pgn:hover,
#important-next-button-web-pgn:hover {
    transform: translateY(-2px);
}


@media (max-width: 1024px) {
    .training-layout {
        grid-template-columns: 1fr;
        display: flex;
        flex-direction: column;
    }

    .training-sidebar {
        order: 1;
    }

    .training-board-card {
        order: 2;
    }

    .pgn-mode-container {
        order: 3;
        height: auto;
        min-height: auto;
        padding: 1rem;
        width: 100%;
        display: flex;
        flex-direction: column;
        align-items: stretch;
        flex: 0 0 auto;
        gap: 0.75rem;
    }

    .training-status-panel {
        order: 4;
        height: auto;
    }

    .training-board {
        max-width: 420px;
    }

    .movement-list-web-container {
        max-height: none;
    }

    .study-pgn-right-column-web {
        flex: 0 0 auto;
        overflow: visible;
    }

    .movement-scroll {
        max-height: none;
    }

    .next-button-web-pgn-container {
        margin-bottom: 0.5rem;
        width: 100%;
        display: flex;
        justify-content: center;
        align-items: center;
    }

    .pgn-right-column {
        gap: 0.5rem;
        display: flex;
        flex-direction: column;
    }

    .movement-list-web-container_bottom {
        margin-top: 0;
        margin-bottom: 0.5rem;
    }

    #next-button-web-pgn,
    #important-next-button-web-pgn {
        touch-action: manipulation;
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    }

    .buttons-container {
        justify-content: center;
    }

    #next-mov-button,
    #prev-mov-button,
    #important-next-mov-button,
    #important-prev-mov-button {
        width: 56px;
        height: 40px;
        touch-action: manipulation;
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    }

    .btn-icon {
        width: 48px;
        height: 48px;
        touch-action: manipulation;
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
        cursor: pointer;
    }

    .training-hint-actions {
        gap: 0.5rem;
    }
}

.opening-sidebar {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 270px);
    max-height: calc(100vh - 270px);
}

.sidebar-card {
    background: var(--surface);
    border-radius: 30px;
    box-shadow: var(--shadow-soft);
    padding: 0.5rem 0.25rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    flex: 1;
    min-height: 0;
}

.sidebar-card h2 {
    margin: 0;
    font-size: 1.25rem;
}

.chapters-title {
    padding: 1rem 0rem 1rem 1.5rem !important;
    align-items: center;
    border-radius: 1rem;
    font-size: 20px !important;
    font-weight: 500;
    text-align: left;
    color: #fbfaf8 !important;
    background-color: #0f0f0f !important;
    display: flex;
    flex-direction: column;
    place-content: center;
    align-items: flex-start;
    margin: 0 0 1rem 0;
}

.chapters-title .opening-title-line {
    font-weight: 600;
    margin-bottom: 0.35rem;
}

.chapters-title .variant-subtitle {
    font-size: 0.9rem;
    font-weight: 500;
    color: #ffe27a;;
}

.chapter-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    overflow: auto;
    min-height: 0;
    font-family: 'Poppins', sans-serif !important;
}

.chapter-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.55rem 0.85rem;
    border-radius: 18px;
    border: 1px solid var(--border);
    cursor: pointer;
    background: var(--badge-bg);
    font-weight: 500;
}

.chapter-item.active {
    background: #fff6c7;
    border-color: #ffe27a;
}

.chapter-index {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #111;
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
}

.board-card {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    height: 100%;
    width: 100%;
    position: relative;
    z-index: 0;
    overflow: visible;
}

.moves-card {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 270px);
    max-height: calc(100vh - 270px);
    gap: 0.5rem;
}

.moves-panel {
    border-radius: 24px;
    border: 1px solid var(--border);
    background: var(--surface);
    box-shadow: var(--shadow-soft);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    font-family: 'Poppins', sans-serif !important;
}

.variant-card {
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 1rem;
    cursor: pointer;
    transition: border 0.2s ease, background 0.2s ease;
}

.variant-card.active {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.board-toolbar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    justify-content: center;
    padding: 1rem;
    background: var(--surface);
    border-radius: 24px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-soft);
}

.board-toolbar button {
    width: 40px;
    height: 40px;
    border: 1px solid var(--border);
    background: #ffe27a;
    color: var(--text);
    cursor: pointer;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.board-toolbar button:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(255, 226, 122, 0.5);
}

.board-toolbar button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

#move-label {
    min-width: 120px;
    text-align: center;
    font-weight: 600;
}

.chess-board {
    width: 100%;
    height: calc(100vh - 270px);
    max-width: calc(100vh - 266px);
    margin: 0 auto;
    position: relative;
    aspect-ratio: 1 / 1;
    isolation: isolate;
    overflow: visible;
}

/* Badge de símbolo de jugada en casilla */
.square-55d63 {
    position: relative;
}

.move-symbol-badge {
    position: absolute;
    top: 0;
    right: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 900;
    font-size: 18px;
    z-index: 9999;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
    pointer-events: none;
    transform: translate(50%, -50%);
}

.chess-board [class*='chessboard'] {
    border-radius: 18px;
    overflow: visible;
    position: relative;
    z-index: 1;
    box-shadow: 0 20px 35px rgba(13, 21, 32, 0.3);
}

.chess-board .square-55d63 {
    transition: transform 0.2s ease;
}

/* Resaltado de casillas - Casillas claras (white-1e1d7) */
[class*="square"][class*="white"].highlight-from,
[class*="square"][class*="white"].highlight-to {
    background-color: #c3d888 !important;
}

/* Resaltado de casillas - Casillas oscuras (black-3c85d) */
[class*="square"][class*="black"].highlight-from,
[class*="square"][class*="black"].highlight-to {
    background-color: #93b266 !important;
}

.moves-panel {
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 1rem;
    background: var(--surface);
    display: flex;
    flex-direction: column;
    height: 100%;
}

.movement-scroll {
    flex: 1;
    overflow: auto;
    padding-right: 0.5rem;
    max-height: 100%;
}

.movement-list {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}


.movement-list-inline {
    line-height: 1.8;
    font-size: 1rem;
}

.movement-comment {
    font-style: italic;
    color: var(--muted);
    font-size: 0.9rem;
}

.main-line {
    margin-bottom: 1rem;
}

.variation-line {
    margin-left: 1.5rem;
    margin-bottom: 0.5rem;
    background: #f9f9fb;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    border-left: 3px solid var(--border);
    font-style: italic;
}

.movement-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.movement {
    border: none;
    border-radius: 16px;
    background: var(--badge-bg);
    color: var(--text);
    padding: 0.6rem 0.85rem;
    text-align: left;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.95rem;
    transition: transform 0.15s ease, box-shadow 0.2s ease;
}

.movement-inline {
    border: none;
    background: transparent;
    color: var(--text);
    padding: 0.1rem 0.2rem;
    cursor: pointer;
    display: inline;
    font-size: 1rem;
    font-weight: 400;
    transition: background 0.15s ease;
    border-radius: 4px;
}

.movement-inline:hover {
    background: rgba(47, 98, 243, 0.1);
}

.movement-inline.active {
    background: #ffe27a;
    font-weight: 700;
}

.movement.transparent-button {
    background: var(--badge-bg);
}

.movement.main-movement {
    background: var(--accent-soft);
    font-weight: 600;
    font-size: 1.2rem;
}

.movement-inline.main-movement {
    font-size: 1.2rem;
    font-weight: 600;
    font-family: 'Poppins', sans-serif !important;
}

.movement.variant-movement {
    background: #f5f5f9;
    font-size: 0.9rem;
}

.movement-inline.variant-movement {
    font-size: 1.1rem;
    font-weight: 400;
}

.movement.active {
    box-shadow: 0 8px 20px rgba(47, 98, 243, 0.2);
    background: #dae1ff;
}

.movement-number {
    font-weight: 700;
    color: #000;
    margin-right: 0;
}

.movement-notation {
    display: inline;
    align-items: center;
    gap: 0.25rem;
}

.move-comment-text {
    font-style: italic;
    color: var(--muted);
}

.movement-comment2 {
    font-style: italic;
    color: #0f0f0f;
    font-size: 1.1rem;
}

#training-move-comment,
#important-move-comment {
    color: #0f0f0f;
    font-style: normal;
    font-size: 1.1rem;
}

.movement-comment-inline {
    background: #fefefe;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    color: #333;
    font-size: 0.95rem;
    margin: 0.5rem 0;
    line-height: 1.6;
    border-left: 3px solid #e0e0e0;
}

.variant-comment {
    background: #f9f9fb;
    margin-left: 0;
}

.movement-variations {
    border-left: 2px solid var(--border);
    margin-left: 0.9rem;
    padding-left: 0.9rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.placeholder-panel {
    margin: auto;
    max-width: 420px;
    text-align: center;
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    padding: 2rem;
    box-shadow: var(--shadow-soft);
}

/* Ajustes de altura para que tablero y jugadas ocupen todo el espacio disponible */
html,
body {
    height: 100%;
}

#app-root,
.app-shell,
main {
    height: 100%;
}

main {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.opening-view,
.opening-main,
.opening-panels,
.opening-panel,
.study-layout {
    height: 100%;
    min-height: 0;
}

.opening-sidebar,
.sidebar-card,
.chapter-list,
.board-card,
.moves-panel {
    min-height: 0;
}

.error,
.empty,
.loading {
    color: var(--muted);
    padding: 1rem;
    text-align: center;
}

/* Media query para tablets y móviles */
@media (max-width: 768px) {
    html, body {
        height: auto;
        overflow: auto;
    }

    main {
        padding: 0.5rem;
        height: auto;
        min-height: unset;
        overflow: visible;
    }

    .opening-container {
        height: auto;
        min-height: unset;
    }

    .opening-header {
        margin-bottom: 0.75rem;
    }

    .opening-header h1 {
        font-size: 1.3rem;
    }

    .opening-header p {
        font-size: 0.85rem;
    }

    .opening-tabs {
        gap: 0.3rem;
        padding: 0.25rem;
        margin-bottom: 1rem;
    }

    .opening-tab {
        padding: 0.4rem 1rem;
        font-size: 0.85rem;
    }

    .opening-panels {
        position: static;
        height: auto;
        min-height: unset;
    }

    .opening-panel {
        position: static;
        opacity: 1;
        pointer-events: auto;
        height: auto;
        min-height: unset;
    }

    .opening-panel:not(.active) {
        display: none;
    }

    /* Layout vertical en móvil */
    .study-layout {
        display: flex;
        flex-direction: column;
        gap: 1rem;
        height: auto;
        min-height: unset;
    }

    /* Sidebar se convierte en select dropdown */
    .opening-sidebar {
        height: auto;
        max-height: none;
        order: 1;
    }

    .sidebar-card {
        padding: 0;
        background: transparent;
        box-shadow: none;
        border-radius: 0;
    }

    .sidebar-card h2 {
        display: none;
    }

    .chapter-list {
        display: none; /* Ocultamos la lista, se mostrará como select */
    }

    .mobile-selector {
        display: block !important;
    }

    .training-sidebar-card h3 {
        display: none;
    }

    /* Tablero en móvil */
    .board-card {
        order: 2;
        height: auto;
    }

    .chess-board {
        width: 100%;
        max-width: 100vw;
        max-height: 90vw;
        aspect-ratio: 1 / 1;
    }

    /* Panel de jugadas en móvil */
    .moves-card {
        order: 3;
        height: auto;
        max-height: none;
        gap: 1rem;
    }

    .moves-panel {
        max-height: 210px;
        overflow-y: auto;
    }

    /* Botones de navegación al final */
    .board-toolbar {
        order: 4;
        position: static;
        z-index: 10;
        margin-top: 1rem;
        margin-bottom: 2rem;
        padding: 1rem;
        background: var(--surface);
        box-shadow: var(--shadow-soft);
    }

    .board-toolbar button {
        width: 48px;
        height: 48px;
    }

    #move-label {
        font-size: 1rem;
    }

    /* Badges más pequeños en móvil */
    .move-symbol-badge {
        width: 24px;
        height: 24px;
        font-size: 13px;
    }

    /* Círculos de movimientos posibles más pequeños en móvil */
    #training-board .move-option::after,
    #important-board .move-option::after {
        width: 14px;
        height: 14px;
    }
}

@media (max-width: 480px) {
    /* Círculos aún más pequeños en pantallas muy pequeñas */
    #training-board .move-option::after,
    #important-board .move-option::after {
        width: 12px;
        height: 12px;
    }
}

@media (max-width: 1100px) and (min-width: 769px) {
    main {
        padding: 1rem;
    }
    .study-layout {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    .opening-sidebar {
        order: 1;
        height: auto;
        max-height: none;
    }
    .board-card {
        order: 2;
    }
    .moves-card {
        order: 3;
        height: auto;
        max-height: 400px;
    }
    .chess-board {
        height: auto;
        max-width: 600px;
        max-height: 600px;
    }
}

/* Modal de selección de jugadas */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--surface);
    border-radius: 16px;
    padding: 0;
    max-width: 280px;
    width: auto;
    min-width: 200px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
    overflow: hidden;
}

.modal-content.modal-content--top {
    margin-top: -6rem;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
}

.close-modal-button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s ease;
}

.close-modal-button:hover {
    background: rgba(0, 0, 0, 0.05);
}

.close-modal-button svg {
    fill: var(--text);
    width: 20px;
    height: 20px;
}

.move-choices-list {
    display: flex;
    flex-direction: column;
    padding: 0.75rem;
    gap: 0.5rem;
    font-family: 'Poppins', sans-serif !important;
}

.move-choice-button {
    padding: 0.5rem 1rem;
    border: 1px solid #ffe27a;
    border-radius: 12px;
    background: #f7d253 ;
    color: var(--text);
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.move-choice-button:hover {
    background: #ffe27a;
    box-shadow: inset 0 -3px 0 #d0a600;
}

@media (max-width: 720px) {
    :root {
        --square-size: 48px;
    }

    .app-header {
        padding: 1rem;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .app-header__brand {
        flex-direction: column;
        gap: 0.2rem;
        align-items: flex-start;
    }

    .logo {
        font-size: 1.1rem;
    }

    .tagline {
        font-size: 0.8rem;
    }

    .app-header__actions {
        width: 100%;
        justify-content: center;
    }

    .badge {
        font-size: 0.8rem;
        padding: 0.3rem 0.8rem;
    }

    .opening-tabs {
        flex-wrap: wrap;
        justify-content: center;
    }

    .chapter-item {
        padding: 0.5rem 0.65rem;
    }

    /* Ajustes adicionales para el modal en móvil */
    .modal-content {
        max-width: 90vw;
        margin: 0 1rem;
    }

    .move-choice-button {
        font-size: 1.1rem;
    }
}
.move-choice-button.active {
    background: #ffe27a;
    box-shadow: inset 0 -3px 0 #d0a600;
}
.mat-mdc-icon-button .mat-focus-indicator,
.mdc-icon-button .mat-focus-indicator {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: inherit;
}

.mat-mdc-button .mdc-button__label {
    position: relative;
    z-index: 1;
}
