*{
    margin:0;
    padding:0;
    box-sizing:border-box;
    font-family:Arial, Helvetica, sans-serif;
}

body{
    margin:0;
    min-height:100vh;

    background:
    radial-gradient(circle at top,#3b82f6 0%,#111827 45%,#030712 100%);

    color:white;

    display:flex;
    justify-content:center;

    padding:35px;

    font-family:
    "Segoe UI",
    Arial,
    sans-serif;
}

.container{

    width:1200px;
    max-width:100%;

    background:rgba(255,255,255,.08);

    backdrop-filter:blur(25px);

    border:1px solid rgba(255,255,255,.15);

    border-radius:30px;

    padding:35px;

    box-shadow:

    0 30px 70px rgba(0,0,0,.5);

}

header{
    text-align:center;
    margin-bottom:25px;
}

header h1{

    color:white;

    font-size:48px;

    letter-spacing:2px;

}

header p{

    color:#d1d5db;

    margin-top:10px;

    font-size:18px;

}

.menu{
    display:flex;
    gap:10px;
    margin-bottom:25px;
    flex-wrap:wrap;
}

.menu button{
    flex:1;
}

button{

padding:15px 22px;

border:none;

border-radius:18px;

font-size:17px;

font-weight:700;

color:white;

cursor:pointer;

background:linear-gradient(135deg,#2563eb,#60a5fa);

transition:.3s;

box-shadow:

0 10px 25px rgba(59,130,246,.35);

}

button:hover{

transform:translateY(-5px) scale(1.03);

box-shadow:

0 18px 40px rgba(59,130,246,.55);

}

button:active{

transform:scale(.97);

}


.card{
    background:rgba(255,255,255,.08);
    border:1px solid rgba(255,255,255,.15);
    backdrop-filter:blur(18px);
    border-radius:25px;
    padding:25px;
    margin-bottom:25px;
}

.card h2{
    margin-bottom:15px;
}

input,
textarea{

width:100%;

padding:16px 20px;

font-size:17px;

border:none;

border-radius:18px;

background:rgba(255,255,255,.09);

backdrop-filter:blur(15px);

color:white;

transition:.25s;

}

input:focus,
textarea:focus{

outline:none;

transform:scale(1.01);

box-shadow:0 0 20px rgba(59,130,246,.45);

}

::placeholder{
    color:#cbd5e1;
}

input:focus{
    outline:none;
    border-color:#2575fc;
}

#wordList{
    display:flex;
    flex-direction:column;
    gap:10px;
}

.word{

display:flex;
justify-content:space-between;
align-items:center;

padding:18px 22px;

margin-bottom:15px;

border-radius:18px;

background:rgba(255,255,255,.08);

backdrop-filter:blur(20px);

border:1px solid rgba(255,255,255,.12);

transition:.25s;

}

.word:hover{

transform:translateY(-4px);

background:rgba(255,255,255,.12);

box-shadow:0 15px 35px rgba(59,130,246,.35);

}
.studyButtons{
    display:flex;
    gap:10px;
    justify-content:center;
    flex-wrap:wrap;
}

.studyButtons button{
    min-width:170px;
}

@media(max-width:700px){

.menu{
    flex-direction:column;
}

.studyButtons{
    flex-direction:column;
}



}
#answers{
    display:flex;
    flex-direction:column;
    gap:10px;
    margin-top:20px;
}

.answerBtn{
    background:#2575fc;
    color:white;
    border:none;
    border-radius:10px;
    padding:14px;
    cursor:pointer;
    font-size:18px;
    transition:.2s;
}

.answerBtn:hover{
    transform:scale(1.02);
}

.correct{
    background:#2ecc71 !important;
}

.wrong{
    background:#e74c3c !important;
}

.flashcard{
    width:100%;
    max-width:600px;
    height:350px;
    margin:30px auto;
    perspective:1000px;
    cursor:pointer;
    box-shadow:0 10px 30px rgba(0,0,0,.15);
}

.cardInner{
    width:100%;
    height:100%;
    position:relative;
    transform-style:preserve-3d;
    transition:transform .6s;
}

