﻿*, *::before, *::after {
    box-sizing: border-box;
}

:root {
    --bg-1: #eef6ff;
    --bg-2: #dfe9ff;
    --bg-3: #c7d2fe;
    --primary: #4f46e5;
    --primary-dark: #312e81;
    --secondary: #7c3aed;
    --accent: #ff8a5b;
    --success: #10b981;
    --warning: #f59e0b;
    --text: #0f172a;
    --muted: #475569;
    --panel: rgba(255, 255, 255, 0.88);
    --panel-strong: rgba(255, 255, 255, 0.97);
    --border: rgba(148, 163, 184, 0.45);
    --shadow-soft: 0 20px 45px rgba(15, 23, 42, 0.12);
    --shadow-strong: 0 24px 55px rgba(79, 70, 229, 0.18);
}

html,
body {
    height: 100%;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background:
        radial-gradient(circle at 10% 10%, rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0) 30%),
        radial-gradient(circle at 85% 15%, rgba(96, 165, 250, 0.4), rgba(96, 165, 250, 0) 22%),
        radial-gradient(circle at 85% 75%, rgba(168, 85, 247, 0.2), rgba(168, 85, 247, 0) 26%),
        linear-gradient(135deg, var(--bg-1) 0%, var(--bg-2) 35%, var(--bg-3) 100%);
    color: var(--text);
    margin: 0;
    padding: 0;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(255,255,255,0.08) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.08) 1px, transparent 1px);
    background-size: 34px 34px;
    mask-image: radial-gradient(circle at center, black 30%, transparent 100%);
    opacity: 0.8;
}

.welcome-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(circle at 14% 18%, rgba(255, 255, 255, 0.42) 0%, rgba(255, 255, 255, 0) 42%),
        radial-gradient(circle at 86% 82%, rgba(251, 191, 36, 0.38) 0%, rgba(251, 191, 36, 0) 44%),
        linear-gradient(135deg, #e0f2fe 0%, #bfdbfe 28%, #93c5fd 56%, #fde68a 100%);
    opacity: 1;
    visibility: visible;
    transition: opacity 0.85s ease, visibility 0.85s ease;
}

.welcome-overlay.hide {
    opacity: 0;
    visibility: hidden;
}

.welcome-content {
    padding: 30px 36px;
    border-radius: 26px;
    background: rgba(255, 255, 255, 0.78);
    border: 1px solid rgba(147, 197, 253, 0.72);
    box-shadow: 0 26px 56px rgba(59, 130, 246, 0.22);
    backdrop-filter: blur(8px);
    text-align: center;
    animation: welcomePulse 1.8s ease-in-out infinite alternate;
}

.welcome-logo {
    position: relative;
    width: 108px;
    height: 108px;
    margin: 0 auto 10px;
}

.welcome-logo-img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: contain;
    background: #ffffff;
    border: 3px solid rgba(147, 197, 253, 0.9);
    box-shadow: 0 12px 20px rgba(37, 99, 235, 0.25);
    padding: 8px;
}

.corner-brand-logo {
    position: fixed;
    top: 18px;
    right: 18px;
    z-index: 1150;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    object-fit: contain;
    background: #ffffff;
    border: 2px solid rgba(191, 219, 254, 0.95);
    box-shadow: 0 10px 20px rgba(15, 23, 42, 0.16);
    padding: 4px;
    pointer-events: none;
}

.simple-book {
    position: absolute;
    left: 50%;
    top: 8px;
    transform: translateX(-50%);
    width: 108px;
    height: 70px;
}

.simple-book-page {
    position: absolute;
    top: 6px;
    width: 50px;
    height: 60px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    border: 2px solid #93c5fd;
    box-shadow: 0 10px 18px rgba(37, 99, 235, 0.2);
}

.simple-book-page.left {
    left: 0;
    border-radius: 14px 3px 10px 14px;
    transform: perspective(100px) rotateY(14deg);
}

.simple-book-page.right {
    right: 0;
    border-radius: 3px 14px 14px 10px;
    transform: perspective(100px) rotateY(-14deg);
}

.simple-book-spine {
    position: absolute;
    left: 50%;
    top: 8px;
    width: 10px;
    height: 60px;
    transform: translateX(-50%);
    border-radius: 6px;
    background: linear-gradient(180deg, #3b82f6 0%, #1d4ed8 100%);
    box-shadow: 0 6px 14px rgba(29, 78, 216, 0.25);
}

.welcome-brand {
    margin: 0;
    font-size: 1.02rem;
    font-weight: 800;
    color: #1d4ed8;
    letter-spacing: 0.2em;
    text-transform: uppercase;
}

.welcome-content h2 {
    margin: 8px 0 0;
    font-size: clamp(1.5rem, 3.8vw, 2.4rem);
    font-weight: 800;
    letter-spacing: 0.02em;
    color: #0f172a;
    text-shadow: 0 2px 12px rgba(255, 255, 255, 0.6);
}

.welcome-subtitle {
    margin: 10px 0 0;
    font-size: 1rem;
    font-weight: 600;
    color: #334155;
}

@keyframes welcomePulse {
    from {
        transform: translateY(0) scale(1);
    }
    to {
        transform: translateY(-4px) scale(1.015);
    }
}

.page-shell {
    position: relative;
    width: 100%;
    max-width: 1600px;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 24px;
    margin: 0 auto;
}

.page-shell::before {
    content: "";
    position: absolute;
    inset: 8% 8% auto auto;
    width: 260px;
    height: 260px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(79, 70, 229, 0.25), rgba(79, 70, 229, 0));
    filter: blur(28px);
    pointer-events: none;
}



.settings-content {
    max-width: 460px;
    width: min(100%, 460px);
    min-width: 320px;
    display: grid;
    grid-template-columns: repeat(2, minmax(120px, 1fr));
    gap: 12px 14px;
    padding: 20px 16px;
}

.setting-group {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.setting-group.full-width {
    grid-column: 1 / -1;
}

.setting-group label {
    margin-bottom: 0;
    white-space: normal;
    flex-shrink: 0;
}

.setting-group input[type="range"] {
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
}

.setting-group input[type="checkbox"] {
    margin-right: 8px;
}

.settings-about {
    grid-column: 1 / -1;
    margin: 0;
    text-align: left;
    color: #555;
    font-size: 0.92rem;
    line-height: 1.4;
}

.modal-buttons {
    grid-column: 1 / -1;
    display: flex;
    justify-content: center;
    gap: 14px;
}

.setting-group span {
    font-weight: 600;
}

.contact-link {
    margin-top: 16px;
    font-size: 1rem;
    color: #2563eb;
    cursor: pointer;
    text-decoration: underline;
}

.contact-link:hover {
    color: #1d4ed8;
}

.setting-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
}

.language-switch {
    display: flex;
    gap: 10px;
}

.lang-button {
    width: 50px;
    height: 50px;
    border-radius: 16px;
    border: none;
    background: transparent;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.flag-img {
    width: 42px;
    height: 28px;
    object-fit: cover;
    border-radius: 4px;
}

.lang-button:hover {
    transform: scale(1.05);
    background-color: rgba(59, 130, 246, 0.1);
}

.lang-button.active {
    box-shadow: inset 0 0 0 2px rgba(59, 130, 246, 0.4);
}

input[type="range"] {
    width: 100%;
    max-width: 200px;
}

.screen {
    overflow: visible;
    width: 100%;
    max-width: 1600px;
    margin: auto;
    padding: 26px 24px 28px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.96) 0%, rgba(247, 250, 255, 0.94) 100%);
    border: 1px solid var(--border);
    border-radius: 30px;
    box-shadow: var(--shadow-soft);
    display: flex;
    flex-direction: column;
    align-items: center;
    color: var(--text);
    backdrop-filter: blur(15px);
}

#results {
    position: relative;
    overflow: hidden;
}

.results-content {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 30px 0 10px;
    position: relative;
}

.results-card {
    width: min(100%, 820px);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(255, 255, 255, 0.88));
    border-radius: 36px;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.14);
    padding: 40px 30px;
    text-align: center;
    position: relative;
    z-index: 1;
}

.trophy {
    font-size: 5rem;
    margin-bottom: 18px;
}

.winner-text {
    font-size: 3rem;
    font-weight: 900;
    line-height: 1.05;
    letter-spacing: 0.08em;
    color: #111827;
    text-transform: uppercase;
    margin: 0 0 16px;
}

.scores-text {
    font-size: 1.1rem;
    color: #334155;
    margin-bottom: 24px;
    white-space: pre-wrap;
}

