#hanziconnect {
    --hanziconnect-blue: var(--hd-primary, #2e4a43);
    --hanziconnect-blue-dark: var(--hd-primary-hover, #1f342f);
    --hanziconnect-blue-light: var(--hd-primary-soft, #e7eeea);
    --hanziconnect-ink: var(--hd-text, #222a2d);
    --hanziconnect-muted: var(--hd-muted, #5d686c);
    display: inline-block;
    width: 100%;
}

#hanziconnect .output_block_p {
    min-height: 620px;
    position: relative;
}

#hanziconnect #result_block.hanziconnect_welcome {
    background-image: url('/modules/chinesekids/views/img/chinesetools/hanziconnect/welcome.jpg');
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
    margin-bottom: 0;
    min-height: 620px;
    overflow: hidden;
    position: relative;
}

#hanziconnect #result_block.hanziconnect_welcome .chinesetools-title {
    position: relative;
    z-index: 1;
}

#hanziconnect .chinesetools-title h1 {
    text-shadow: 0 5px 11px rgba(31, 52, 47, .28);
}

#hanziconnect .list_sett li {
    align-items: center;
    display: flex;
    justify-content: space-between;
}

#hanziconnect .list_sett li.hanziconnect_input,
#hanziconnect .list_sett li.hanziconnect_level_settings,
#hanziconnect .list_sett li.hanziconnect_template_settings {
    display: block;
}

#hanziconnect .hanziconnect_input_header {
    align-items: center;
    display: flex;
    justify-content: space-between;
    min-height: 24px;
}

#hanziconnect .hanziconnect_input textarea {
    display: block;
    margin: 6px 0 0;
    min-height: 108px;
    resize: vertical;
}

#hanziconnect .hanziconnect_edit_button {
    font-size: 12px;
    margin-top: 7px;
    width: 100%;
    border-radius: 10px;
}

#hanziconnect .hanziconnect_input_footer {
    align-items: flex-start;
    display: flex;
    justify-content: space-between;
    min-height: 25px;
    padding: 7px 5px 0;
}

#hanziconnect .hanziconnect_input_footer .chinesetools_error {
    display: block;
    padding: 0 8px 0 0;
}

#hanziconnect .hanziconnect_word_count {
    color: #777;
    flex: 0 0 auto;
    font-size: 12px;
    margin-left: auto;
}

#hanziconnect .hanziconnect_input_hint {
    color: var(--hd-muted, #5d686c);
    font-size: 11px;
    line-height: 1.4;
    padding: 2px 5px 7px;
}

#hanziconnect .list_sett .setting_first,
#hanziconnect .list_sett li .setting_checkbox {
    align-items: center;
    display: flex;
    justify-content: space-between;
    width: 100%;
}

#hanziconnect .list_sett li .setting_checkbox .checker {
    float: none;
    margin: 0;
    top: 0;
}

#hanziconnect .card-body .value_sett .ss-main,
#hanziconnect .card-body .value_sett select {
    width: 100%;
}

#hanziconnect .hanziconnect_chain_setting .value_sett {
    flex: 0 0 148px;
    width: 148px;
}

#hanziconnect .hanziconnect_chain_setting .ss-main,
#hanziconnect .hanziconnect_chain_setting select,
#hanziconnect .hanziconnect_chain_setting .ss-single-selected,
#hanziconnect .hanziconnect_chain_setting .ss-option {
    white-space: nowrap;
}

#hanziconnect .hanziconnect_levels {
    width: 100%;
}

#hanziconnect .hanziconnect_levels .setting_title_all {
    align-items: center;
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
}

#hanziconnect .hanziconnect_levels .checker_all {
    align-items: center;
    display: flex;
    font-size: 12px;
}

#hanziconnect .hanziconnect_levels .chinesetools-list_inputs {
    align-items: center;
    display: flex;
    flex-wrap: nowrap;
    justify-content: space-between;
}

#hanziconnect .hanziconnect_levels .chinesetools-list_item {
    align-items: center;
    display: flex;
    flex: 0 1 auto;
    flex-direction: column;
    justify-content: space-between;
    min-width: 0;
}

#hanziconnect .hanziconnect_selection_summary {
    background: var(--hd-surface-muted, #eff2ef);
    border-left: 3px solid var(--hanziconnect-blue);
    color: var(--hd-muted, #5d686c);
    font-size: 12px;
    line-height: 1.45;
    margin-bottom: 8px;
    padding: 8px 9px;
}

#hanziconnect .hanziconnect_template_settings .setting_checkbox + .setting_checkbox {
    margin-top: 9px;
}

