/* ------------------------- BODY / GLOBAL ------------------------- */
body {
    padding: 0;
    margin: 0;
    height: 100vh;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #f0f0f0;
    overflow-x: hidden;
}

html, body {
    overscroll-behavior-y: none;
}

.global {
    position: relative;
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2vw;
    box-sizing: border-box;
}

.container {
    display: grid;
    grid-template-rows: auto 1fr;
    width: 100%;
    height: 100%;
}

/* ------------------------- HEADER / NAV ------------------------- */
header {
    display: block;
    margin-bottom: 1rem;
}

header a.btn {
    font-size: 1rem;
    padding: 0.6em 1em;
    margin: 0;
}

/* ------------------------- FLIP CARD ------------------------- */
.card {
    /* one square size for every device; never touches the edges */
    --card-size: min(90vw, 80vh, 800px);
    width: var(--card-size);
    height: var(--card-size);
    perspective: 1000px;
    margin-inline: auto;
    overflow: hidden;
}

.card-inner {
    width: 100%;
    height: 100%;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: calc(var(--card-size) * 0.7);
    transition: transform 0.5s ease, background 0.5s ease, color 0.5s ease;
    transform-style: preserve-3d;
    position: relative;
}

.card-face,
.card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    text-align: center;
}

.card-face {
    background: #fff;
    color: #e74c3c;
}

.font-one-char   { font-size: 1em; }
.font-two-char   { font-size: 0.5em; }
.font-three-char { font-size: 0.25em; }

.card-back {
    flex-direction: column;
    font-size: 0.66em;
    background: #198754;
    color: #fff;
    transform: rotateY(180deg);
}
.card-back .pinyin      { font-size: 0.66em; }
.card-back .translation { font-size: 0.22em; }

.card.flipped .card-inner {
    transform: rotateY(180deg);
}

/* bkrs link on the card back */
a.bkrs {
    text-decoration: none;
    font-weight: bold;
    color: #fff !important;
}
a.bkrs:hover { text-decoration: underline; }
a.bkrs > span.boostrap-hack { color: #fff !important; }

/* ------------------------- MYTH PAGE ------------------------- */
/* card here sizes to its content, not the flip-card square */
.myth-page .card {
    height: auto;
    --card-size: auto;
    overflow: visible;
}

.myth-image {
    width: 100%;
    height: auto;
    display: block;
    background: #faf9f6;
}

/* ------------------------- DRAWING PAGE ------------------------- */
.draw-page .form-select,
.draw-page .form-control {
    border-radius: 12px;
    border-color: #e2e2dc;
    padding: 0.6em 0.9em;
    font-size: 1rem;
    background-color: #fff;
}

.draw-page .form-select:focus,
.draw-page .form-control:focus {
    border-color: #b9b9b1;
    box-shadow: 0 0 0 0.18rem rgba(0, 0, 0, 0.05);
}

.draw-page .btn {
    border-radius: 12px;
    font-weight: 500;
}

.draw-page #result {
    text-align: center;
    margin-top: 0.5rem;
    min-height: 1.5em;
}

/* prompt list (RU / EN / Pinyin / Answer / Display) */
.draw-page .prompt-list {
    border: 1px solid #e2e2dc;
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
}

.draw-page .prompt-list .list-group-item {
    background: transparent;
    border-color: #eee;
    padding: 0.65rem 1rem;
    align-items: baseline;
}

.draw-page .prompt-label {
    flex: 0 0 5.5rem;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
}

.draw-page .prompt-value {
    font-size: 1.05rem;
    color: #1f1f1f;
}

.draw-page .form-switch .form-check-label {
    color: #6b6b6b;
    cursor: pointer;
}

/* drawing cells: neutral rounded frame so each character has its square */
.draw-page #canvases > div {
    background: #fff;
    border: 1px solid #e2e2dc !important;
    border-radius: 12px !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

/* drawing cells: SVG fills the cell so 1 char = 100%, 2 = 50/50, etc. */
.draw-page #canvases svg {
    width: 100% !important;
    height: 100% !important;
    display: block;
}

/* bottom action buttons match the green menu style */
.draw-page .btn-secondary {
    color: #198754;
    background-color: transparent;
    border-color: #198754;
    border-radius: 12px;
}
.draw-page .btn-secondary:hover,
.draw-page .btn-secondary:focus {
    color: #fff;
    background-color: #198754;
    border-color: #198754;
}
.draw-page .btn-primary {
    background-color: #198754;
    border-color: #198754;
    border-radius: 12px;
}
.draw-page .btn-primary:hover,
.draw-page .btn-primary:focus {
    background-color: #146c43;
    border-color: #146c43;
}

/* ------------------------- LANGUAGE SWITCHER (pill) ------------------------- */
.lang {
    display: flex;
    align-items: center;
}

.lang select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    width: auto;
    min-width: 4.5rem;
    border: 1px solid #198754;
    border-radius: 2rem;
    padding: 0.35rem 2rem 0.35rem 0.9rem;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.4;
    color: #198754;
    background-color: #fff;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23198754' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.7rem center;
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.lang select:hover {
    background-color: #198754;
    color: #fff;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
}

.lang select:focus {
    outline: none;
    border-color: #198754;
    box-shadow: 0 0 0 0.2rem rgba(25, 135, 84, 0.2);
}

/* ------------------------- RESPONSIVE ------------------------- */
@media (max-width: 1024px) {
    header a.btn {
        font-size: 2.2vw;
        padding: 0.7em 1em;
    }
}

@media (max-width: 768px) {
    header a.btn {
        font-size: 4vw;
        padding: 0.6em 0.8em;
    }
}

/* nav: menu buttons + language pill stay on one tidy row */
@media (max-width: 576px) {
    header .row {
        flex-wrap: nowrap;
        gap: 0.4rem;
    }
    header .row > .col {
        flex: 1 1 0;
        min-width: 0;
        padding-left: 0;
        padding-right: 0;
    }
    header .row > .col-auto.lang,
    header .row > .lang {
        flex: 0 0 auto;
        padding-left: 0;
        padding-right: 0;
    }
    header a.btn {
        font-size: 0.9rem;
        padding: 0.5em 0.3em;
        white-space: nowrap;
    }
    .lang select {
        min-width: 3.2rem;
        padding: 0.5rem 1.5rem 0.5rem 0.6rem;
        font-size: 0.85rem;
        height: 100%;
    }
}

@media (max-width: 480px) {
    header a.btn {
        font-size: 0.9rem;
        padding: 0.5em 0.3em;
    }
}
