#memo {
    --memo-blue-dark: var(--hd-primary-hover, #1f342f);
    --memo-blue: var(--hd-primary, #2e4a43);
    --memo-blue-light: var(--hd-primary-soft, #e7eeea);
    --memo-ink: var(--hd-text, #222a2d);
    --memo-card-back-color: var(--memo-blue);
    --memo-card-back-image:
        url("/modules/chinesekids/base_svg/ico_logo.svg"),
        url("/modules/chinesekids/views/img/chinesetools/memo/memo-card-back-bg.webp");
    --memo-card-back-position: center, center;
    --memo-card-back-repeat: no-repeat, no-repeat;
    --memo-card-back-size: auto 45.6%, cover;
    display: inline-block;
    width: 100%;
}

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

#memo #result_block {
    margin-bottom: 25px;
    position: relative;
}

#memo #result_preview {
    background-color: var(--hd-surface-muted, #eff2ef);
    background-image:
        url("/modules/chinesekids/views/img/chinesetools/memo/memo-hero-desktop.webp");
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
    min-height: 560px;
    overflow: hidden;
    position: relative;
}

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

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

#memo .list_sett li.memo_input,
#memo .list_sett li.memo_level_settings,
#memo .list_sett li.memo_selection_summary {
    display: block;
}

#memo .memo_input {
    padding: 0;
}

#memo .memo_input textarea {
    display: block;
    margin: 0;
    min-height: 82px;
    resize: vertical;
}

#memo .memo_input_footer {
    align-items: flex-start;
    display: flex;
    justify-content: space-between;
    min-height: 26px;
    padding: 7px 5px 0;
}

#memo .memo_input_footer .chinesetools_error {
    display: block;
    padding: 0 8px 0 0;
}

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

#memo .memo_warning {
    color: #b76e00;
    font-size: 12px;
    line-height: 1.35;
    min-height: 16px;
    padding: 1px 5px 6px;
}

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

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

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

#memo .list_sett li .setting_checkbox input {
    float: none;
    margin: 0;
}

#memo .card-body .value_sett .ss-main,
#memo .card-body .value_sett select,
#memo .card-body .value_sett input[type="number"] {
    width: 100%;
}

#memo .card-body .value_sett input[type="number"] {
    border: 1px solid var(--hd-control-border, #7d8983);
    min-height: 34px;
    padding: 5px 8px;
}

#memo .memo_levels {
    width: 100%;
}

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

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

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

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

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

#memo .memo_selection_summary span {
    display: block;
}

#memo .memo_controls .btnBlock > a,
#memo .memo_controls .btnBlock > .btn_no_pro {
    width: 49%;
}

#memo .memo_controls .btn_no_pro .btn {
    width: 100%;
}

#memo #MemoPlay_error {
    display: block;
    padding-top: 8px;
}

.memo_card {
    -webkit-appearance: none;
    appearance: none;
    aspect-ratio: 4 / 5;
    background: transparent;
    border: 0;
    cursor: pointer;
    display: block;
    min-width: 0;
    padding: 0;
    perspective: 900px;
    position: relative;
    width: 100%;
}

.memo_card_inner {
    display: block;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 430ms cubic-bezier(0.2, 0.72, 0.25, 1);
    width: 100%;
}

.memo_card_flipped .memo_card_inner,
.memo_card_matched .memo_card_inner {
    transform: rotateY(180deg);
}

.memo_card_back,
.memo_card_front {
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    border: 1px solid rgba(46, 74, 67, 0.22);
    border-radius: 10px;
    box-shadow: 0 7px 18px rgba(32, 47, 61, 0.17);
    height: 100%;
    inset: 0;
    overflow: hidden;
    position: absolute;
    width: 100%;
}

.memo_card_back {
    align-items: center;
    background-color: var(--memo-card-back-color);
    background-image: var(--memo-card-back-image);
    background-position: var(--memo-card-back-position);
    background-repeat: var(--memo-card-back-repeat);
    background-size: var(--memo-card-back-size);
    display: flex;
    justify-content: center;
}

.memo_card_front {
    align-items: center;
    background:
        radial-gradient(circle at 50% 38%, #fff 0%, #fff 48%, var(--hd-surface-muted, #eff2ef) 100%);
    color: var(--memo-ink);
    display: flex;
    justify-content: center;
    padding: 8%;
    transform: rotateY(180deg);
}

.memo_card_front_hanzi {
    flex-direction: column;
}

.memo_card_hanzi_value {
    display: block;
    color: var(--memo-blue-dark);
    font-size: clamp(42px, 7.8vw, 94px);
    line-height: 1;
    text-align: center;
}

.memo_card_hanzi_pinyin {
    color: rgba(83, 100, 116, 0.62);
    display: block;
    font-family: "Noto Sans", sans-serif !important;
    font-size: clamp(11px, 1.15vw, 15px);
    font-weight: 500;
    line-height: 1.2;
    margin-bottom: 0.22em;
    text-align: center;
}

.memo_card_front_pinyin {
    color: var(--memo-blue-dark);
    font-size: clamp(18px, 2.1vw, 30px);
    font-weight: 700;
    line-height: 1.2;
    overflow-wrap: anywhere;
    text-align: center;
}

.memo_card:focus {
    outline: 0;
}

.memo_card:focus-visible .memo_card_back,
.memo_card:focus-visible .memo_card_front {
    box-shadow:
        0 0 0 3px #fff,
        0 0 0 6px var(--hd-focus, #275ea8),
        0 7px 18px rgba(32, 47, 61, 0.17);
}

.memo_card_matched {
    animation: memo-match 480ms ease;
    cursor: default;
}

.memo_card_mismatch {
    animation: memo-mismatch 240ms ease;
}

@keyframes memo-match {
    0%,
    100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.045);
    }
}