.cardInner.flip{
    transform:rotateY(180deg);
}

.cardFront,
.cardBack{
    position:absolute;
    width:100%;
    height:100%;

    background:white;
    border-radius:20px;

    box-shadow:0 10px 25px rgba(0,0,0,.15);

    display:flex;
    flex-direction:column;
    justify-content:center;
    align-items:center;

    backface-visibility:hidden;
    -webkit-backface-visibility:hidden;

    padding:20px;
}

.cardBack{
    transform:rotateY(180deg);
}

#cardImage{

width:180px;
height:180px;
object-fit:cover;
border-radius:15px;

}

#cardFrontText,
#cardBackText{
    font-size:34px;
    font-weight:bold;
    text-align:center;
}
#createSet .card{

    max-width:700px;
    margin:auto;

}
.wordButtons{
    display:flex;
    gap:8px;
}
.setCard{

    background:white;
    border-radius:20px;
    padding:20px;
    margin-bottom:20px;

    box-shadow:0 10px 25px rgba(0,0,0,.15);

}

.setButtons{

    display:flex;
    gap:10px;
    margin-top:15px;

}



header{
    position:relative;
}

.themeBtn{

    position:absolute;

    top:0;

    right:0;

    width:50px;

    height:50px;

    border-radius:50%;

    font-size:22px;

    cursor:pointer;

}
/* ===========================
   🌙 ТЁМНАЯ ТЕМА
=========================== */

body.dark{
    background:#121212;
}

body.dark .container{
    background:#1e1e1e;
    color:white;
}

body.dark header h1,
body.dark header p,
body.dark h2,
body.dark h3,
body.dark p,
body.dark span,
body.dark b{
    color:white;
}

body.dark .card{
    background:#2b2b2b;
}

body.dark .word{
    background:#333;
}

body.dark .flashcard{
    background:#2f2f2f;
    color:white;
}

body.dark .cardFront,
body.dark .cardBack{
    background:#2f2f2f;
    color:white;
}

body.dark input,
body.dark textarea{
    background:#333;
    color:white;
    border:2px solid #555;
}

body.dark input::placeholder,
body.dark textarea::placeholder{
    color:#bbb;
}

body.dark button{
    background:#3b82f6;
    color:white;
}

body.dark button:hover{
    background:#2563eb;
}

body.dark .answerBtn{
    background:#3b82f6;
}

body.dark .correct{
    background:#22c55e !important;
}

body.dark .wrong{
    background:#ef4444 !important;
}
body.dark .setCard{
    background:#333;
    color:white;
}

body.dark .setCard h3{
    color:white;
}

body.dark .setCard p{
    color:white;
}
#letters{

    display:flex;
    justify-content:center;
    gap:10px;
    flex-wrap:wrap;
    margin:20px;

}


.letterBtn{

    width:50px;
    height:50px;
    font-size:24px;

}


#scrambleAnswer{

    min-height:40px;
    text-align:center;

}
#letters{

    display:flex;
    flex-wrap:wrap;
    gap:10px;
    justify-content:center;
    margin:20px 0;

}

.letterBtn{

    width:55px;
    height:55px;

    font-size:24px;
    font-weight:bold;

    border:none;
    border-radius:12px;

    cursor:pointer;

    transition:.2s;

}

.letterBtn:hover{

    transform:scale(1.08);

}

.letterBtn:disabled{

    opacity:.35;
    cursor:default;

}
/* ===========================
   СТАТИСТИКА
=========================== */

.statsGrid{

    display:grid;

    grid-template-columns:repeat(auto-fit,minmax(230px,1fr));

    gap:20px;

}

.statCard{

    background:rgba(255,255,255,.08);

    backdrop-filter:blur(18px);

    border:1px solid rgba(255,255,255,.15);

    border-radius:22px;

    padding:25px;

    transition:.3s;
position:relative;

overflow:hidden;
}

.statCard:hover{

    transform:translateY(-6px);

}

.statNumber{

    font-size:42px;

    font-weight:bold;

    margin-top:15px;

    color:#60a5fa;

}