.confetti-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.confetti-piece {
    position: absolute;
    top: -8%;
    width: 10px;
    height: 20px;
    border-radius: 4px;
    opacity: 0.95;
    background: linear-gradient(135deg, #f59e0b, #f97316);
    animation: confetti-fall 3.6s linear infinite;
}

.confetti-piece:nth-child(2) {
    background: linear-gradient(135deg, #22c55e, #10b981);
    width: 8px;
}

.confetti-piece:nth-child(3) {
    background: linear-gradient(135deg, #3b82f6, #0ea5e9);
}

.confetti-piece:nth-child(4) {
    background: linear-gradient(135deg, #ec4899, #db2777);
    width: 8px;
}

.confetti-piece:nth-child(5) {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
}

.confetti-piece:nth-child(6) {
    background: linear-gradient(135deg, #facc15, #eab308);
}

.confetti-piece:nth-child(7) {
    background: linear-gradient(135deg, #14b8a6, #0d9488);
}

.confetti-piece:nth-child(8) {
    background: linear-gradient(135deg, #ec4899, #db2777);
}

@keyframes confetti-fall {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(110vh) rotate(720deg);
        opacity: 0.4;
    }
}

.hidden {
    display: none !important;
}

h1,
h2 {
    font-weight: 800;
    margin: 0 0 20px;
    text-shadow: 2px 2px 8px rgba(0, 0, 0, 0.12);
}

h1 {
    font-size: clamp(2.5rem, 4vw, 4rem);
    background: linear-gradient(90deg, #4f46e5 0%, #7c3aed 38%, #ec4899 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: glow 3s ease-in-out infinite alternate;
    letter-spacing: 0.03em;
}

@keyframes glow {
    from { filter: drop-shadow(0 0 10px rgba(74, 0, 224, 0.5)); }
    to { filter: drop-shadow(0 0 20px rgba(142, 45, 226, 0.8)); }
}

h2 {
    font-size: 2.1em;
    color: #1981f1;
}

button {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 52%, var(--accent) 100%);
    color: #fff;
    border: none;
    padding: 16px 28px;
    margin: 10px;
    border-radius: 18px;
    cursor: pointer;
    font-size: 1.05em;
    font-weight: 700;
    letter-spacing: 0.01em;
    transition: transform 0.25s ease, box-shadow 0.25s ease, filter 0.25s ease, opacity 0.25s ease;
    box-shadow: 0 12px 24px rgba(79, 70, 229, 0.22), inset 0 1px 0 rgba(255,255,255,0.45);
    position: relative;
    overflow: hidden;
}

button::before {
    content: "";
    position: absolute;
    top: 0;
    left: -25%;
    width: 55%;
    height: 100%;
    background: linear-gradient(120deg, rgba(255,255,255,0.0), rgba(255,255,255,0.4), rgba(255,255,255,0.0));
    transform: skewX(-20deg);
    transition: left 0.55s ease;
}

button:hover:not(:disabled) {
    transform: translateY(-3px) scale(1.01);
    box-shadow: 0 18px 34px rgba(79, 70, 229, 0.28), inset 0 1px 0 rgba(255,255,255,0.5);
    filter: brightness(1.04);
}

button:hover:not(:disabled)::before {
    left: 120%;
}

button:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.home-buttons,
.mode-buttons {
    display: flex;
    justify-content: center;
    gap: 16px;
    flex-wrap: wrap;
    width: 100%;
}

.kyrgyzstan-map-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    width: 100%;
    margin: 18px 0;
}

.region-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    color: #0f172a;
    border-radius: 18px;
    padding: 18px 16px;
    min-height: 170px;
    text-align: left;
    border: 2px solid rgba(59, 130, 246, 0.2);
}

.region-card.locked {
    filter: grayscale(0.35);
    background: linear-gradient(135deg, #e2e8f0 0%, #cbd5e1 100%);
    opacity: 0.75;
}

.region-card.unlocked {
    border-color: rgba(34, 197, 94, 0.4);
    background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
}

.region-card h3 {
    margin: 12px 0 8px;
    font-size: 1.08rem;
}

.region-card p,
.region-card small {
    margin: 4px 0;
    color: #1f2937;
}

.region-badge {
    display: inline-flex;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(59, 130, 246, 0.12);
    font-size: 0.72rem;
    font-weight: 700;
}

.map-view {
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 12px 0 8px;
}

.map-header-row {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.map-subtitle {
    margin: 6px 0 0;
    color: #475569;
    font-size: 0.96rem;
}

.kyrgyzstan-map-shell {
    position: relative;
    width: 100%;
    max-width: 980px;
    margin: 0 auto;
    border-radius: 24px;
    background: linear-gradient(180deg, #1d2b3a 0%, #24384d 100%);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.25);
    padding: 16px;
    overflow: hidden;
}

.kyrgyzstan-interactive-map {
    display: block;
    width: 100%;
    height: auto;
    background: #eaf2ff;
    border-radius: 18px;
}

.kg-region,
.kg-region-city {
    cursor: pointer;
    stroke: #ffffff;
    stroke-width: 2;
    fill: #2c3e50;
    transition: fill 0.3s ease, transform 0.3s ease, filter 0.3s ease;
    transform-origin: center;
}

.kg-region:hover,
.kg-region-city:hover {
    fill: #3498db;
    filter: brightness(1.08);
    transform: translateY(-1px);
}

.kg-region-city {
    fill: #e74c3c;
    animation: pulseBishkek 1.6s ease-in-out infinite;
    stroke: #ffffff;
    stroke-width: 2;
}

@keyframes pulseBishkek {
    0% {
        transform: scale(1);
        opacity: 1;
        filter: drop-shadow(0 0 0 rgba(231, 76, 60, 0.5));
    }
    50% {
        transform: scale(1.12);
        opacity: 0.9;
        filter: drop-shadow(0 0 10px rgba(231, 76, 60, 0.8));
    }
    100% {
        transform: scale(1);
        opacity: 1;
        filter: drop-shadow(0 0 0 rgba(231, 76, 60, 0.5));
    }
}

.map-region-info {
    width: 100%;
    max-width: 980px;
    margin: 18px auto 0;
}

.map-region-card {
    background: linear-gradient(135deg, #f8fbff 0%, #edf6ff 100%);
    border-radius: 26px;
    border: 1px solid rgba(147, 197, 253, 0.45);
    box-shadow: 0 18px 34px rgba(29, 78, 216, 0.10);
    padding: 18px 20px;
    color: #0f172a;
}

.map-region-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.map-region-card h4 {
    margin: 0 0 10px;
    font-size: 1.2rem;
}

.map-region-card p {
    margin: 8px 0;
    color: #334155;
}

.map-topic-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.map-topic-list span {
    display: inline-block;
    padding: 7px 10px;
    border-radius: 999px;
    background: rgba(96, 165, 250, 0.12);
    color: #1d4ed8;
    font-size: 0.76rem;
    font-weight: 700;
}

.region-badge.selected {
    background: rgba(37, 99, 235, 0.12);
    color: #1d4ed8;
}

.map-open-btn {
    margin-top: 12px;
    border: none;
    border-radius: 12px;
    background: #1d4ed8;
    color: white;
    font-weight: 700;
    padding: 10px 18px;
    cursor: pointer;
}

.kyrgyzstan-map-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    width: 100%;
    margin: 18px 0;
}

.region-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    color: #0f172a;
    border-radius: 18px;
    padding: 18px 16px;
    min-height: 170px;
    text-align: left;
    border: 2px solid rgba(59, 130, 246, 0.2);
}

.region-card h3 {
    margin: 12px 0 8px;
    font-size: 1.08rem;
}

.region-card p,
.region-card small {
    margin: 4px 0;
    color: #1f2937;
}

.map-region-info {
    width: 100%;
    max-width: 980px;
    margin: 0 auto;
}

.map-region-card {
    background: linear-gradient(135deg, #f8fbff 0%, #edf6ff 100%);
    border-radius: 26px;
    border: 1px solid rgba(147, 197, 253, 0.45);
    box-shadow: 0 18px 34px rgba(29, 78, 216, 0.10);
    padding: 18px 20px;
    color: #0f172a;
    animation: cardLift 0.35s ease;
}

.map-region-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.map-region-card h4 {
    margin: 0 0 10px;
    font-size: 1.2rem;
}

.map-region-card p {
    margin: 8px 0;
    color: #334155;
}

.map-topic-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.map-topic-list span {
    display: inline-block;
    padding: 7px 10px;
    border-radius: 999px;
    background: rgba(96, 165, 250, 0.12);
    color: #1d4ed8;
    font-size: 0.76rem;
    font-weight: 700;
}

.region-badge.selected {
    background: rgba(37, 99, 235, 0.12);
    color: #1d4ed8;
}

@keyframes mapFloat {
    from {
        transform: translateY(0) scale(1);
    }
    to {
        transform: translateY(-4px) scale(1.006);
    }
}

@keyframes cardLift {
    from {
        opacity: 0.7;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.section-divider {
    width: 100%;
    height: 1px;
    background: rgba(148, 163, 184, 0.5);
    margin: 16px 0;
}

.region-description {
    margin-top: 0;
    color: #334155;
    text-align: center;
}

.region-subject-card {
    min-height: 160px;
}

.form-row {
    display: flex;
    justify-content: center;
    gap: 20px;
    width: 80%;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.selects-row.hidden {
    display: none;
}

select,
input[type="text"],
input[type="password"] {
    width: 400px;
    max-width: calc(50% - 20px);
    min-width: 260px;
    padding: 16px 18px;
    border: 1.5px solid rgba(148, 163, 184, 0.8);
    border-radius: 16px;
    font-size: 1.02em;
    background: rgba(255, 255, 255, 0.92);
    transition: border-color 0.25s ease, box-shadow 0.25s ease, transform 0.25s ease;
}

.player-name {
    width: 500px;
    max-width: calc(50% - 20px);
    min-width: 300px;
}

select:focus,
input[type="text"]:focus,
input[type="password"]:focus {
    outline: none;
    border-color: #4a00e0;
    box-shadow: 0 0 15px rgba(74, 0, 224, 0.25);
}

.game-top-row {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.current-theme {
    width: 100%;
    text-align: center;
    margin-bottom: 20px;
    font-size: 1rem;
    color: #555;
}

#game {
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    overflow-x: hidden;
    width: 100%;
}

.exit-button {
    background: linear-gradient(135deg, #ff0000 0%, #0000ff 100%);
    color: white;
    border: none;
    padding: 12px 22px;
    border-radius: 16px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.18);
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.modal-content {
    background: #ffffff;
    border-radius: 24px;
    padding: 32px;
    max-width: 420px;
    width: 100%;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}

.teacher-request-content {
    max-width: 760px;
    max-height: min(84vh, 760px);
    overflow-y: auto;
    text-align: left;
}

.teacher-request-content h3 {
    margin-top: 0;
    margin-bottom: 14px;
    color: #0f172a;
}

.teacher-request-content ol {
    margin: 0;
    padding-left: 22px;
    color: #334155;
    line-height: 1.55;
}

.teacher-request-content li {
    margin-bottom: 10px;
}

.teacher-request-content p {
    margin: 8px 0 0;
}

.modal-content p {
    font-size: 1.2em;
    color: #333;
    margin-bottom: 24px;
}

.modal-buttons {
    display: flex;
    justify-content: center;
    gap: 16px;
    flex-wrap: wrap;
}

.modal button {
    width: 120px;
    padding: 14px 0;
}

.project-source-tag {
    display: inline-flex;
    align-items: center;
    margin-top: 6px;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 700;
}

.project-source-custom {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #86efac;
}

.project-source-builtin {
    background: #dbeafe;
    color: #1e3a8a;
    border: 1px solid #93c5fd;
}

.players-grid {
    width: 100%;
    display: flex;
    gap: 20px;
    align-items: stretch;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 12px;
    min-height: auto;
    overflow-y: auto;
}

.player {
    flex: 0 0 300px;
    max-width: 300px;
    background: #ffffff;
    border: 2px solid #e2e8f0;
    border-radius: 28px;
    padding: 20px 16px;
    box-shadow: 0 18px 45px rgba(15, 23, 42, 0.09);
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
}

.player h3 {
    font-size: 1.45em;
    margin: 0 0 14px;
    text-align: center;
    color: #111827;
}

.tubes-center {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 16px;
    flex: 0 0 auto;
}

.racing-track-wrap {
    width: min(100%, 520px);
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 14px;
    border-radius: 20px;
    border: 1px solid #dbeafe;
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
    box-shadow: 0 12px 26px rgba(15, 23, 42, 0.08);
}

.race-lane {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.race-lane-label {
    font-weight: 700;
    color: #0f172a;
    font-size: 0.92rem;
}

.race-road {
    position: relative;
    height: 52px;
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid #bfdbfe;
    background:
        repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.16) 0 18px, rgba(255, 255, 255, 0.02) 18px 36px),
        linear-gradient(180deg, #334155 0%, #1f2937 100%);
}

.race-progress {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, rgba(59, 130, 246, 0.24), rgba(14, 165, 233, 0.35));
    transition: width 0.45s ease;
}

.race-finish {
    position: absolute;
    top: 0;
    right: 0;
    width: 24px;
    height: 100%;
    background:
        linear-gradient(45deg, #ffffff 25%, #111827 25%, #111827 50%, #ffffff 50%, #ffffff 75%, #111827 75%, #111827 100%);
    background-size: 14px 14px;
}

.race-car {
    position: absolute;
    top: 50%;
    left: 4px;
    transform: translateX(0);
    translate: 0 -50%;
    font-size: 1.5rem;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.35));
    transition: transform 0.45s ease;
    z-index: 2;
}

.tube-card {
    width: 120px;
    padding: 18px 14px;
    background: #f8fafc;
    border: 1px solid #dbeafe;
    border-radius: 24px;
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.08);
}

.tube-label {
    text-align: center;
    font-size: 0.95rem;
    margin-bottom: 14px;
    color: #334155;
    font-weight: 700;
}

.tube-status {
    width: 100%;
    height: 250px;
    background: #e2e8f0;
    border-radius: 18px;
    overflow: hidden;
    display: flex;
    justify-content: flex-end;
    align-items: flex-end;
}

.tube-track {
    width: 100%;
    height: 100%;
    position: relative;
}

.tube-fill {
    width: 100%;
    background: linear-gradient(180deg, #34d399, #10b981);
    border-radius: 18px 18px 0 0;
    position: absolute;
    bottom: 0;
}

.question-text {
    width: 100%;
    min-height: 90px;
    padding: 12px 12px;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1), rgba(248, 250, 252, 0.95));
    border-radius: 20px;
    margin: 0 0 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 1.05em;
    line-height: 1.3;
    color: #111827;
}

.answers {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.learning-step-view .practice-choice {
    min-height: 52px;
    padding: 13px 14px;
    border-radius: 12px;
    font-size: 1rem;
    line-height: 1.35;
    touch-action: manipulation;
}

.learning-step-view #practiceResponse,
.learning-step-view #practiceInput {
    min-height: 48px;
    font-size: 16px;
}

.answer {
    width: 100%;
    min-height: 44px;
    padding: 10px 16px;
    background-color: #f8fafc;
    border: 2px solid #e2e8f0;
    border-radius: 18px;
    font-size: 1em;
    font-weight: 700;
    color: #111827;
    cursor: pointer;
    transition: transform 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
    text-align: left;
    line-height: 1.4;
    word-break: break-word;
}

.answer:hover {
    background-color: #eef2ff;
    transform: translateY(-1px);
    border-color: #4338ca;
}

.answer.correct {
    background-color: #16a34a;
    color: #ffffff;
    border-color: #16a34a;
}

.answer.incorrect {
    background-color: #dc2626;
    color: #ffffff;
    border-color: #dc2626;
}

#timer {
    font-size: 2.2em;
    font-weight: 800;
    margin-bottom: 16px;
    color: #2563eb;
}

.progress-container {
    display: none;
}

@media (max-width: 1200px) {
    /* .players-grid {
        flex-direction: column;
        align-items: center;
    } */

    .player {
        max-width: 760px;
        width: 100%;
    }
}

@media (max-width: 820px) {
    .player {
        min-width: auto;
        padding: 18px 18px;
    }

    .question-text {
        min-height: 160px;
        font-size: 1.18em;
    }

    .answer {
        min-height: 60px;
        font-size: 1.05em;
        padding: 16px 18px;
    }

    .racing-track-wrap {
        width: 100%;
        max-width: 100%;
        padding: 12px;
    }

    .race-road {
        height: 48px;
    }
}

.tug-rope {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 4px;
    height: 48px;
    background-color: #000;
    transition: left 0.8s ease;
}

.question-block {
    width: 100%;
    border: 3px solid #ddd;
    padding: 24px;
    margin-bottom: 24px;
    border-radius: 22px;
    background-color: rgba(255, 255, 255, 0.95);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

.question-block input[type="text"] {
    width: 100%;
    margin-bottom: 14px;
    border: 2px solid #ccc;
    border-radius: 14px;
    padding: 14px 16px;
    font-size: 1em;
}

.assignment-deadline-row {
    justify-content: center;
}

.assignment-deadline-card {
    width: 100%;
    max-width: 520px;
    padding: 18px 18px 16px;
    border-radius: 18px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(241, 245, 249, 0.98) 100%);
    border: 2px solid rgba(59, 130, 246, 0.18);
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
    display: block;
}

.assignment-deadline-card label {
    display: block;
    margin-bottom: 10px;
    font-weight: 700;
    color: #1f2937;
}

.assignment-deadline-card input[type="date"] {
    width: 100%;
    min-width: 0;
    padding: 14px 16px;
    border-radius: 14px;
    border: 2px solid #cbd5e1;
    background: #fff;
    color: #0f172a;
    font-size: 1rem;
}

.assignment-deadline-card input[type="date"]:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.12);
}

.assignment-deadline-note {
    margin: 10px 0 0;
    color: #475569;
    font-size: 0.92rem;
    line-height: 1.45;
}

#assignmentsScreen {
    padding-top: 88px;
}

#assignmentForm {
    width: 100%;
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
}

#assignmentForm .form-row {
    width: 100%;
}

#assignmentForm select,
#assignmentForm input[type="date"] {
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

#assignmentsList {
    width: 100%;
    max-width: 900px;
}