#hanziconnect .hanziconnect_invalid textarea,
#hanziconnect .hanziconnect_invalid .ss-main,
#hanziconnect .hanziconnect_invalid .hanziconnect_levels,
#hanziconnect .hanziconnect_invalid .btn,
#hanziconnect .hanziconnect_edit_button.hanziconnect_invalid {
    border-color: #b73535 !important;
    box-shadow: 0 0 0 2px rgba(217, 83, 79, 0.12);
}

#hanziconnect .hanziconnect_controls .btnBlock > a,
#hanziconnect .hanziconnect_controls .btnBlock > .btn_no_pro {
    width: 49%;
}

#hanziconnect .hanziconnect_controls .btn_no_pro .btn {
    width: 100%;
}

#hanziconnect .hanziconnect_sample_pdf {
    color: var(--hanziconnect-blue-dark);
    display: block;
    font-size: 13px;
    margin-top: 7px;
    text-align: center;
    text-decoration: underline;
}

.hanziconnect_modal {
    background: #fff;
    border-radius: 7px;
    max-width: 760px;
    padding: 22px;
    width: 92vw;
}

.hanziconnect_modal h3 {
    color: var(--hd-text, #222a2d);
    font-size: 24px;
    margin: 0 0 16px;
}

.hanziconnect_modal_status {
    color: var(--hd-muted, #5d686c);
    min-height: 22px;
}

.hanziconnect_modal_actions {
    display: flex;
    gap: 9px;
    justify-content: flex-end;
    margin-top: 18px;
}

.hanziconnect_editor_items {
    max-height: 58vh;
    overflow-y: auto;
    padding-right: 5px;
}

.hanziconnect_editor_item {
    align-items: center;
    border-bottom: 1px solid var(--hd-border, #d7ddda);
    display: grid;
    gap: 16px;
    grid-template-columns: 112px minmax(0, 1fr);
    padding: 12px 2px;
}

.hanziconnect_editor_hanzi {
    color: var(--hd-text, #222a2d);
    font-size: 34px;
    line-height: 1.15;
    text-align: center;
}

.hanziconnect_editor_fields {
    display: grid;
    gap: 10px;
    grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
}

.hanziconnect_editor_fields label {
    color: var(--hd-muted, #5d686c);
    display: block;
    font-size: 12px;
    font-weight: 400;
}

.hanziconnect_editor_fields input,
.hanziconnect_editor_fields textarea {
    border: 1px solid var(--hd-border, #d7ddda);
    border-radius: 3px;
    color: var(--hd-text, #222a2d);
    display: block;
    margin-top: 4px;
    padding: 7px 8px;
    resize: vertical;
    width: 100%;
}

.hanziconnect_editor_item_invalid {
    background: var(--hd-error-surface, #fdeded);
}

.hanziconnect_editor_item_invalid input {
    border-color: #b73535;
}

#onlinegame_hanziconnect,
#hanziconnect_result {
    align-items: center;
    background:
        radial-gradient(circle at 16% 12%, rgba(255, 255, 255, 0.98), transparent 30%),
        linear-gradient(145deg, var(--hd-canvas, #f6f7f3) 0%, var(--hd-primary-soft, #e7eeea) 53%, var(--hd-accent-soft, #fff3c4) 100%);
    display: flex;
    flex-direction: column;
    min-height: 620px;
    overflow: hidden;
    padding: 20px;
    position: relative;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

#onlinegame_hanziconnect::before,
#hanziconnect_result::before {
    background-image:
        linear-gradient(45deg, transparent 49.5%, rgba(46, 74, 67, 0.045) 50%, transparent 50.5%),
        linear-gradient(-45deg, transparent 49.5%, rgba(46, 74, 67, 0.045) 50%, transparent 50.5%);
    background-size: 76px 76px;
    content: "";
    inset: 0;
    pointer-events: none;
    position: absolute;
}

#onlinegame_hanziconnect > *,
#hanziconnect_result > * {
    position: relative;
    z-index: 1;
}

#onlinegame_hanziconnect .hanziconnect_game_title {
    color: var(--hanziconnect-blue-dark);
    font-size: 27px;
    font-weight: 700;
    margin: 0 0 11px;
    text-align: center;
}

#onlinegame_hanziconnect .hanziconnect_game_status {
    align-items: center;
    background: rgba(255, 255, 255, 0.86);
    border: 1px solid rgba(46, 74, 67, 0.18);
    border-radius: 7px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px 28px;
    justify-content: center;
    margin-bottom: 13px;
    max-width: 760px;
    padding: 8px 16px;
    width: 100%;
}

#onlinegame_hanziconnect .hanziconnect_status_item {
    color: var(--hd-muted, #5d686c);
    font-size: 13px;
    white-space: nowrap;
}

#onlinegame_hanziconnect .hanziconnect_status_item strong {
    color: var(--hanziconnect-blue-dark);
}

#onlinegame_hanziconnect .hanziconnect_board {
    height: 420px;
    margin: 0 auto;
    max-width: 780px;
    position: relative;
    width: 100%;
}

#onlinegame_hanziconnect .hanziconnect_lines {
    inset: 0;
    overflow: visible;
    pointer-events: none;
    position: absolute;
    z-index: 2;
}

#onlinegame_hanziconnect .hanziconnect_columns {
    display: grid;
    height: 100%;
    position: relative;
    width: 100%;
    z-index: 3;
}

#onlinegame_hanziconnect .hanziconnect_columns_2 {
    column-gap: 25%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

#onlinegame_hanziconnect .hanziconnect_columns_3 {
    column-gap: 8%;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

#onlinegame_hanziconnect .hanziconnect_column {
    display: grid;
    gap: 8px;
    grid-template-rows: repeat(5, minmax(0, 1fr));
    min-width: 0;
}

#onlinegame_hanziconnect .hanziconnect_node_wrap {
    min-height: 0;
    position: relative;
}