@keyframes memo-mismatch {
    0%,
    100% {
        transform: translateX(0);
    }
    35% {
        transform: translateX(-3px);
    }
    70% {
        transform: translateX(3px);
    }
}

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

#onlinegame_memo > *,
#memo_result > * {
    position: relative;
    z-index: 1;
}

#onlinegame_memo .memo_game_title {
    color: var(--memo-blue-dark);
    font-size: 27px;
    font-weight: 700;
    margin: 0 0 14px;
    text-align: center;
}

#onlinegame_memo .memo_music_toggle {
    align-items: center;
    background: rgba(255, 255, 255, 0.88);
    border: 1px solid rgba(46, 74, 67, 0.22);
    border-radius: 50%;
    color: var(--memo-blue-dark);
    cursor: pointer;
    display: flex;
    font-size: 17px;
    height: 34px;
    justify-content: center;
    padding: 0;
    position: absolute;
    right: 16px;
    top: 16px;
    transition: background-color 160ms ease, color 160ms ease;
    width: 34px;
    z-index: 3;
}

#onlinegame_memo .memo_music_toggle:hover,
#onlinegame_memo .memo_music_toggle:focus {
    background: #ffffff;
    color: var(--memo-blue);
    outline: none;
}

#onlinegame_memo .memo_music_toggle:focus {
    box-shadow: 0 0 0 2px rgba(39, 94, 168, 0.24);
}

#onlinegame_memo .memo_music_toggle.memo_music_muted {
    color: var(--hd-muted, #5d686c);
}

#onlinegame_memo .memo_game_status {
    align-items: center;
    background: rgba(255, 255, 255, 0.82);
    border: 1px solid rgba(46, 74, 67, 0.18);
    border-radius: 7px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px 22px;
    justify-content: center;
    margin-bottom: 15px;
    max-width: 820px;
    padding: 8px 16px;
    width: 100%;
}

#onlinegame_memo .memo_status_item {
    color: var(--hd-muted, #5d686c);
    font-size: 14px;
    white-space: nowrap;
}

#onlinegame_memo .memo_status_item strong {
    color: var(--memo-blue-dark);
}

#onlinegame_memo .memo_board {
    display: grid;
    gap: 10px;
    margin: 0 auto;
    max-width: 850px;
    opacity: 0;
    transition: opacity 160ms ease;
    width: 100%;
}

#onlinegame_memo .memo_board_back_light {
    --memo-card-back-color: #f8fcff;
    --memo-card-back-image:
        url("/modules/chinesekids/base_svg/ico_logo.svg"),
        url("/modules/chinesekids/views/img/chinesetools/memo/memo-card-back-light-bg.webp");
}

#onlinegame_memo .memo_board_ready {
    opacity: 1;
}

#onlinegame_memo .memo_board[data-columns="4"] {
    max-width: 690px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

#onlinegame_memo .memo_board[data-columns="5"] {
    grid-template-columns: repeat(5, minmax(0, 1fr));
}

#onlinegame_memo .memo_game_actions {
    align-items: center;
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 20px;
}

#onlinegame_memo .memo_game_settings,
#memo_result .memo_game_settings {
    color: var(--memo-blue-dark);
    display: none;
    font-size: 13px;
}

#memo_result {
    justify-content: center;
}

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

#memo_result .memo_result_summary {
    background: rgba(255, 255, 255, 0.78);
    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%;
}

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

#memo_result .memo_result_characters {
    color: var(--memo-blue-dark);
    font-size: 30px;
    letter-spacing: 4px;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

#memo_result .memo_result_stats {
    align-items: center;
    border-top: 1px solid rgba(46, 74, 67, 0.13);
    color: var(--hd-muted, #5d686c);
    display: flex;
    flex-wrap: wrap;
    gap: 8px 20px;
    justify-content: center;
    margin-top: 10px;
    padding-top: 10px;
}

#memo_result .memo_result_stats strong {
    color: var(--memo-blue-dark);
}

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

@media (max-width: 991px) {
    #onlinegame_memo .memo_board {
        max-width: 720px;
    }
}

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

    #memo #result_preview {
        aspect-ratio: 4 / 5;
        background-image:
            url("/modules/chinesekids/views/img/chinesetools/memo/memo-hero-mobile.webp");
        min-height: 0;
    }

    #onlinegame_memo,
    #memo_result {
        min-height: 520px;
        padding: 18px 8px;
    }

    #onlinegame_memo .memo_game_title {
        font-size: 23px;
        margin-bottom: 10px;
        padding: 0 38px;
    }

    #onlinegame_memo .memo_music_toggle {
        height: 32px;
        right: 10px;
        top: 10px;
        width: 32px;
    }

    #onlinegame_memo .memo_game_status {
        gap: 6px 13px;
        padding: 7px 8px;
    }

    #onlinegame_memo .memo_status_item {
        font-size: 12px;
    }

    #onlinegame_memo .memo_board,
    #onlinegame_memo .memo_board[data-columns="4"],
    #onlinegame_memo .memo_board[data-columns="5"] {
        gap: 6px;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        max-width: 100%;
    }

    .memo_card_back,
    .memo_card_front {
        border-radius: 7px;
    }

    .memo_card_front_pinyin {
        font-size: clamp(14px, 4.5vw, 21px);
    }

    #onlinegame_memo .memo_game_settings,
    #memo_result .memo_game_settings {
        display: inline-block;
    }

    #memo_result h1 {
        font-size: 36px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .memo_card_inner,
    #onlinegame_memo .memo_board {
        transition-duration: 0.01ms;
    }

    .memo_card_matched,
    .memo_card_mismatch {
        animation: none;
    }
}