.correct-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    font-size: 0.95em;
}

.correct-row input {
    margin-right: 8px;
}

.contact-link {
    position: fixed;
    bottom: 20px;
    right: 20px;
    font-size: 0.9em;
    color: #4a00e0;
    text-decoration: underline;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    z-index: 50;
}

.contact-link:hover {
    color: #8e2de2;
    transform: scale(1.1);
}

.projects-list {
    width: 100%;
    max-width: 800px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 30px;
}

.notification-window {
    max-height: min(70vh, 560px);
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.notification-window::-webkit-scrollbar {
    width: 0;
    height: 0;
}

/* Adaptive layout safety net for containers, media and overflow */
* {
    box-sizing: border-box;
}

img,
svg,
video,
canvas,
iframe {
    max-width: 100%;
    height: auto;
}

table {
    width: 100%;
    max-width: 100%;
    border-collapse: collapse;
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.page-shell,
.screen,
.projects-list,
.profile-card,
.about-card,
.class-panel,
.question-block,
.modal-content,
.results-card,
.homework-card,
.homework-results-card,
.auth-card,
.settings-content,
.video-tutorial-content,
.teacher-request-content {
    width: 100%;
    min-width: 0;
}

.screen {
    max-width: min(1200px, 100%);
    margin-left: auto;
    margin-right: auto;
}

.projects-list,
.profile-card,
.about-card,
.class-panel,
.question-block,
.homework-card,
.auth-card,
.modal-content,
.teacher-request-content,
.notification-window {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.form-row > *,
.project-item > *,
.class-item > *,
.notification-item > * {
    min-width: 0;
}

.project-info,
.notification-item,
.class-item,
.question-text,
.homework-question-text,
p,
h1,
h2,
h3,
h4,
button,
label,
td,
th {
    overflow-wrap: anywhere;
    word-break: break-word;
}

button {
    max-width: 100%;
    white-space: normal;
}

@media (max-width: 768px) {
    body {
        align-items: flex-start;
    }

    .page-shell {
        width: 100%;
        max-width: 100%;
        padding: calc(12px + env(safe-area-inset-top)) 10px calc(12px + env(safe-area-inset-bottom));
    }

    .screen,
    .projects-list,
    .profile-card,
    .about-card,
    .class-panel,
    .question-block,
    .homework-card,
    .auth-card,
    .modal-content,
    .video-tutorial-content,
    .settings-content,
    .teacher-request-content {
        width: 100%;
        max-width: 100%;
    }

    .screen {
        padding: 14px 12px;
        border-radius: 18px;
    }

    .class-panel {
        min-width: 0;
        flex-basis: 100%;
    }

    .home-buttons,
    .mode-buttons,
    .project-buttons,
    .notification-actions {
        width: 100%;
    }

    button,
    .project-buttons button,
    .start-homework-btn,
    .accept-request-btn,
    .reject-request-btn,
    .accept-profile-change-btn,
    .reject-profile-change-btn {
        width: 100%;
    }

    select,
    input[type="text"],
    input[type="password"],
    textarea,
    .player-name {
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }

    #assignmentsScreen {
        padding-top: 14px;
    }

    .learning-step-view {
        padding: 11px;
        border-radius: 12px;
    }

    .learning-step-top {
        align-items: flex-start;
        flex-direction: column;
        gap: 6px;
    }

    .learning-step-top h3 {
        margin: 0;
        font-size: 1.05rem;
        line-height: 1.25;
    }

    .subject-card-grid,
    .path-map,
    .learning-lesson-grid {
        grid-template-columns: 1fr;
    }

    .answers {
        gap: 8px;
    }

    .learning-step-view .practice-choice {
        min-height: 56px;
        padding: 14px 12px;
        font-size: 16px;
    }

    .learning-flow-root,
    .learning-workspace {
        min-width: 0;
    }
}

.project-item {
    background: linear-gradient(180deg, rgba(255,255,255,0.96), rgba(248,250,252,0.96));
    border: 1px solid rgba(148, 163, 184, 0.5);
    border-radius: 18px;
    padding: 18px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
    transition: all 0.3s ease;
}

.project-item:hover {
    border-color: rgba(79, 70, 229, 0.5);
    box-shadow: 0 14px 28px rgba(79, 70, 229, 0.12);
    transform: translateY(-2px);
}

.project-info {
    flex: 1;
    color: #333;
    font-weight: 500;
}

.project-buttons {
    display: flex;
    gap: 12px;
}

.project-buttons button {
    padding: 10px 16px;
    font-size: 0.9em;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
}

.project-open {
    background: linear-gradient(135deg, #4ecdc4, #44b7b5);
    color: white;
}

.project-open:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(78, 205, 196, 0.3);
}

.project-delete {
    background: linear-gradient(135deg, #ff6b6b, #ff4757);
    color: white;
}

.project-report {
    background: linear-gradient(135deg, #f59e0b, #f97316);
    color: #fff;
}

.project-report:hover {
    transform: scale(1.05);
}

.project-delete:hover {
    transform: scale(1.05);
}

.contact-info {
    font-size: 1.1em;
    color: #333;
    margin: 12px 0;
    letter-spacing: 0.5px;
}

@media(max-width: 1040px) {
    .players-grid {
        flex-direction: column;
    }

    select,
    input[type="text"] {
        width: 100%;
        max-width: 100%;
    }
}

#videoTutorial {
    display: flex;
}

#videoTutorial.hidden {
    display: none !important;
}

.video-tutorial-content {
    text-align: center;
    padding: 40px 30px;
    max-width: 600px;
    width: 100%;
}

#videoMessage {
    font-size: 1.3em;
    color: #334155;
    margin-bottom: 32px;
    line-height: 1.5;
}

.video-buttons {
    display: flex;
    flex-direction: column;
    gap: 16px;
    justify-content: center;
}

.video-button {
    background: linear-gradient(45deg, #4f46e5, #7c3aed);
    font-size: 1.1em;
}

.video-button:hover:not(:disabled) {
    background: linear-gradient(45deg, #4f46e5, #6d28d9);
}

.menu-button {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 1100;
    width: 52px;
    height: 52px;
    border-radius: 18px;
    border: 2px solid rgba(255, 255, 255, 0.9);
    background: rgba(255, 255, 255, 0.98);
    color: #333;
    font-size: 1.8rem;
    cursor: pointer;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.18);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 0;
}

.notification-bell {
    position: fixed;
    top: 21px;
    left: 84px;
    z-index: 1100;
    width: 46px;
    height: 46px;
    border-radius: 16px;
    border: 2px solid rgba(255, 255, 255, 0.9);
    background: rgba(255, 255, 255, 0.98);
    color: #111827;
    font-size: 1.35rem;
    cursor: pointer;
    box-shadow: 0 14px 28px rgba(0, 0, 0, 0.14);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.notification-bell.hidden {
    display: none;
}

.notification-bell::after {
    content: '';
    position: absolute;
    top: 7px;
    right: 7px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ef4444;
    box-shadow: 0 0 0 2px #ffffff;
}

.menu-dots {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 5px;
    width: 24px;
    height: 10px;
    line-height: 0;
    transform: translateY(-1px);
}

.menu-dot {
    display: block;
    width: 6px;
    height: 6px;
    background: #111827;
    border-radius: 50%;
    box-shadow: 0 0 0 1px rgba(17, 24, 39, 0.04);
    flex-shrink: 0;
}

.sideBar-hidden {
    display: none;
}

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: min(320px, 85vw);
    height: 100%;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 20px 0 45px rgba(15, 23, 42, 0.16);
    z-index: 1200;
    padding: 24px 18px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    transform: translateX(-120%);
    transition: transform 0.25s ease;
    border-right: 1px solid rgba(148, 163, 184, 0.55);
}

.sidebar.hidden {
    transform: translateX(-120%);
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
}

.sidebar:not(.hidden) {
    transform: translateX(0);
    pointer-events: auto;
    opacity: 1;
    visibility: visible;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.sidebar-header h3 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
    color: #111827;
    line-height: 1.2;
}

.close-menu {
    width: 34px !important;
    height: 34px !important;
    min-width: 34px !important;
    min-height: 34px !important;
    border-radius: 50%;
    border: 1px solid #cbd5e1;
    background: #f8fafc;
    font-size: 1.05rem;
    font-weight: 700;
    color: #334155;
    cursor: pointer;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 !important;
    margin: 0 !important;
}

.close-menu:hover {
    background: #eef2ff;
    border-color: #93c5fd;
}

.menu-items {
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
    padding-right: 4px;
}

.menu-link,
.sidebar-action {
    display: block;
    width: 100%;
    padding: 14px 18px;
    border-radius: 16px;
    border: 1px solid rgba(148, 163, 184, 0.55);
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    color: #111827;
    font-weight: 700;
    text-align: left;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.menu-link:hover,
.sidebar-action:hover {
    background: linear-gradient(180deg, #eff6ff 0%, #e0e7ff 100%);
    border-color: rgba(79, 70, 229, 0.45);
    transform: translateX(2px);
    box-shadow: 0 10px 18px rgba(79, 70, 229, 0.08);
}

.sidebar-footer {
    margin-top: auto;
}

.profile-card,
.about-card,
.class-panel,
.question-block {
    width: 100%;
    background: rgba(255, 255, 255, 0.98);
    border-radius: 24px;
    box-shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
    padding: 24px;
    color: #111827;
}

.profile-card p,
.about-card p {
    margin: 14px 0;
    line-height: 1.6;
}

.empty-state {
    text-align: center;
    color: #9ca3af;
    font-size: 0.95rem;
    padding: 40px 20px;
    margin: 20px 0;
}

.profile-info {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.profile-info p {
    margin: 0;
    font-size: 1rem;
}

.profile-edit-note {
    margin: 8px 0 0;
    color: #64748b;
    font-size: 0.92rem;
    text-align: center;
}

.profile-info strong {
    color: #111827;
    margin-right: 8px;
}

.notification-item,
.class-item {
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    position: relative;
}

.notification-item.unread {
    border-color: #fecaca;
    background: #fffafa;
}

.notification-dot {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ef4444;
    box-shadow: 0 0 0 2px #ffffff;
}

.notification-item h4,
.class-item h4 {
    margin: 0 0 8px 0;
    color: #111827;
    font-size: 1.05rem;
}

.notification-item p,
.class-item p {
    margin: 0;
    color: #6b7280;
    font-size: 0.95rem;
}

.class-chip {
    display: inline-flex;
    align-items: center;
    margin: 4px 6px 4px 0;
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid #93c5fd;
    background: #eff6ff;
    color: #1e40af;
    font-weight: 700;
    font-size: 0.9rem;
}

.class-student-item {
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 8px;
}

.class-student-item span {
    color: #64748b;
    font-size: 0.9rem;
}

.class-item-rich {
    border-radius: 16px;
    border: 1px solid #c7d2fe;
    background: linear-gradient(180deg, #ffffff 0%, #f7f9ff 100%);
}

.class-student-extended {
    border-radius: 12px;
    padding: 12px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
}

.class-student-extended strong {
    display: block;
    color: #0f172a;
}

.class-student-extended p {
    margin: 6px 0 0;
}

.class-meta-banner {
    border: 1px dashed #93c5fd;
    border-radius: 12px;
    background: #eff6ff;
    padding: 10px;
    margin-bottom: 10px;
}

.class-meta-banner p {
    margin: 4px 0;
    color: #1e3a8a;
}

.class-grid {
    display: flex;
    gap: 20px;
    width: 100%;
    flex-wrap: wrap;
    justify-content: center;
}

.class-panel {
    flex: 1 1 360px;
    min-width: 320px;
}

textarea {
    width: 100%;
    padding: 16px 18px;
    border-radius: 18px;
    border: 2px solid #d1d5db;
    resize: vertical;
    font-size: 1rem;
    margin-bottom: 18px;
}

.notification-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
}

.start-homework-btn {
    padding: 10px 16px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: #ffffff;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 10px 20px rgba(37, 99, 235, 0.18);
}

.start-homework-btn:hover:not(:disabled) {
    transform: translateY(-1px);
}

.start-homework-btn:disabled {
    background: #cbd5e1;
    color: #64748b;
    box-shadow: none;
}

.teacher-feedback-actions {
    flex-wrap: wrap;
}

.teacher-feedback-btn {
    padding: 8px 12px;
    border: 1px solid #bfdbfe;
    border-radius: 10px;
    background: #eff6ff;
    color: #1e3a8a;
    font-weight: 700;
    cursor: pointer;
}

.practice-choice.is-correct {
    border-color: #16a34a;
    background-color: #dcfce7;
    color: #166534;
}

.practice-choice.is-incorrect {
    border-color: #dc2626;
    background-color: #fee2e2;
    color: #991b1b;
}

.teacher-feedback-btn:hover {
    background: #dbeafe;
}

.teacher-feedback-input {
    flex: 1 1 220px;
    min-width: 200px;
    padding: 8px 10px;
    border: 1px solid #bfdbfe;
    border-radius: 10px;
    background: #ffffff;
    color: #1e293b;
}

.teacher-feedback-send {
    padding: 8px 12px;
    border: 1px solid #93c5fd;
    border-radius: 10px;
    background: #2563eb;
    color: #ffffff;
    font-weight: 700;
    cursor: pointer;
}

.teacher-feedback-send:hover {
    background: #1d4ed8;
}

.homework-top-row {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 18px;
}

.homework-top-row h2 {
    margin: 0 0 4px;
}

.homework-card {
    width: 100%;
    background: rgba(255, 255, 255, 0.98);
    border-radius: 24px;
    box-shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
    padding: 24px;
    color: #111827;
}

.homework-card-actions {
    width: 100%;
    display: flex;
    justify-content: flex-end;
    margin-bottom: 12px;
}

.homework-question-number {
    color: #64748b;
    font-weight: 700;
    margin-bottom: 10px;
}

.homework-question-text {
    font-size: 1.25rem;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 18px;
    line-height: 1.5;
}

.homework-answers {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.homework-answer {
    min-height: 64px;
    padding: 14px 16px;
    border-radius: 16px;
    border: 2px solid #dbeafe;
    background: linear-gradient(180deg, #ffffff 0%, #eff6ff 100%);
    color: #0f172a;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.homework-answer:hover:not(:disabled) {
    transform: translateY(-1px);
    border-color: #60a5fa;
    box-shadow: 0 10px 22px rgba(59, 130, 246, 0.14);
}

.homework-answer.correct {
    background: linear-gradient(180deg, #ecfdf5 0%, #d1fae5 100%);
    border-color: #34d399;
}

.homework-answer.incorrect {
    background: linear-gradient(180deg, #fef2f2 0%, #fee2e2 100%);
    border-color: #f87171;
}

.homework-answer:disabled {
    cursor: not-allowed;
    opacity: 0.88;
}

.homework-feedback {
    min-height: 24px;
    margin-top: 16px;
    font-weight: 700;
    color: #334155;
}

.homework-results-card {
    max-width: 620px;
}

.accept-request-btn,
.reject-request-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.accept-profile-change-btn,
.reject-profile-change-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.accept-request-btn {
    background: #10b981;
    color: white;
}

.accept-profile-change-btn {
    background: #10b981;
    color: white;
}

.accept-request-btn:hover {
    background: #059669;
}

.accept-profile-change-btn:hover {
    background: #059669;
}

.reject-request-btn {
    background: #ef4444;
    color: white;
}

.reject-profile-change-btn {
    background: #ef4444;
    color: white;
}

.reject-request-btn:hover {
    background: #dc2626;
}

.reject-profile-change-btn:hover {
    background: #dc2626;
}



.modal-note,
.note-block {
    font-size: 0.95rem;
    color: #4b5563;
    margin-top: 12px;
    text-align: left;
}

.note-block {
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 18px;
    padding: 14px 16px;
}

.register-role-row {
    display: flex;
    gap: 16px;
    justify-content: center;
    flex-wrap: wrap;
}

.register-role-row label {
    cursor: pointer;
    font-weight: 700;
    color: #334155;
}

.auth-screen {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 80px);
    padding: 20px;
    background: linear-gradient(180deg, #f8fafc 0%, #eef2ff 100%);
}
.auth-card {
    width: min(860px, 100%);
    background: #ffffff;
    border-radius: 24px;
    box-shadow: 0 24px 48px rgba(15, 23, 42, 0.12);
    padding: 28px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.filter-modal-content {
    width: min(92vw, 520px);
    max-width: 520px;
}

.assignment-wizard-modal {
    width: min(94vw, 820px);
    max-width: 820px;
    max-height: min(86vh, 760px);
    overflow-y: auto;
    text-align: left;
}

.assignment-step h3 {
    margin-top: 0;
    color: #0f172a;
}

.wizard-subtitle {
    margin: 0 0 12px;
    color: #475569;
    font-size: 0.95rem;
}

.wizard-theme-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.wizard-theme-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    width: 100%;
    padding: 14px 16px;
    border: 1px solid #d1fae5;
    border-radius: 14px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fffb 100%);
    cursor: pointer;
    box-shadow: 0 8px 18px rgba(34, 197, 94, 0.08);
    color: #0f172a;
    text-align: left;
}

.wizard-theme-card:hover {
    border-color: #34d399;
    box-shadow: 0 10px 22px rgba(34, 197, 94, 0.14);
    transform: translateY(-1px);
}

.wizard-theme-card.active {
    border-color: #22c55e;
    background: linear-gradient(180deg, #ecfdf5 0%, #d1fae5 100%);
}

.wizard-theme-info {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
    min-width: 0;
}

.wizard-theme-title {
    font-size: 1rem;
    font-weight: 800;
}

.wizard-theme-meta {
    font-size: 0.85rem;
    color: #475569;
}

.wizard-theme-source {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
}

.wizard-theme-source.custom {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #86efac;
}

.wizard-theme-source.builtin {
    background: #dbeafe;
    color: #1e3a8a;
    border: 1px solid #93c5fd;
}

.theme-select-action {
    background: linear-gradient(180deg, #22c55e 0%, #16a34a 100%);
    color: #ffffff;
    border: none;
    border-radius: 10px;
    padding: 9px 16px;
    min-width: 110px;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    box-shadow: 0 6px 12px rgba(34, 197, 94, 0.22);
    transition: all 0.2s ease;
}

.theme-select-action:hover {
    transform: translateY(-1px);
    filter: brightness(1.03);
}

.auth-card h2 {
    margin: 0;
    font-size: 2rem;
    color: #111827;
}
.auth-note {
    color: #475569;
    line-height: 1.6;
}
.auth-card .form-row {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-start;
    gap: 14px;
    width: 100%;
    margin-bottom: 20px;
}

.auth-card input[type="text"],
.auth-card input[type="password"],
.auth-card select {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    height: 45px;
    padding: 0 15px;
    border-radius: 12px;
    border: 1px solid #d1d5db;
    box-sizing: border-box;
    flex: none;
    line-height: 1.2;
}
.radio-label {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    color: #1f2937;
}
.form-error {
    color: #b91c1c;
    background: rgba(248, 113, 113, 0.12);
    border: 1px solid rgba(220, 38, 38, 0.2);
    padding: 10px 14px;
    border-radius: 12px;
}
.input-with-hint {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
    max-width: 100%;
    margin-bottom: 0;
}
.input-with-hint input {
    width: 100%;
    min-height: 45px;
    height: 45px;
    padding: 0 15px;
    border-radius: 12px;
    box-sizing: border-box;
}
.field-hint {
    display: block;
    font-size: 0.72rem;
    line-height: 1.45;
    color: #64748b;
    margin-top: 0;
    transition: color 0.2s ease;
}
.field-hint-error {
    color: #dc2626;
    font-weight: 600;
}
.input-invalid {
    border-color: #dc2626 !important;
    box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.12);
}
.register-step {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

#registerStep1,
#registerStep2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    width: 100%;
}

#registerStep1 > *,
#registerStep2 > * {
    grid-column: 1 / -1;
}

#registerAuthFields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    width: 100%;
}

#registerAuthFields .form-row {
    margin-bottom: 0;
}

#registerAuthFields .form-row:last-child {
    grid-column: 1 / -1;
}

#teacherFields,
#studentFields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    width: 100%;
}

#teacherFields > *,
#studentFields > * {
    grid-column: 1 / -1;
}

#teacherFields .form-row,
#studentFields .form-row {
    margin-bottom: 0;
}

#registerTeacherClassesList {
    grid-column: 1 / -1;
}

#teacherFields .form-row:nth-of-type(2),
#studentFields .form-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
}