#onlinegame_hanziconnect .hanziconnect_node_wrap .hanziconnect_node {
    box-sizing: border-box;
    height: 100%;
}

#onlinegame_hanziconnect .hanziconnect_audio {
    align-items: center;
    background: var(--hanziconnect-blue-light);
    border: 0;
    border-radius: 50%;
    color: var(--hanziconnect-blue-dark);
    cursor: pointer;
    display: flex;
    font-size: 13px;
    height: 26px;
    justify-content: center;
    left: 6px;
    padding: 0;
    position: absolute;
    top: 6px;
    width: 26px;
    z-index: 5;
}

#onlinegame_hanziconnect .hanziconnect_audio:hover,
#onlinegame_hanziconnect .hanziconnect_audio:focus {
    background: var(--hanziconnect-blue);
    color: #fff;
    outline: 2px solid var(--hd-focus, #275ea8);
    outline-offset: 2px;
}

#onlinegame_hanziconnect .hanziconnect_audio_playing {
    background: var(--hanziconnect-blue);
    color: #fff;
}

#onlinegame_hanziconnect .hanziconnect_audio_playing::after {
    border: 2px solid var(--hanziconnect-blue);
    border-radius: 50%;
    content: "";
    inset: -4px;
    position: absolute;
    animation: hanziconnect-audio-pulse 1.2s ease-out infinite;
}

#onlinegame_hanziconnect .hanziconnect_audio_loading i {
    animation: hanziconnect-audio-loading 800ms ease-in-out infinite alternate;
}

#onlinegame_hanziconnect .hanziconnect_audio_primary {
    font-size: 24px;
    height: 46px;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 46px;
}

#onlinegame_hanziconnect .hanziconnect_node_wrap_audio .hanziconnect_node {
    background: var(--hd-primary-soft, #e7eeea);
}

@keyframes hanziconnect-audio-pulse {
    from { opacity: 0.8; transform: scale(0.8); }
    to { opacity: 0; transform: scale(1.5); }
}

@keyframes hanziconnect-audio-loading {
    from { opacity: 0.4; }
    to { opacity: 1; }
}

#onlinegame_hanziconnect .hanziconnect_node {
    align-items: center;
    appearance: none;
    background: rgba(255, 255, 255, 0.95);
    border: 2px solid rgba(46, 74, 67, 0.23);
    border-radius: 9px;
    box-shadow: 0 5px 13px rgba(31, 52, 47, 0.08);
    color: var(--hanziconnect-ink);
    cursor: crosshair;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 0;
    padding: 4px 8px;
    position: relative;
    touch-action: none;
    transition:
        background-color 170ms ease,
        border-color 170ms ease,
        box-shadow 170ms ease,
        transform 170ms ease;
    width: 100%;
}