.progressBar{

    width:100%;

    height:12px;

    margin-top:20px;

    background:rgba(255,255,255,.15);

    border-radius:30px;

    overflow:hidden;

}

.progressFill{

    width:0%;

    height:100%;

    border-radius:30px;

    background:linear-gradient(90deg,#22c55e,#3b82f6);

    transition:width .5s;

}

.statCard{

background:rgba(255,255,255,.08);

backdrop-filter:blur(20px);

border-radius:20px;

padding:25px;

text-align:center;

box-shadow:0 10px 30px rgba(0,0,0,.25);

transition:.3s;

}

.statCard:hover{

transform:translateY(-8px);

}

.statCard h2{

font-size:18px;

margin-bottom:15px;

}

.statCard h1{

font-size:42px;

color:#60a5fa;

margin-bottom:15px;

}

.progressBar{

height:14px;

background:#444;

border-radius:20px;

overflow:hidden;

}

@keyframes pop{

0%{
transform:scale(.8);
opacity:0;
}

100%{
transform:scale(1);
opacity:1;
}

}


.gamesGrid{

display:grid;

grid-template-columns:
repeat(auto-fit,minmax(260px,1fr));

gap:25px;

margin-top:20px;

}

.gameCard{

height:340px;

display:flex;
flex-direction:column;
justify-content:space-between;

background:rgba(255,255,255,.08);

backdrop-filter:blur(20px);

border-radius:25px;

padding:30px;

text-align:center;

transition:.35s;

box-shadow:0 20px 40px rgba(0,0,0,.25);

}

.gameCard:hover{

transform:translateY(-12px) scale(1.04);

box-shadow:0 25px 60px rgba(59,130,246,.45);

}


.gameIcon{

font-size:90px;

margin-bottom:25px;

}

.gameCard h2{

margin-bottom:15px;

}

.gameCard p{

opacity:.8;

margin-bottom:20px;

line-height:1.5;

}

#gameScreen{

margin-top:35px;

padding:35px;

border-radius:25px;

background:rgba(255,255,255,.08);

backdrop-filter:blur(20px);

border:1px solid rgba(255,255,255,.12);

animation:pop .4s;

}
.gameCard button{

margin-top:20px;

padding:16px;

font-size:18px;

border-radius:16px;

width:100%;

}
.statCard::before{

content:"";

position:absolute;

top:0;
left:0;

width:100%;
height:5px;

background:linear-gradient(
90deg,
#22c55e,
#3b82f6,
#8b5cf6
);

}
.gamesTitle{
    text-align:center;
    font-size:42px;
    margin-bottom:8px;
}

.gamesSubtitle{
    text-align:center;
    color:#888;
    margin-bottom:35px;
}

.gamesGrid{
    display:grid;
    grid-template-columns:repeat(auto-fit,minmax(260px,1fr));
    gap:25px;
}

.gameCard{
    background:white;
    border-radius:22px;
    padding:30px;
    text-align:center;
    box-shadow:0 15px 35px rgba(0,0,0,.12);
    transition:.3s;
    cursor:pointer;
}

.dark .gameCard{
    background:#232323;
}

.gameCard:hover{
    transform:translateY(-8px);
}

.gameIcon{
    font-size:55px;
    margin-bottom:15px;
}

.gameCard h2{
    margin-bottom:12px;
}

.gameCard p{
    color:#777;
    min-height:45px;
}

.playBtn{
    display:inline-block;
    margin-top:20px;
    background:#4CAF50;
    color:white;
    padding:12px 30px;
    border-radius:12px;
    font-weight:bold;
}

.dark .playBtn{
    background:#66bb6a;
}
.flashcard{

    width:420px;
    height:280px;

    margin:40px auto;

    perspective:1200px;

    cursor:pointer;

    transition:.3s;

}

.flashcard:hover{

    transform:translateY(-8px) scale(1.03);

}

.cardInner{

    width:100%;
    height:100%;

    position:relative;

    transition:transform .7s cubic-bezier(.2,.8,.2,1);

    transform-style:preserve-3d;

}

.cardInner.flip{

    transform:rotateY(180deg);

}