.agreement-row {
    align-items: flex-start !important;
    gap: 10px !important;
    background: #f8fbff;
    border: 1px solid #dbeafe;
    border-radius: 14px;
    padding: 10px 12px;
}

.agreement-row input[type="checkbox"] {
    margin-top: 4px;
}

.agreement-row label {
    color: #334155;
    line-height: 1.45;
    font-size: 0.92rem;
}

.agreement-row a {
    color: #1d4ed8;
    text-decoration: underline;
}

.registration-consents {
    display: grid;
    gap: 8px;
    background: #f8fbff;
    border: 1px solid #dbeafe;
    border-radius: 14px;
    padding: 10px 12px;
}

.registration-consents label {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    color: #334155;
    line-height: 1.45;
    font-size: 0.92rem;
}

.registration-consents input[type="checkbox"] {
    flex: 0 0 auto;
    margin-top: 4px;
}

.registration-consents a {
    color: #1d4ed8;
    text-decoration: underline;
}

.gov-stat-card,
.gov-school-open {
    appearance: none;
    width: 100%;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.gov-stat-card:hover,
.gov-school-open:hover {
    border-color: #60a5fa;
    box-shadow: 0 8px 18px rgba(37, 99, 235, 0.12);
}

.gov-details-modal-content {
    max-width: 760px;
    max-height: min(84vh, 780px);
    overflow-y: auto;
    text-align: left;
}

#govSchoolNoticeText {
    width: 100%;
    margin-top: 8px;
    resize: vertical;
}