#onlinegame_hanziconnect .hanziconnect_node::before,
#onlinegame_hanziconnect .hanziconnect_node::after {
    background: #fff;
    border: 2px solid var(--hanziconnect-blue);
    border-radius: 50%;
    content: "";
    height: 10px;
    position: absolute;
    top: calc(50% - 5px);
    width: 10px;
    z-index: 4;
}

#onlinegame_hanziconnect .hanziconnect_node::before {
    left: -7px;
}

#onlinegame_hanziconnect .hanziconnect_node::after {
    right: -7px;
}

#onlinegame_hanziconnect .hanziconnect_column:first-child .hanziconnect_node::before,
#onlinegame_hanziconnect .hanziconnect_column:last-child .hanziconnect_node::after {
    display: none;
}

#onlinegame_hanziconnect .hanziconnect_node:hover,
#onlinegame_hanziconnect .hanziconnect_node:focus,
#onlinegame_hanziconnect .hanziconnect_node_selected {
    border-color: var(--hanziconnect-blue);
    box-shadow: 0 0 0 3px rgba(46, 74, 67, 0.13);
    outline: none;
    transform: translateY(-1px);
}

#onlinegame_hanziconnect .hanziconnect_node_selected::after {
    animation: hanziconnect-active-point 900ms ease-in-out infinite;
    background: var(--hanziconnect-blue);
    box-shadow: 0 0 0 4px rgba(46, 74, 67, 0.18);
}

#onlinegame_hanziconnect .hanziconnect_node_connected {
    background: var(--hd-success-surface, #eaf5ed);
    border-color: var(--hd-success, #286747);
}

#onlinegame_hanziconnect .hanziconnect_node_text {
    display: block;
    line-height: 1.1;
    overflow-wrap: anywhere;
    text-align: center;
}

#onlinegame_hanziconnect .hanziconnect_node_hanzi .hanziconnect_node_text {
    font-size: clamp(25px, 3.2vw, 34px);
    font-weight: 400;
}

#onlinegame_hanziconnect .hanziconnect_node_pinyin .hanziconnect_node_text {
    color: var(--hanziconnect-blue-dark);
    font-size: clamp(15px, 2vw, 20px);
}

#onlinegame_hanziconnect .hanziconnect_node_translation {
    color: var(--hanziconnect-muted);
    display: -webkit-box;
    font-size: 10px;
    line-height: 1.15;
    margin-top: 2px;
    overflow: hidden;
    overflow-wrap: anywhere;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

#onlinegame_hanziconnect .hanziconnect_line {
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 4;
    transition: stroke-dashoffset 560ms cubic-bezier(0.24, 0.72, 0.24, 1);
}

#onlinegame_hanziconnect .hanziconnect_line_correct {
    filter: drop-shadow(0 2px 2px rgba(40, 103, 71, 0.2));
    stroke: var(--hd-success, #286747);
}

#onlinegame_hanziconnect .hanziconnect_line_wrong {
    animation: hanziconnect-line-error 620ms ease forwards;
    stroke: #b73535;
}

#onlinegame_hanziconnect .hanziconnect_line_preview {
    stroke: rgba(46, 74, 67, 0.55);
    stroke-dasharray: 6 6;
    stroke-width: 3;
}

#onlinegame_hanziconnect .hanziconnect_node_wrong {
    animation: hanziconnect-shake 380ms ease;
    border-color: #b73535;
}

#onlinegame_hanziconnect .hanziconnect_board_locked {
    pointer-events: none;
}

#onlinegame_hanziconnect .hanziconnect_game_actions {
    align-items: center;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
}

#onlinegame_hanziconnect .hanziconnect_game_settings,
#hanziconnect_result .hanziconnect_game_settings {
    color: var(--hanziconnect-blue-dark);
    display: none;
    font-size: 13px;
}

#hanziconnect_result {
    justify-content: center;
}

#hanziconnect_result h1 {
    color: var(--hanziconnect-blue-dark);
    font-size: 42px;
    font-weight: 700;
    margin: 0 0 18px;
    text-align: center;
}