.cardFront,
.cardBack{

    position:absolute;

    width:100%;
    height:100%;

    border-radius:25px;

    backface-visibility:hidden;

    display:flex;

    flex-direction:column;

    justify-content:center;

    align-items:center;

    padding:20px;

    box-shadow:0 15px 40px rgba(0,0,0,.18);

}

.cardFront{

    background:linear-gradient(135deg,#4f8cff,#6da8ff);

    color:white;

}

.cardBack{

    background:white;

    color:#222;

    transform:rotateY(180deg);

}
#cardFrontText,
#cardBackText{

    font-size:42px;

    font-weight:700;

    text-align:center;

    transition:.3s;

}
#cardImage{

    width:130px;

    height:130px;

    object-fit:cover;

    border-radius:18px;

    margin-bottom:20px;

    box-shadow:0 8px 20px rgba(0,0,0,.2);

}
.studyButtons{

    display:flex;

    gap:15px;

    justify-content:center;

    flex-wrap:wrap;

    margin-top:30px;

}

.studyButtons button{

    padding:14px 26px;

    border:none;

    border-radius:15px;

    font-size:17px;

    cursor:pointer;

    transition:.25s;

}

.studyButtons button:hover{

    transform:translateY(-4px);

}

.studyButtons button:active{

    transform:scale(.94);

}
@keyframes cardAppear{

    from{

        opacity:0;
        transform:scale(.9);

    }

    to{

        opacity:1;
        transform:scale(1);

    }

}

.flashcard{

    animation:cardAppear .35s ease;

}

.achievements{
    width:100%;
}

#achievementList{
    display:grid;
    grid-template-columns:repeat(auto-fill,minmax(180px,1fr));
    gap:15px;
    margin-top:20px;
}

.badge{
    background:#ffffff;
    border-radius:20px;
    padding:20px;
    text-align:center;
    transition:.3s;
    cursor:pointer;
    box-shadow:0 8px 20px rgba(0,0,0,.08);
    border:3px solid transparent;
}

body.dark .badge{
    background:#232323;
}

.badge:hover{
    transform:translateY(-6px) scale(1.03);
}

.badge.locked{
    opacity:.35;
    filter:grayscale(100%);
}

.badge.unlocked{
    border-color:#FFD54A;
    animation:badgePop .5s;
}

.badgeIcon{
    font-size:45px;
    margin-bottom:10px;
}

.badgeTitle{
    font-size:18px;
    font-weight:bold;
}

.badgeDesc{
    font-size:13px;
    margin-top:6px;
    opacity:.8;
}

@keyframes badgePop{

0%{
transform:scale(.7);
}

70%{
transform:scale(1.1);
}

100%{
transform:scale(1);
}

}

.badgeProgress{

height:8px;

background:#ddd;

border-radius:20px;

overflow:hidden;

margin-top:10px;

}