.legal-modal-content {
    max-width: 760px;
    max-height: min(84vh, 760px);
    overflow-y: auto;
    text-align: left;
}

.legal-modal-content h3 {
    margin-top: 0;
    color: #0f172a;
}

.settings-contact-btn {
    margin-top: 10px;
    text-align: center;
}

#achievementsSummary {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 12px;
}

.learning-shell {
    width: 100%;
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 16px;
}

.learning-flow-root {
    width: 100%;
}

.learning-step-view {
    width: 100%;
    border: 1px solid #dbeafe;
    border-radius: 16px;
    background: #ffffff;
    padding: 14px;
}

.learning-step-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.subject-card-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.subject-card {
    text-align: left;
    border: 1px solid #bfdbfe;
    border-radius: 14px;
    background: linear-gradient(180deg, #ffffff 0%, #eff6ff 100%);
    padding: 12px;
    color: #0f172a;
    box-shadow: 0 10px 22px rgba(37, 99, 235, 0.1);
}

.subject-card h3 {
    margin: 0 0 6px;
    color: #1e3a8a;
}

.subject-card p {
    margin: 4px 0;
    color: #334155;
    font-size: 0.92rem;
}

.path-map {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.path-node {
    display: grid;
    grid-template-columns: 44px 1fr;
    gap: 8px;
    align-items: center;
    text-align: left;
    border-radius: 14px;
    border: 1px solid #cbd5e1;
    background: #f8fafc;
    color: #0f172a;
    padding: 10px;
}

.path-node .path-index {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #dbeafe;
    color: #1d4ed8;
    font-weight: 800;
}

.path-node .path-topic {
    font-weight: 700;
}

.path-node .path-status {
    grid-column: 2;
    color: #475569;
    font-size: 0.84rem;
}

.path-node.done {
    border-color: #86efac;
    background: linear-gradient(180deg, #ecfdf5 0%, #f0fdf4 100%);
}

.path-node.locked {
    opacity: 0.72;
    cursor: not-allowed;
}

.learning-list {
    margin: 0;
    padding-left: 20px;
    color: #334155;
}

.ilbirs-inline-tip {
    margin: 12px 0;
    border-radius: 12px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1e3a8a;
    padding: 10px;
    font-weight: 600;
}

.match-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.match-row {
    display: grid;
    grid-template-columns: 1fr 180px;
    gap: 8px;
    align-items: center;
}

.match-row select {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding: 10px 12px;
    border-radius: 12px;
    border: 2px solid #cbd5e1;
}

.learning-subjects {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.learning-subject-btn.active {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: #fff;
}

.learning-workspace {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.learning-header {
    background: linear-gradient(180deg, #ffffff 0%, #f1f7ff 100%);
    border: 1px solid #dbeafe;
    border-radius: 16px;
    padding: 14px;
}

.module-progress {
    width: 100%;
    height: 10px;
    border-radius: 999px;
    background: #e2e8f0;
    overflow: hidden;
}

.module-progress span {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, #22c55e 0%, #16a34a 100%);
}

.learning-part-title {
    margin: 8px 0 4px;
    color: #1e293b;
}

.learning-lesson-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.learning-lesson-card {
    border: 1px solid #dbeafe;
    border-radius: 14px;
    background: #fff;
    padding: 12px;
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.learning-lesson-card.done {
    border-color: #86efac;
    background: linear-gradient(180deg, #ecfdf5 0%, #f0fdf4 100%);
}

.lesson-title {
    font-weight: 800;
    color: #0f172a;
}

.lesson-status {
    color: #475569;
    font-size: 0.9rem;
}

.learning-lesson-detail {
    border: 1px solid #dbeafe;
    border-radius: 16px;
    padding: 14px;
    background: #fff;
}

.learning-section-title {
    font-weight: 800;
    color: #1d4ed8;
    margin: 12px 0 6px;
}

.ilbirs-panel {
    display: flex;
    align-items: center;
    gap: 12px;
    border-radius: 16px;
    padding: 12px;
    border: 1px solid #cbd5e1;
    background: linear-gradient(135deg, #f8fbff 0%, #eef4ff 100%);
}

.ilbirs-avatar {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.7rem;
    background: #fff;
    border: 2px solid #cbd5e1;
    overflow: hidden;
}

.ilbirs-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ilbirs-bubble {
    flex: 1;
    color: #1e293b;
    font-weight: 600;
}

.ilbi-toast {
    position: fixed;
    left: 50%;
    bottom: 16px;
    transform: translateX(-50%) translateY(14px);
    width: min(92vw, 420px);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 16px;
    border: 1px solid #bfdbfe;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 16px 34px rgba(15, 23, 42, 0.2);
    z-index: 2300;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.22s ease, transform 0.22s ease, visibility 0.22s ease;
}

.ilbi-toast.show {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.ilbi-toast-image {
    width: 52px;
    height: 52px;
    object-fit: cover;
    border-radius: 12px;
    border: 1px solid #93c5fd;
    background: #ffffff;
    flex-shrink: 0;
}

.ilbi-toast-text {
    margin: 0;
    color: #0f172a;
    font-size: 0.96rem;
    font-weight: 700;
    line-height: 1.35;
    text-align: left;
}

.mood-joy { border-color: #facc15; }
.mood-support { border-color: #38bdf8; }
.mood-surprise { border-color: #a78bfa; }
.mood-thoughtful { border-color: #94a3b8; }
.mood-explain { border-color: #2563eb; }
.mood-error { border-color: #ef4444; }
.mood-win { border-color: #22c55e; }
.mood-motivation { border-color: #f59e0b; }

.ort-stats-grid,
.admin-stats-grid {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 12px;
}

.stat-card {
    border: 1px solid #dbeafe;
    border-radius: 14px;
    background: #fff;
    padding: 12px;
    text-align: left;
}

.admin-stats-grid .stat-card {
    width: 100%;
}

.admin-stats-grid .stat-card[data-admin-nav] {
    cursor: pointer;
}

.stat-card h4 {
    margin: 0;
    color: #475569;
    font-size: 0.9rem;
}

.stat-card p {
    margin: 8px 0 0;
    font-size: 1.3rem;
    font-weight: 800;
    color: #0f172a;
}

.ort-bars {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ort-bar {
    display: grid;
    grid-template-columns: 130px 1fr 48px;
    align-items: center;
    gap: 8px;
}

.ort-bar div {
    height: 10px;
    border-radius: 999px;
    background: #e2e8f0;
    overflow: hidden;
}

.ort-bar i {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, #2563eb, #0ea5e9);
}

.admin-grid {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.application-role-badge {
    display: inline-block;
    background: #eef2ff;
    color: #4338ca;
    border-radius: 999px;
    padding: 2px 10px;
    font-size: 0.78rem;
    font-weight: 700;
    margin: 4px 0 8px;
}

.gov-school-bars {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.gov-school-bar-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.gov-school-bar-label {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    font-size: 0.85rem;
    color: #334155;
    font-weight: 600;
}

.gov-school-bar-label span:last-child {
    color: #64748b;
    font-weight: 500;
    white-space: nowrap;
}

.gov-school-bar-track {
    height: 12px;
    border-radius: 999px;
    background: #e2e8f0;
    overflow: hidden;
}

.gov-school-bar-fill {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #2563eb, #0ea5e9);
    transition: width 0.3s ease;
}

.gov-theme-list {
    margin: 6px 0 0;
    padding-left: 18px;
    font-size: 0.88rem;
    color: #475569;
}

.chat-quick-btn {
    padding: 8px 14px;
    border: 1px solid #c7d2fe;
    border-radius: 8px;
    background: #eef2ff;
    color: #4338ca;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chat-quick-btn:hover {
    background: #e0e7ff;
}

.news-card {
    gap: 8px;
}

.news-image {
    width: 100%;
    max-height: 220px;
    object-fit: cover;
    border-radius: 10px;
    border: 1px solid #dbeafe;
    background: #f8fafc;
}

.news-link {
    color: #1d4ed8;
    font-weight: 700;
    text-decoration: none;
}

.news-link:hover {
    text-decoration: underline;
}

.admin-preview-note {
    margin-top: 4px;
    color: #475569;
    font-size: 0.92rem;
}

.admin-user-card {
    display: grid;
    gap: 6px;
}

.admin-user-card h4,
.admin-user-card p {
    margin: 0;
}

.admin-activity-chart {
    width: 100%;
    border-radius: 12px;
    border: 1px solid #dbeafe;
    background: #ffffff;
    margin: 8px 0 12px;
}
.link-button {
    background: transparent;
    border: none;
    color: #4f46e5;
    font-weight: 700;
    cursor: pointer;
    padding: 0;
}

.auth-register-link {
    background: transparent;
    border: none;
    color: #2563eb;
    font-size: 0.92rem;
    font-weight: 600;
    text-decoration: none;
    margin: -6px 0 4px;
    padding: 0;
    cursor: pointer;
    align-self: flex-start;
}

.auth-register-link:hover {
    text-decoration: underline;
    color: #1d4ed8;
    transform: none;
    box-shadow: none;
}
.settings-button {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1100;
    width: 48px;
    height: 48px;
    border-radius: 16px;
    border: 2px solid rgba(255, 255, 255, 0.9);
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.12);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.hidden {
    display: none !important;
}

@media (max-width: 900px) {
    :root {
        --m-gap-1: 8px;
        --m-gap-2: 12px;
        --m-gap-3: 16px;
        --m-gap-4: 20px;
        --m-radius-1: 12px;
        --m-radius-2: 16px;
        --m-radius-3: 20px;
        --m-surface: rgba(255, 255, 255, 0.98);
        --m-surface-soft: #f8fbff;
        --m-text-main: #0f172a;
        --m-text-muted: #475569;
        --m-border: #dbe7ff;
        --m-accent: #2563eb;
    }

    body {
        align-items: flex-start;
        background:
            radial-gradient(circle at 6% -12%, rgba(14, 165, 233, 0.3) 0%, rgba(14, 165, 233, 0) 32%),
            radial-gradient(circle at 95% 14%, rgba(59, 130, 246, 0.24) 0%, rgba(59, 130, 246, 0) 34%),
            linear-gradient(180deg, #eaf2ff 0%, #f8fbff 44%, #eef6ff 100%);
        overflow-x: hidden;
    }

    .page-shell {
        align-items: flex-start;
        height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom));
        min-height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom));
        width: min(calc(100vw - 16px), calc((100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 12px) * 0.75));
        max-width: 460px;
        aspect-ratio: 3 / 4;
        padding: calc(10px + env(safe-area-inset-top)) 8px calc(10px + env(safe-area-inset-bottom));
        margin: 0 auto;
        border-radius: 20px;
        border: 1px solid #cfe0ff;
        box-shadow: 0 12px 30px rgba(15, 23, 42, 0.14);
        overflow: hidden;
    }

    .screen {
        width: 100%;
        max-width: 460px;
        margin: 0;
        height: 100%;
        min-height: 0;
        border-radius: var(--m-radius-3);
        padding: var(--m-gap-3) var(--m-gap-2);
        background: var(--m-surface);
        box-shadow: 0 14px 28px rgba(15, 23, 42, 0.1);
        border: 1px solid #d7e7ff;
        overflow-x: hidden;
        overflow-y: auto;
    }

    .screen,
    .screen * {
        max-width: 100%;
    }

    .menu-button {
        top: calc(8px + env(safe-area-inset-top));
        left: 8px;
        width: 44px;
        height: 44px;
        border-radius: 14px;
    }

    .notification-bell {
        top: calc(8px + env(safe-area-inset-top));
        left: 58px;
        width: 42px;
        height: 42px;
        border-radius: 14px;
    }

    .corner-brand-logo {
        top: calc(8px + env(safe-area-inset-top));
        right: 8px;
        width: 44px;
        height: 44px;
        padding: 3px;
    }

    .sidebar {
        width: 100%;
        max-width: 100%;
        padding: calc(16px + env(safe-area-inset-top)) 12px calc(12px + env(safe-area-inset-bottom));
        background: rgba(255, 255, 255, 0.985);
        backdrop-filter: blur(10px);
    }

    .sidebar-header h3 {
        font-size: 1.35rem;
    }

    .class-grid {
        flex-direction: column;
        align-items: center;
    }

    #home {
        position: relative;
        width: 100%;
        max-width: 420px;
        min-height: 100%;
        justify-content: center;
        padding: 24px 16px 18px;
        gap: 12px;
        border-radius: 24px;
        background:
            radial-gradient(circle at 12% 12%, rgba(56, 189, 248, 0.2) 0%, rgba(56, 189, 248, 0) 38%),
            radial-gradient(circle at 88% 88%, rgba(59, 130, 246, 0.2) 0%, rgba(59, 130, 246, 0) 40%),
            linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
    }

    #home h1 {
        margin: 0 0 8px;
        font-size: clamp(1.7rem, 8vw, 2.2rem);
        line-height: 1.16;
        color: #0f172a;
        background: none;
        -webkit-text-fill-color: currentColor;
        animation: none;
        text-shadow: none;
    }

    #home h2 {
        margin: 0 0 14px;
        font-size: clamp(1rem, 4.7vw, 1.2rem);
        line-height: 1.45;
        color: var(--m-text-muted);
        text-shadow: none;
        max-width: 30ch;
    }

    #home h1,
    #home h2,
    .project-info,
    .notification-item h4,
    .notification-item p,
    .class-item h4,
    .class-item p,
    .question-text,
    .homework-question-text,
    .winner-text,
    .scores-text,
    .current-theme,
    .auth-note,
    .settings-about,
    label,
    p {
        overflow-wrap: anywhere;
        word-break: break-word;
    }

    .home-buttons,
    .mode-buttons,
    .notification-actions,
    .project-buttons,
    .video-buttons,
    .modal-buttons {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        width: 100%;
    }

    #home .home-buttons {
        max-width: 320px;
        width: 100%;
        margin: 0 auto;
    }

    button,
    .project-buttons button {
        width: 100%;
        margin: 0;
        min-height: 48px;
        padding: 12px 14px;
        font-size: 0.98rem;
        border-radius: var(--m-radius-1);
    }

    #home .home-buttons button {
        min-height: 52px;
        border-radius: 16px;
        font-weight: 800;
        box-shadow: 0 8px 18px rgba(15, 23, 42, 0.14);
    }

    #home .home-buttons button:nth-child(1) {
        background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
        color: #ffffff;
        border: 1px solid rgba(37, 99, 235, 0.35);
    }

    #home .home-buttons button:nth-child(2),
    #home .home-buttons button:nth-child(3) {
        background: linear-gradient(180deg, #ffffff 0%, #f5f9ff 100%);
        color: var(--m-text-main);
        border: 1px solid #bfd7ff;
        box-shadow: 0 3px 10px rgba(59, 130, 246, 0.12);
    }

    #home .home-buttons button:active {
        transform: scale(0.99);
    }

    #home .contact-link {
        position: static;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        margin: 8px auto 0;
        padding: 8px 12px;
        border-radius: 999px;
        background: #eef2ff;
        color: #1d4ed8;
        font-size: 0.84rem;
        text-decoration: none;
        font-weight: 700;
        border: 1px solid #bfdbfe;
        transform: none;
        left: auto;
        right: auto;
        bottom: auto;
    }

    #home .contact-link:hover {
        transform: none;
        color: #1e40af;
        background: #e0e7ff;
    }

    .form-row,
    .auth-card .form-row {
        width: 100%;
        gap: var(--m-gap-1);
        margin-bottom: 12px;
    }

    select,
    input[type="text"],
    input[type="password"],
    textarea,
    .player-name {
        width: 100%;
        min-width: 0;
        max-width: 100%;
        padding: 12px 14px;
        border-radius: var(--m-radius-1);
        font-size: 1rem;
        border: 2px solid var(--m-border);
    }

    .projects-list {
        gap: var(--m-gap-2);
        margin-bottom: 14px;
        max-width: 430px;
    }

    .project-item {
        flex-direction: column;
        align-items: stretch;
        gap: var(--m-gap-2);
        padding: 14px;
        border-radius: var(--m-radius-2);
        border-color: #dbe7ff;
        background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
        box-shadow: 0 8px 20px rgba(15, 23, 42, 0.07);
    }

    .project-info {
        font-size: 0.94rem;
        line-height: 1.45;
        word-break: break-word;
    }

    .projects-list,
    .results-content,
    .video-tutorial-content,
    .homework-card,
    .auth-card,
    .class-panel,
    .profile-card,
    .about-card,
    .question-block,
    .settings-content {
        width: 100%;
        min-width: 0;
    }

    .results-content {
        padding: 8px 0;
    }

    .results-card,
    .homework-results-card {
        border-radius: var(--m-radius-3);
        padding: 18px 14px;
    }

    .winner-text {
        font-size: clamp(1.35rem, 6.8vw, 1.9rem);
        letter-spacing: 0.02em;
    }

    .scores-text {
        font-size: 1rem;
    }

    #game {
        height: auto;
        overflow: visible;
    }

    .game-top-row,
    .homework-top-row {
        align-items: flex-start;
        gap: 10px;
        margin-bottom: 12px;
    }

    #timer {
        font-size: 1.55rem;
        margin-bottom: 8px;
    }

    .players-grid {
        gap: 12px;
        margin-top: 8px;
        flex-direction: column;
        align-items: stretch;
    }

    .player {
        flex: 1 1 auto;
        width: 100%;
        max-width: 100%;
        border-radius: var(--m-radius-2);
        padding: 12px;
        box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
    }

    .player h3 {
        font-size: 1.15rem;
        margin-bottom: 10px;
    }

    .tubes-center {
        width: 100%;
        gap: 10px;
    }

    .tube-card {
        flex: 1 1 0;
        width: auto;
        min-width: 0;
        border-radius: var(--m-radius-2);
        padding: 10px;
    }

    .tube-status {
        height: 140px;
    }

    .question-text {
        min-height: 72px;
        padding: 10px;
        font-size: 1rem;
        border-radius: var(--m-radius-1);
        line-height: 1.4;
    }

    .answer {
        min-height: 44px;
        padding: 10px 12px;
        border-radius: var(--m-radius-1);
        font-size: 0.96rem;
    }

    .homework-card {
        border-radius: var(--m-radius-2);
        padding: 14px;
    }

    .homework-card-actions {
        margin-bottom: 10px;
    }

    .homework-question-text {
        font-size: 1.06rem;
        margin-bottom: 12px;
    }

    .homework-answers {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .homework-answer {
        min-height: 52px;
        border-radius: 12px;
        padding: 10px 12px;
    }

    .notification-item,
    .class-item,
    .class-panel,
    .profile-card,
    .about-card,
    .question-block,
    .auth-card {
        border-radius: var(--m-radius-2);
        padding: 14px;
        border: 1px solid #e2ebff;
        background: linear-gradient(180deg, #ffffff 0%, #f9fbff 100%);
    }

    .teacher-feedback-input {
        width: 100%;
        min-width: 0;
    }

    #registerStep1,
    #registerStep2,
    #registerAuthFields,
    #teacherFields,
    #studentFields,
    .settings-content {
        grid-template-columns: 1fr;
    }

    .settings-content {
        min-width: 0;
        padding: 14px;
    }

    .setting-group {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .modal-content {
        width: calc(100% - 16px);
        max-width: 100%;
        border-radius: var(--m-radius-2);
        padding: 16px 12px;
    }

    .wizard-theme-grid {
        grid-template-columns: 1fr;
    }

    .learning-shell,
    #achievementsSummary,
    .subject-card-grid,
    .path-map,
    .admin-grid,
    .ort-stats-grid,
    .admin-stats-grid,
    .learning-lesson-grid {
        grid-template-columns: 1fr;
    }

    .match-row {
        grid-template-columns: 1fr;
    }

    .ilbi-toast {
        width: min(94vw, 360px);
        bottom: 10px;
        padding: 9px 10px;
    }

    .ilbi-toast-image {
        width: 46px;
        height: 46px;
    }

    .ort-bar {
        grid-template-columns: 1fr;
    }

    .modal,
    .sidebar,
    .modal-content,
    .menu-items {
        overflow-x: hidden;
    }
}

@media (max-width: 720px) {
    .form-row {
        width: 100%;
        gap: 12px;
    }

    select,
    input[type="text"],
    input[type="password"],
    textarea {
        width: 100%;
        max-width: 100%;
    }

    button {
        width: 100%;
        max-width: 100%;
    }

    .screen {
        max-width: 100%;
    }
}

@media screen and (max-width: 380px) {
    #home {
        padding: 20px 12px 14px;
        min-height: calc(100dvh - 86px);
    }

    #home h1 {
        font-size: clamp(1.55rem, 8vw, 1.85rem);
    }

    #home h2 {
        font-size: clamp(0.95rem, 4.5vw, 1.05rem);
    }

    #home .home-buttons {
        max-width: 100%;
    }

    #home .home-buttons button {
        min-height: 48px;
        font-size: 0.94rem;
    }

    .screen {
        border-radius: 16px;
        padding: 12px 10px;
    }

    .menu-button {
        width: 40px;
        height: 40px;
        left: 6px;
    }

    .notification-bell {
        width: 38px;
        height: 38px;
        left: 50px;
    }

    h2 {
        font-size: 1.15rem;
    }

    .answer,
    .homework-answer,
    button {
        font-size: 0.92rem;
    }
}

@media (min-width: 901px) {
    body {
        align-items: flex-start;
        background:
            radial-gradient(circle at 6% -12%, rgba(14, 165, 233, 0.3) 0%, rgba(14, 165, 233, 0) 32%),
            radial-gradient(circle at 95% 14%, rgba(59, 130, 246, 0.24) 0%, rgba(59, 130, 246, 0) 34%),
            linear-gradient(180deg, #eaf2ff 0%, #f8fbff 44%, #eef6ff 100%);
    }

    .page-shell {
        justify-content: flex-start;
        align-items: flex-start;
        padding: 92px 24px 28px;
        max-width: 1320px;
    }

    .screen {
        max-width: 1220px;
        padding: 26px 28px;
        background: rgba(255, 255, 255, 0.98);
        border: 1px solid #d7e7ff;
        box-shadow: 0 14px 28px rgba(15, 23, 42, 0.1);
    }

    #home {
        background:
            radial-gradient(circle at 12% 12%, rgba(56, 189, 248, 0.2) 0%, rgba(56, 189, 248, 0) 38%),
            radial-gradient(circle at 88% 88%, rgba(59, 130, 246, 0.2) 0%, rgba(59, 130, 246, 0) 40%),
            linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
    }

    #home h1 {
        color: #0f172a;
        background: none;
        -webkit-text-fill-color: currentColor;
        animation: none;
        text-shadow: none;
    }

    #home h2 {
        color: #475569;
        text-shadow: none;
    }

    #profileScreen,
    #classesScreen,
    #assignmentsScreen,
    #notificationsScreen,
    #achievementsScreen,
    #aboutScreen {
        max-width: 1100px;
    }

    #assignmentsScreen {
        padding-top: 96px;
        row-gap: 18px;
    }

    #assignmentIntro,
    #assignmentForm,
    #assignmentsList {
        width: 100%;
        max-width: 920px;
        margin-left: auto;
        margin-right: auto;
    }

    #assignmentForm .home-buttons {
        justify-content: flex-end;
    }

    #assignmentForm .home-buttons button {
        width: auto;
        min-width: 180px;
    }

    .projects-list {
        max-width: 920px;
    }

    .class-grid {
        align-items: stretch;
    }

    .class-panel {
        min-width: 0;
        flex: 1 1 calc(50% - 12px);
        max-width: calc(50% - 12px);
    }

    .modal-content.settings-content {
        width: min(92vw, 640px);
        max-width: 640px;
        min-width: 0;
        max-height: min(88vh, 760px);
        overflow-y: auto;
        padding: 24px 22px;
    }

    .settings-content {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .settings-content .setting-group.full-width,
    .settings-about,
    .settings-content .modal-buttons {
        grid-column: 1 / -1;
    }
}