#hanziconnect_result .hanziconnect_result_summary {
    background: rgba(255, 255, 255, 0.84);
    border: 1px solid rgba(46, 74, 67, 0.2);
    border-radius: 7px;
    margin-bottom: 20px;
    max-width: 680px;
    padding: 16px 22px;
    text-align: center;
    width: 100%;
}

#hanziconnect_result .hanziconnect_result_label {
    color: var(--hd-muted, #5d686c);
    font-size: 13px;
    margin-bottom: 5px;
}

#hanziconnect_result .hanziconnect_result_words {
    color: var(--hanziconnect-blue-dark);
    display: flex;
    flex-wrap: wrap;
    font-size: 30px;
    gap: 5px 15px;
    justify-content: center;
    line-height: 1.35;
}

#hanziconnect_result .hanziconnect_result_stats {
    border-top: 1px solid rgba(46, 74, 67, 0.13);
    color: var(--hd-muted, #5d686c);
    display: flex;
    gap: 22px;
    justify-content: center;
    margin-top: 11px;
    padding-top: 10px;
}

#hanziconnect_result .hanziconnect_result_stats strong {
    color: var(--hanziconnect-blue-dark);
}

#hanziconnect_result .chinesetools-screen_buttons {
    align-items: center;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

@keyframes hanziconnect-shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    50% { transform: translateX(5px); }
    75% { transform: translateX(-3px); }
}

@keyframes hanziconnect-line-error {
    0%, 65% { opacity: 1; }
    100% { opacity: 0; }
}

@keyframes hanziconnect-active-point {
    0%, 100% { box-shadow: 0 0 0 2px rgba(46, 74, 67, 0.15); }
    50% { box-shadow: 0 0 0 6px rgba(46, 74, 67, 0.24); }
}

@media (max-width: 769px) {
    #hanziconnect .output_block_p {
        min-height: auto;
        padding: 0;
    }

    #hanziconnect #result_block.hanziconnect_welcome {
        min-height: 520px;
    }

    #onlinegame_hanziconnect,
    #hanziconnect_result {
        min-height: 590px;
        padding: 16px 7px;
    }

    #onlinegame_hanziconnect .hanziconnect_game_title {
        font-size: 23px;
        margin-bottom: 8px;
    }

    #onlinegame_hanziconnect .hanziconnect_game_status {
        gap: 5px 14px;
        margin-bottom: 10px;
        padding: 7px 6px;
    }

    #onlinegame_hanziconnect .hanziconnect_status_item {
        font-size: 11px;
    }

    #onlinegame_hanziconnect .hanziconnect_board {
        height: 420px;
    }

    #onlinegame_hanziconnect .hanziconnect_columns_2 {
        column-gap: 17%;
    }

    #onlinegame_hanziconnect .hanziconnect_columns_3 {
        column-gap: 5%;
    }

    #onlinegame_hanziconnect .hanziconnect_column {
        gap: 6px;
    }

    #onlinegame_hanziconnect .hanziconnect_node {
        border-radius: 7px;
        padding: 3px 3px;
    }

    #onlinegame_hanziconnect .hanziconnect_node_hanzi .hanziconnect_node_text {
        font-size: clamp(20px, 7vw, 29px);
    }

    #onlinegame_hanziconnect .hanziconnect_node_pinyin .hanziconnect_node_text {
        font-size: clamp(11px, 3.8vw, 16px);
    }

    #onlinegame_hanziconnect .hanziconnect_node_translation {
        font-size: 8px;
    }

    #onlinegame_hanziconnect .hanziconnect_line {
        stroke-width: 3;
    }

    #onlinegame_hanziconnect .hanziconnect_game_settings,
    #hanziconnect_result .hanziconnect_game_settings {
        display: inline-block;
    }

    .hanziconnect_editor_item {
        gap: 8px;
        grid-template-columns: 76px minmax(0, 1fr);
    }

    .hanziconnect_editor_hanzi {
        font-size: 27px;
    }

    .hanziconnect_editor_fields {
        grid-template-columns: 1fr;
    }
}

@media (prefers-reduced-motion: reduce) {
    #onlinegame_hanziconnect .hanziconnect_node,
    #onlinegame_hanziconnect .hanziconnect_line,
    #onlinegame_hanziconnect .hanziconnect_audio::after,
    #onlinegame_hanziconnect .hanziconnect_audio i {
        animation-duration: 0.01ms;
        transition-duration: 0.01ms;
    }
}