.badgeFill{

height:100%;

background:linear-gradient(90deg,#4CAF50,#00E676);

transition:.3s;

}

.badgeCounter{

margin-top:6px;

font-size:13px;

opacity:.8;

}
.quest{
    background:#2f2f2f;
    border-radius:15px;
    padding:18px;
    margin:15px 0;
}

.questTitle{
    font-size:20px;
    font-weight:bold;
    margin-bottom:8px;
}

.questProgress{
    color:#ccc;
    margin-bottom:10px;
}

.questBar{
    height:10px;
    background:#444;
    border-radius:10px;
    overflow:hidden;
}

.questFill{
    height:100%;
    width:0%;
    background:linear-gradient(90deg,#3b82f6,#22c55e);
    transition:.4s;
}

.questDone{

    color:#5cff8d;
    font-weight:bold;
    margin-top:10px;

}
/* ===================================== */
/* 📱 МОБИЛЬНАЯ ВЕРСИЯ */
/* ===================================== */

@media (max-width: 900px){

.container{
    width:95%;
    padding:15px;
}

header h1{
    font-size:34px;
}

header p{
    font-size:18px;
}

.menu{
    display:grid;
    grid-template-columns:1fr 1fr;
    gap:10px;
}

.menu button{
    width:100%;
    font-size:17px;
}

.gamesGrid{
    grid-template-columns:1fr;
}

.statsGrid{
    grid-template-columns:1fr;
}

.studyButtons{
    display:flex;
    flex-direction:column;
    gap:10px;
}

.studyButtons button{
    width:100%;
}

.flashcard{
    width:100%;
    height:260px;
}

.cardFrontText,
.cardBackText{
    font-size:34px;
}

.card img{
    max-width:100%;
    height:auto;
}

input,
textarea,
select,
button{
    width:100%;
    box-sizing:border-box;
}

.word{
    flex-direction:column;
    align-items:flex-start;
    gap:10px;
}

.word button{
    width:100%;
}

.setButtons{
    display:grid;
    grid-template-columns:1fr 1fr;
    gap:8px;
}

.setButtons button{
    width:100%;
}

.progressBar{
    width:100%;
}

}
@media (max-width:500px){

header h1{
    font-size:28px;
}

header p{
    font-size:16px;
}

.flashcard{
    height:220px;
}

.cardFrontText,
.cardBackText{
    font-size:28px;
}

.gamesTitle{
    font-size:36px;
}

.gamesSubtitle{
    font-size:16px;
}

.gameCard{
    padding:20px;
}

.gameIcon{
    font-size:48px;
}

}
/* ========================= */
/* ЭССЕ И ПИСЬМА */
/* ========================= */

.essayHeader {
    text-align: center;
}

.essayHeader p {
    opacity: 0.8;
}


#essayTitle,
#essayType,
#essayText {

    width: 100%;

    box-sizing: border-box;

    margin-bottom: 15px;

}


#essayTitle {

    padding: 14px;

    border-radius: 10px;

    border: 1px solid #ccc;

    font-size: 17px;

}


#essayType {

    padding: 14px;

    border-radius: 10px;

    border: 1px solid #ccc;

    font-size: 16px;

}


#essayText {

    min-height: 350px;

    resize: vertical;

    padding: 16px;

    border-radius: 12px;

    border: 1px solid #ccc;

    font-size: 16px;

    line-height: 1.6;

    font-family: inherit;

}


.essayButtons {

    display: flex;

    gap: 10px;

    flex-wrap: wrap;

}


.essayButtons button {

    flex: 1;

    min-width: 130px;

}


.essayItem {

    display: flex;

    justify-content: space-between;

    align-items: center;

    gap: 20px;

    padding: 18px;

    margin-bottom: 12px;

    border-radius: 14px;

    background: rgba(128,128,128,0.12);

}


.essayInfo {

    flex: 1;

    min-width: 0;

}


.essayInfo h3 {

    margin-top: 0;

}


.essayInfo p {

    opacity: 0.75;

    overflow-wrap: anywhere;

}


.essayActions {

    display: flex;

    gap: 8px;

}


.essayActions button {

    min-width: 45px;

    padding: 10px;

}


/* МОБИЛЬНАЯ ВЕРСИЯ */

@media (max-width: 600px) {

    .essayItem {

        flex-direction: column;

        align-items: stretch;

    }


    .essayActions {

        width: 100%;

    }


    .essayActions button {

        flex: 1;

    }


    .essayButtons {

        flex-direction: column;

    }


    .essayButtons button {

        width: 100%;

    }


    #essayText {

        min-height: 280px;

    }

}
/* Исправление клика по вкладке Эссе на ПК */

.menu {
    position: relative;
    z-index: 1000;
}

.menu button {
    position: relative;
    z-index: 1001;
    pointer-events: auto;
}

#essayTab {
    position: relative;
    z-index: 1002;
    pointer-events: auto;
    cursor: pointer;
}
.essayWordCounter {
    margin-top: 10px;
    padding: 8px 12px;
    border-radius: 10px;
    background: rgba(100, 100, 100, 0.1);
    font-size: 14px;
    font-weight: 600;
    text-align: right;
}

/* Полировка интерфейса и мобильная раскладка */
:root {
    color-scheme: dark;
    --panel: rgba(20, 25, 48, 0.76);
    --panel-border: rgba(198, 208, 255, 0.13);
    --text-muted: #aeb8d4;
    --accent: #9c78ff;
}