.wizard-theme-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 400px;
    overflow-y: auto;
    padding: 8px 4px;
    margin-top: 12px;
}

/* ===== Telegram-style class chat (Chapter: Chats) ===== */

#chatsScreen.screen {
    padding: 0;
    overflow: hidden;
    background: transparent;
    box-shadow: none;
    border: none;
}

.chat-layout {
    display: flex;
    width: 100%;
    height: min(78vh, 720px);
    min-height: 480px;
    background: #ffffff;
    border-radius: 24px;
    overflow: hidden;
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.16);
    border: 1px solid rgba(148, 163, 184, 0.35);
}

.chat-sidebar {
    width: 320px;
    flex: 0 0 320px;
    display: flex;
    flex-direction: column;
    background: #f7f9fc;
    border-right: 1px solid rgba(148, 163, 184, 0.3);
    min-width: 0;
}

.chat-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 16px 8px;
}

.chat-sidebar-header h2 {
    margin: 0;
    font-size: 1.3rem;
    color: #111827;
}

.chat-search-row {
    padding: 4px 16px 12px;
}

.chat-search-row input {
    width: 100%;
    max-width: 100%;
    padding: 10px 14px;
    border-radius: 14px;
    border: 1.5px solid rgba(148, 163, 184, 0.6);
    font-size: 0.95em;
    background: #ffffff;
}