body {
    align-items: flex-start;
    min-height: 100vh;
    padding: clamp(12px, 3vw, 36px);
    background:
        radial-gradient(ellipse at 12% 4%, rgba(80, 107, 255, .26), transparent 34rem),
        radial-gradient(ellipse at 88% 24%, rgba(221, 71, 179, .13), transparent 32rem),
        linear-gradient(145deg, #0b1020, #11152a 54%, #090c18);
    color: #f5f6ff;
}

body.dark {
    background:
        radial-gradient(ellipse at 12% 4%, rgba(80, 107, 255, .18), transparent 34rem),
        radial-gradient(ellipse at 88% 24%, rgba(221, 71, 179, .1), transparent 32rem),
        linear-gradient(145deg, #080a12, #121321 54%, #090a10);
}

.container {
    width: min(1120px, 100%);
    padding: clamp(18px, 4vw, 42px);
    border: 1px solid var(--panel-border);
    border-radius: clamp(20px, 3vw, 32px);
    background: rgba(15, 19, 38, .72);
    box-shadow: 0 28px 90px rgba(0, 0, 0, .4), inset 0 1px rgba(255, 255, 255, .04);
}

header {
    margin-bottom: 26px;
    padding: 5px 96px 0;
}

header h1 {
    font-size: clamp(30px, 5vw, 48px);
    letter-spacing: -.04em;
    background: linear-gradient(100deg, #fff 15%, #c9c4ff 56%, #f6a8dd);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

header p,
.gamesSubtitle {
    color: var(--text-muted);
}

button {
    width: auto;
    min-height: 46px;
    padding: 12px 18px;
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: 15px;
    background: linear-gradient(135deg, #705cff, #aa5fe8);
    box-shadow: 0 8px 22px rgba(117, 83, 255, .2);
    transition: transform .2s ease, box-shadow .2s ease, filter .2s ease;
    touch-action: manipulation;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(160, 94, 255, .3);
    filter: brightness(1.08);
}

button:active {
    transform: scale(.97);
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
.gameCard:focus-visible {
    outline: 2px solid #d5a5ff;
    outline-offset: 3px;
}

body.dark button {
    border-color: rgba(255, 255, 255, .12);
    background: linear-gradient(135deg, #705cff, #aa5fe8);
}

body.dark button:hover {
    background: linear-gradient(135deg, #806dff, #b978ed);
}

header .themeBtn,
header .soundBtn {
    position: absolute;
    top: 0;
    right: 0;
    display: grid;
    width: 44px;
    min-height: 44px;
    height: 44px;
    padding: 0;
    place-items: center;
    border-radius: 14px;
    font-size: 19px;
}

header .soundBtn {
    right: 54px;
}

.menu {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 24px;
}

.menu button {
    min-width: 0;
    padding: 12px 8px;
    background: rgba(255, 255, 255, .055);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .07);
}

.menu button:hover {
    background: rgba(151, 119, 255, .23);
}

.card,
.setCard,
.statCard,
.word {
    border: 1px solid var(--panel-border);
    background: var(--panel);
    box-shadow: 0 14px 36px rgba(0, 0, 0, .17);
}

body.dark .card,
body.dark .setCard,
body.dark .statCard,
body.dark .word {
    border-color: var(--panel-border);
    background: var(--panel);
}

.card {
    padding: clamp(18px, 3vw, 28px);
    border-radius: 22px;
}

.card h2,
.card h3 {
    color: #f4f2ff;
}

.card p,
.word,
.setCard p {
    color: var(--text-muted);
}

input,
textarea,
select {
    margin: 6px 0 12px;
    border: 1px solid rgba(202, 207, 255, .14);
    background: rgba(7, 10, 23, .55);
    color: #f6f5ff;
}

input:focus,
textarea:focus,
select:focus {
    box-shadow: 0 0 0 3px rgba(156, 120, 255, .18);
}

input[type="file"] {
    min-height: 48px;
}

.word {
    margin-bottom: 0;
    padding: 15px 18px;
    border-radius: 16px;
}

.word:hover {
    background: rgba(255, 255, 255, .09);
    box-shadow: 0 12px 28px rgba(126, 91, 255, .16);
}

.wordButtons,
.setButtons,
.essayActions {
    flex-wrap: wrap;
}

.setCard {
    border-radius: 20px;
}

.statsGrid {
    gap: 14px;
}

.statCard {
    border-radius: 19px;
}

.statNumber,
.statCard h1 {
    color: #d3a0ff;
}

.progressFill {
    background: linear-gradient(90deg, #40e0bd, #8b73ff, #f171c8);
}

.gamesTitle {
    font-size: clamp(30px, 5vw, 42px);
}

.gamesGrid {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 17px;
}

.gameCard {
    position: relative;
    isolation: isolate;
    height: auto;
    min-height: 250px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, .11);
    background: linear-gradient(150deg, rgba(37, 39, 72, .88), rgba(20, 23, 43, .95));
    color: #f6f5ff;
    box-shadow: 0 18px 40px rgba(0, 0, 0, .24);
}

body.dark .gameCard {
    border-color: rgba(255, 255, 255, .11);
    background: linear-gradient(150deg, rgba(37, 39, 72, .88), rgba(20, 23, 43, .95));
}

.gameCard::before {
    position: absolute;
    z-index: -1;
    inset: -18px;
    border-radius: inherit;
    background: conic-gradient(from 0deg, #ff4d9d, #ffb84d, #d8ff64, #41e6bc, #5ca9ff, #a76bff, #ff4d9d);
    content: "";
    opacity: .42;
    filter: blur(24px);
    animation: rainbowDrift 11s linear infinite;
}

.gameCard > * {
    position: relative;
    z-index: 1;
}

.gameCard:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 46px rgba(139, 102, 255, .25);
}

.gameCard h2 {
    color: #f6f5ff;
}

.gameCard p {
    min-height: auto;
    color: #bbc3df;
}

.gameIcon {
    font-size: 56px;
    filter: drop-shadow(0 5px 15px rgba(183, 142, 255, .28));
}

.playBtn {
    background: linear-gradient(100deg, #785cff, #d15cba);
    box-shadow: 0 8px 22px rgba(180, 77, 201, .23);
}

.flashcard {
    position: relative;
    isolation: isolate;
    width: min(100%, 560px);
    height: clamp(230px, 42vh, 350px);
    margin: 28px auto 20px;
    box-shadow: none;
}

.flashcard::before {
    position: absolute;
    z-index: -1;
    inset: -5px;
    border-radius: 30px;
    background: conic-gradient(from 0deg, #ff4d9d, #ffb84d, #d8ff64, #41e6bc, #5ca9ff, #a76bff, #ff4d9d);
    content: "";
    opacity: .78;
    filter: blur(18px);
    animation: rainbowDrift 8s linear infinite;
}

.cardInner {
    border-radius: 24px;
}

.cardFront,
.cardBack {
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, .16);
    border-radius: 24px;
    background: linear-gradient(145deg, #202746, #16192f 70%);
    color: #f8f6ff;
    box-shadow: inset 0 1px rgba(255, 255, 255, .08), 0 18px 42px rgba(0, 0, 0, .32);
}

body.dark .cardFront,
body.dark .cardBack {
    background: linear-gradient(145deg, #202746, #16192f 70%);
    color: #f8f6ff;
}

#cardFrontText,
#cardBackText {
    max-width: 100%;
    overflow-wrap: anywhere;
    font-size: clamp(27px, 5vw, 40px);
}

#cardImage {
    max-width: min(180px, 40vw);
    max-height: 48%;
    margin-bottom: 12px;
}

#cardCounter {
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.studyButtons {
    gap: 10px;
}

.answerBtn {
    border-radius: 14px;
    background: rgba(122, 102, 255, .82);
}

.correct {
    background: linear-gradient(120deg, #0ba978, #32cb8d) !important;
}

.wrong {
    background: linear-gradient(120deg, #ce4775, #ee6b72) !important;
}

.letterBtn {
    min-width: 48px;
    border-radius: 14px;
    background: linear-gradient(140deg, #745aff, #a461e8);
}

.essayWordCounter {
    border: 1px solid var(--panel-border);
    background: rgba(255, 255, 255, .045);
    color: var(--text-muted);
}

@keyframes rainbowDrift {
    to {
        transform: rotate(360deg);
    }
}

@media (max-width: 700px) {
    body {
        padding: 10px;
    }

    .container {
        width: 100%;
        padding: 16px;
        border-radius: 22px;
    }

    header {
        margin-bottom: 19px;
        padding: 7px 76px 0;
    }

    header h1 {
        font-size: clamp(27px, 7vw, 34px);
        letter-spacing: -.045em;
    }

    header p {
        margin-top: 6px;
        font-size: 15px;
    }

    header .themeBtn,
    header .soundBtn {
        width: 40px;
        min-height: 40px;
        height: 40px;
        border-radius: 13px;
    }

    header .soundBtn {
        right: 48px;
    }

    .menu {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 7px;
        margin-bottom: 18px;
    }

    .menu button {
        min-height: 42px;
        padding: 9px 5px;
        border-radius: 12px;
        font-size: 13px;
        line-height: 1.2;
    }

    .card {
        margin-bottom: 14px;
        padding: 17px;
        border-radius: 18px;
    }

    .card h2 {
        font-size: 21px;
    }

    input,
    textarea,
    select {
        min-height: 46px;
        padding: 12px 14px;
        font-size: 16px;
    }

    .card > button,
    .card > input + button,
    .card > textarea + button {
        max-width: 100%;
    }

    .gamesGrid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 11px;
        margin-top: 15px;
    }

    .gameCard {
        min-height: 210px;
        padding: 17px 12px;
        border-radius: 19px;
    }

    .gameCard h2 {
        margin-bottom: 8px;
        font-size: 17px;
    }

    .gameCard p {
        margin-bottom: 10px;
        font-size: 13px;
        line-height: 1.4;
    }

    .gameIcon {
        margin-bottom: 9px;
        font-size: 42px;
    }

    .playBtn {
        margin-top: 9px;
        padding: 9px 12px;
        font-size: 13px;
    }

    .studyButtons {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .studyButtons button {
        width: 100%;
        min-width: 0;
        min-height: 44px;
        padding: 10px 7px;
        font-size: 14px;
    }

    .flashcard {
        height: clamp(220px, 38vh, 300px);
        margin: 20px auto 16px;
    }

    #answers,
    #examAnswers {
        gap: 8px;
    }

    #answers button,
    #examAnswers button,
    #letters button {
        width: auto;
    }

    #answers .answerBtn,
    #examAnswers .answerBtn {
        width: 100%;
        min-height: 48px;
        font-size: 16px;
    }

    .statsGrid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .statCard {
        min-width: 0;
        padding: 16px 12px;
        border-radius: 16px;
        overflow-wrap: anywhere;
    }

    .statCard h1,
    .statNumber {
        font-size: 32px;
    }

    .word {
        align-items: stretch;
        gap: 9px;
        padding: 13px;
    }

    .wordButtons,
    .setButtons,
    .essayActions {
        display: flex;
        width: 100%;
        gap: 7px;
    }

    .wordButtons button,
    .setButtons button,
    .essayActions button {
        flex: 1 1 42%;
        min-width: 0;
        padding: 9px 7px;
        font-size: 13px;
    }

    #letters {
        gap: 7px;
        margin: 16px 0;
    }

    .letterBtn {
        width: 42px !important;
        min-width: 42px;
        height: 46px;
        padding: 7px;
        font-size: 20px;
    }

    .essayButtons {
        gap: 8px;
    }
}

@media (max-width: 380px) {
    .container {
        padding: 12px;
    }

    header {
        padding-right: 68px;
        padding-left: 0;
    }

    .menu button {
        font-size: 12px;
    }

    .gameCard {
        min-height: 196px;
        padding-right: 9px;
        padding-left: 9px;
    }

    .gameCard h2 {
        font-size: 15px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}