.chat-rooms-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px 8px 12px;
}

.chat-room-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 8px;
    border-radius: 14px;
    cursor: pointer;
    transition: background 0.18s ease;
    text-align: left;
    width: 100%;
    background: transparent;
    border: none;
}

.chat-room-item:hover {
    background: rgba(79, 70, 229, 0.08);
}

.chat-room-item.active {
    background: rgba(79, 70, 229, 0.14);
}

.chat-avatar {
    width: 48px;
    height: 48px;
    min-width: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    color: #ffffff;
    font-size: 1.05rem;
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    flex-shrink: 0;
}

.chat-room-info {
    flex: 1;
    min-width: 0;
}

.chat-room-top-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
}

.chat-room-name {
    font-weight: 700;
    color: #111827;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-room-time {
    font-size: 0.72rem;
    color: #94a3b8;
    flex-shrink: 0;
}

.chat-room-bottom-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-top: 2px;
}

.chat-room-preview {
    font-size: 0.85rem;
    color: #64748b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-room-unread {
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: #4f46e5;
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chat-rooms-empty {
    text-align: center;
    color: #94a3b8;
    padding: 30px 14px;
    font-size: 0.92rem;
}

.chat-window {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: #eef2f9;
}

.chat-window-empty {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    text-align: center;
    padding: 20px;
}

.chat-window-active {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.chat-window-active.hidden {
    display: none;
}

.chat-window-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    background: #ffffff;
    border-bottom: 1px solid rgba(148, 163, 184, 0.3);
}

.chat-back-btn {
    display: none;
    background: transparent;
    box-shadow: none;
    color: #4f46e5;
    font-size: 1.3rem;
    padding: 4px 8px;
    margin: 0;
}

.chat-header-info {
    min-width: 0;
}

.chat-header-title {
    font-weight: 800;
    color: #111827;
}

.chat-header-status {
    font-size: 0.8rem;
    color: #16a34a;
}

.chat-header-status.offline {
    color: #94a3b8;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-message-row {
    display: flex;
    width: 100%;
}

.chat-message-row.outgoing {
    justify-content: flex-end;
}

.chat-message-row.incoming {
    justify-content: flex-start;
}

.chat-bubble {
    max-width: min(72%, 480px);
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 0.95rem;
    line-height: 1.4;
    position: relative;
    box-shadow: 0 4px 10px rgba(15, 23, 42, 0.06);
}

.chat-message-row.incoming .chat-bubble {
    background: #ffffff;
    color: #111827;
    border-bottom-left-radius: 4px;
}

.chat-message-row.outgoing .chat-bubble {
    background: linear-gradient(135deg, #4f46e5, #6d28d9);
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

.chat-bubble-sender {
    font-size: 0.76rem;
    font-weight: 700;
    margin-bottom: 3px;
    color: #7c3aed;
}

.chat-message-row.outgoing .chat-bubble-sender {
    color: rgba(255, 255, 255, 0.85);
}

.chat-bubble-meta {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 4px;
    margin-top: 4px;
    font-size: 0.68rem;
    opacity: 0.75;
}

.chat-bubble-check {
    font-size: 0.78rem;
}

.chat-bubble-check.read {
    color: #38bdf8;
}

.chat-homework-card {
    max-width: min(80%, 480px);
    background: linear-gradient(160deg, #fff7ed 0%, #ffedd5 100%);
    border: 1.5px solid #fb923c;
    border-radius: 18px;
    padding: 14px 16px;
    box-shadow: 0 10px 24px rgba(251, 146, 60, 0.18);
}

.chat-bubble-with-attachment {
    padding: 10px;
}

.chat-attachment {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-attachment-image {
    display: block;
    border-radius: 12px;
    overflow: hidden;
    max-width: 220px;
}

.chat-attachment-image img {
    display: block;
    width: 100%;
    max-height: 220px;
    object-fit: cover;
}

.chat-attachment-file {
    background: rgba(15, 23, 42, 0.04);
    border-radius: 12px;
    padding: 8px 10px;
}

.chat-message-row.outgoing .chat-attachment-file {
    background: rgba(255, 255, 255, 0.14);
}

.chat-attachment-icon {
    font-size: 1.6rem;
    line-height: 1;
}

.chat-attachment-meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1;
}

.chat-attachment-name {
    font-size: 0.85rem;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.chat-attachment-size {
    font-size: 0.72rem;
    opacity: 0.75;
}

.chat-attachment-download {
    font-size: 0.78rem;
    font-weight: 700;
    text-decoration: underline;
    color: inherit;
    white-space: nowrap;
}

.chat-homework-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 800;
    color: #9a3412;
    margin-bottom: 6px;
}

.chat-homework-card-icon {
    font-size: 1.2rem;
}

.chat-homework-card-text {
    color: #7c2d12;
    margin: 4px 0 10px;
    white-space: pre-wrap;
}

.chat-homework-card-due {
    font-size: 0.82rem;
    color: #9a3412;
    margin-bottom: 10px;
}

.chat-homework-solve-btn {
    background: linear-gradient(135deg, #f97316, #ea580c);
    color: #fff;
    border: none;
    border-radius: 14px;
    padding: 10px 20px;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 10px 20px rgba(234, 88, 12, 0.28);
}

.chat-input-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: #ffffff;
    border-top: 1px solid rgba(148, 163, 184, 0.3);
}

.chat-attach-wrap {
    position: relative;
    flex-shrink: 0;
}

.chat-attach-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: #eef2ff;
    color: #4f46e5;
    font-size: 1.15rem;
    padding: 0;
    margin: 0;
    box-shadow: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.chat-attach-menu {
    position: absolute;
    bottom: 50px;
    left: 0;
    background: #ffffff;
    border-radius: 14px;
    box-shadow: 0 16px 34px rgba(15, 23, 42, 0.2);
    border: 1px solid rgba(148, 163, 184, 0.3);
    display: flex;
    flex-direction: column;
    min-width: 200px;
    overflow: hidden;
    z-index: 20;
}

.chat-attach-menu-item {
    background: #ffffff;
    color: #111827;
    text-align: left;
    padding: 12px 16px;
    border: none;
    border-radius: 0;
    margin: 0;
    box-shadow: none;
    font-weight: 600;
    font-size: 0.92rem;
}

.chat-attach-menu-item:hover {
    background: #f1f5f9;
}

.chat-input-bar input[type="text"] {
    flex: 1;
    min-width: 0;
    width: auto;
    max-width: none;
    padding: 11px 16px;
    border-radius: 20px;
    border: 1.5px solid rgba(148, 163, 184, 0.5);
}

.chat-send-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    padding: 0;
    margin: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.chat-homework-modal-content {
    text-align: left;
    max-width: 480px;
}

.chat-homework-label {
    display: block;
    font-weight: 700;
    margin-bottom: 6px;
    color: #334155;
}

.assignment-card-highlight {
    animation: assignmentHighlightPulse 1.4s ease;
}

@keyframes assignmentHighlightPulse {
    0%, 100% {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    }
    30% {
        box-shadow: 0 0 0 4px rgba(249, 115, 22, 0.45);
    }
}

@media (max-width: 900px) {
    .chat-layout {
        height: min(82vh, 720px);
    }

    .chat-sidebar {
        width: 100%;
        flex: 1 1 100%;
        border-right: none;
    }

    .chat-window {
        display: none;
    }

    .chat-layout.chat-conversation-open .chat-sidebar {
        display: none;
    }

    .chat-layout.chat-conversation-open .chat-window {
        display: flex;
        flex: 1 1 100%;
    }

    .chat-back-btn {
        display: inline-flex;
    }
}


/* Жестко запрещаем сжимать кнопки и включаем плавную прокрутку в меню */
.sidebar, 
.sidebar-menu, 
aside {
    display: flex !important;
    flex-direction: column !important;
    max-height: 100vh !important;
    overflow-y: auto !important; /* Включает прокрутку, если кнопок много */
}

.sidebar button, 
.sidebar a, 
.sidebar-btn, 
aside button, 
aside a {
    flex-shrink: 0 !important;   /* ЗАПРЕЩАЕТ браузеру сплющивать кнопки */
    padding: 12px 16px !important; /* Возвращает кнопкам нормальную высоту */
    height: auto !important;       /* Убирает скрытые ограничения ИИ */
    line-height: 1.4 !important;  /* Выравнивает текст ровно по центру */
    display: block !important;     /* Дает кнопке правильно растягиваться */
}

/* Убираем внутренний скролл формы ДЗ на мобилках и возвращаем нормальные размеры */
#assignmentsScreen .screen,
#assignmentsScreen form,
#assignmentsScreen div,
.auth-card {
    height: auto !important;         /* Убираем зажатую высоту окошка */
    max-height: none !important;     /* Снимаем любые ограничения ИИ */
    overflow-y: visible !important;  /* Полностью уничтожаем внутреннюю прокрутку */
    overflow: visible !important;    /* Проявляем обрезанную стрелочку */
}

#assignmentsScreen select {
    margin-bottom: 15px !important;  /* Делаем красивый отступ до кнопки */
}

/* ===== Apple / iOS-style polish (glassmorphism touch, additive only) ===== */
/* Лёгкий слой "стекла" поверх существующих стилей: не меняет разметку/логику,
   только визуальные акценты (блюр, прозрачность, системный шрифт), как просил пользователь. */

body {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.modal {
    background: rgba(15, 23, 42, 0.35);
    backdrop-filter: blur(6px) saturate(160%);
    -webkit-backdrop-filter: blur(6px) saturate(160%);
}

.modal-content {
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 28px;
}

.sidebar {
    background: rgba(255, 255, 255, 0.78);
    backdrop-filter: blur(26px) saturate(180%);
    -webkit-backdrop-filter: blur(26px) saturate(180%);
    border-right: 1px solid rgba(255, 255, 255, 0.5);
}

.menu-button,
.notification-bell {
    background: rgba(255, 255, 255, 0.65);
    backdrop-filter: blur(14px) saturate(180%);
    -webkit-backdrop-filter: blur(14px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.7);
}

.screen {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(22px) saturate(180%);
    -webkit-backdrop-filter: blur(22px) saturate(180%);
    border-radius: 26px;
}

.auth-card {
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.55);
}

.question-block,
.class-panel,
.stat-card,
.notification-window .notification-item,
.projects-list .notification-item {
    background: rgba(255, 255, 255, 0.68);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
}

select,
input[type="text"],
input[type="password"],
input[type="date"],
textarea {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

button {
    border-radius: 16px;
}

.close-menu,
.menu-button,
.notification-bell {
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease, background 0.2s ease;
}

.menu-button:hover,
.notification-bell:hover {
    transform: translateY(-2px);
}

@media (prefers-reduced-transparency: reduce) {
    .modal,
    .modal-content,
    .sidebar,
    .menu-button,
    .notification-bell,
    .screen,
    .auth-card,
    .question-block,
    .class-panel,
    .stat-card {
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }
}

/* ===== "Мои классы": исправление адаптивной верстки (ПК + телефон) =====
   Причина бага: .class-panel имел flex: 1 1 360px, а на узких экранах
   .class-grid переключался в column-направление, из-за чего 360px
   становился ВЫСОТОЙ и обрезал форму создания класса и список классов
   внутри крошечного скролл-бокса. Ниже — полный, специфичный оверрайд. */
#classesScreen .class-grid {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 20px;
    width: 100%;
}

#classesScreen .class-panel {
    flex: none;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    height: auto;
    overflow: visible;
}

#teacherClassPanel .form-row {
    width: 100%;
    justify-content: flex-start;
    gap: 12px;
}

#teacherClassPanel .form-row select {
    flex: 1 1 200px;
    width: auto;
    min-width: 160px;
    max-width: 100%;
}

#newClassSubject {
    flex: 1 1 100%;
    width: 100%;
}

.subject-checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.subject-checkbox-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid #cbd5e1;
    background: #f8fafc;
    color: #334155;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.subject-checkbox-item input[type="checkbox"] {
    accent-color: #4f46e5;
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.subject-checkbox-item.is-checked,
.subject-checkbox-item:has(input:checked) {
    border-color: #4f46e5;
    background: #eef2ff;
    color: #3730a3;
    font-weight: 700;
}

#myClassesList {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    width: 100%;
    max-width: 100%;
    margin-bottom: 0;
}

#myClassesList .class-item-rich {
    margin-bottom: 0;
    display: flex;
    flex-direction: column;
}

#myClassesList .notification-actions {
    margin-top: auto;
}

#classStudentsPanel {
    width: 100%;
    max-width: 100%;
}

@media (max-width: 640px) {
    #teacherClassPanel .form-row select {
        flex: 1 1 100%;
        min-width: 0;
    }

    #myClassesList {
        grid-template-columns: 1fr;
    }
}

.shop-item {
    background: linear-gradient(180deg, rgba(255,255,255,0.96), rgba(248,250,252,0.96));
    border: 1px solid rgba(148, 163, 184, 0.5);
    border-radius: 18px;
    padding: 18px 20px;
    margin-bottom: 16px;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
}

.shop-item h4 {
    margin: 0 0 8px;
}

.shop-item-owned {
    border-color: rgba(34, 197, 94, 0.5);
    background: linear-gradient(180deg, rgba(240,253,244,0.96), rgba(255,255,255,0.96));
}

.shop-buy-btn {
    padding: 10px 18px;
    border-radius: 10px;
    border: none;
    font-weight: 700;
    cursor: pointer;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
}

.shop-buy-btn:disabled {
    cursor: not-allowed;
    opacity: 0.7;
    background: linear-gradient(135deg, #94a3b8, #64748b);
}

/* Купленные в BilimShop косметические эффекты */
.shop-profile-color-active {
    border-left: 4px solid #667eea;
    padding-left: 14px;
    background: linear-gradient(90deg, rgba(102,126,234,0.08), transparent 60%);
    border-radius: 8px;
}

.shop-nickname-color-active {
    color: #f59e0b;
    font-weight: 700;
}

.shop-nickname-rainbow-active {
    font-weight: 700;
    background: linear-gradient(90deg, #ff0080, #ff8c00, #40e0d0, #ff0080);
    background-size: 300% auto;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation: shopRainbowNickname 3s linear infinite;
}

@keyframes shopRainbowNickname {
    0% { background-position: 0% 50%; }
    100% { background-position: 300% 50%; }
}

body.shop-wallpaper-active #home,
body.shop-wallpaper-active #profileScreen {
    background: linear-gradient(135deg, #1e293b 0%, #4c1d95 45%, #7c3aed 100%);
    border-radius: 20px;
    color: #f8fafc;
}

body.shop-wallpaper-active #home h1,
body.shop-wallpaper-active #home h2,
body.shop-wallpaper-active #profileScreen h2 {
    color: #f8fafc;
}

.streak-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-weight: 700;
}

.leaderboard-hint {
    color: var(--muted);
    margin: 0 0 14px;
}

.leaderboard-my-place {
    background: linear-gradient(120deg, rgba(79, 70, 229, 0.12), rgba(124, 58, 237, 0.12));
    border: 1px solid rgba(79, 70, 229, 0.35);
    border-radius: 14px;
    padding: 10px 16px;
    font-weight: 700;
    color: var(--primary-dark);
    margin-bottom: 16px;
}

.leaderboard-podium {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 20px;
    align-items: end;
}

.leaderboard-podium-card {
    border-radius: 18px;
    padding: 18px 14px;
    text-align: center;
    background: linear-gradient(160deg, #fff, #f1f5f9);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-soft);
}

.leaderboard-podium-card.place-1 {
    background: linear-gradient(160deg, #fff7cc, #ffd45e 65%, #ffb300);
    order: 2;
    transform: scale(1.08);
    border-color: #f59e0b;
}

.leaderboard-podium-card.place-2 {
    background: linear-gradient(160deg, #f3f6fb, #d9e2ec 65%, #b8c4d4);
    order: 1;
    border-color: #94a3b8;
}

.leaderboard-podium-card.place-3 {
    background: linear-gradient(160deg, #ffe9d9, #f3c199 65%, #cd8b5b);
    order: 3;
    border-color: #b97a4a;
}

.leaderboard-podium-card.is-me {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

.leaderboard-medal {
    font-size: 2.2rem;
    line-height: 1;
}

.leaderboard-place {
    font-weight: 700;
    color: var(--muted);
    margin: 4px 0;
}

.leaderboard-name {
    font-weight: 800;
    color: var(--text);
    margin-bottom: 2px;
}

.leaderboard-xp {
    font-weight: 700;
    color: var(--primary-dark);
    margin-bottom: 6px;
}

.leaderboard-row.is-me {
    border: 2px solid var(--primary);
    background: rgba(79, 70, 229, 0.06);
}

.leaderboard-me-tag {
    font-size: 0.75rem;
    font-weight: 700;
    color: #fff;
    background: var(--primary);
    border-radius: 999px;
    padding: 2px 8px;
    margin-left: 6px;
    vertical-align: middle;
}

.share-profile-textarea {
    width: 100%;
    resize: vertical;
    font-family: inherit;
    font-size: 0.95rem;
    padding: 10px;
    border-radius: 10px;
    border: 1px solid var(--border);
    margin: 10px 0;
}

@media (max-width: 640px) {
    .leaderboard-podium {
        grid-template-columns: 1fr;
    }
    .leaderboard-podium-card.place-1,
    .leaderboard-podium-card.place-2,
    .leaderboard-podium-card.place-3 {
        order: 0;
        transform: none;
    }
}

.parent-child-card {
    border: 1px solid var(--border, #dbeafe);
    border-radius: 16px;
    background: #fff;
    padding: 16px;
    margin-bottom: 14px;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.05);
}

.parent-child-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 6px;
}

.parent-child-header h4 {
    margin: 0;
    font-size: 1.15rem;
    color: #0f172a;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    padding: 5px 12px;
    border-radius: 999px;
    background: #f1f5f9;
    color: #334155;
    font-size: 0.82rem;
    font-weight: 700;
    white-space: nowrap;
}

.parent-child-stats {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    margin-top: 10px;
}

.child-results-list {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.child-results-list p {
    margin: 0;
    padding: 8px 10px;
    background: #f8fafc;
    border-radius: 10px;
    font-size: 0.9rem;
    color: #334155;
}

.result-date {
    color: #94a3b8;
    font-size: 0.8rem;
    float: right;
}

@media (max-width: 640px) {
    .parent-child-stats {
        grid-template-columns: repeat(2, 1fr);
    }
}




