:root {
    --app-bg-1: #f7fbff;
    --app-bg-2: #fff7ea;
    --surface: #ffffff;
    --surface-muted: #f6f9fc;
    --border-soft: rgba(15, 23, 42, 0.1);
    --navbar-height: 68px;
}

* {
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    padding-top: var(--navbar-height);
    background:
        radial-gradient(circle at top left, rgba(13, 110, 253, 0.14), transparent 30%),
        radial-gradient(circle at bottom right, rgba(255, 193, 7, 0.2), transparent 34%),
        linear-gradient(135deg, var(--app-bg-1), var(--app-bg-2));
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.app-navbar {
    min-height: var(--navbar-height);
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(14px);
}

.navbar-logo {
    width: 42px;
    height: 42px;
    object-fit: contain;
    border-radius: 12px;
    flex: 0 0 auto;
}

.navbar-title {
    font-size: 0.95rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    color: #172033;
    line-height: 1.1;
}

.app-shell {
    min-height: 100vh;
}

.app-logo {
    display: grid;
    place-items: center;
    width: 76px;
    height: 76px;
    border-radius: 26px;
    background: #fff;
    font-size: 2.3rem;
    box-shadow: 0 14px 30px rgba(15, 23, 42, 0.12);
}

.student-card {
    padding: 1.25rem;
    border-radius: 1.5rem;
    background: linear-gradient(135deg, rgba(13, 202, 240, 0.12), rgba(25, 135, 84, 0.12));
    border: 1px solid rgba(13, 110, 253, 0.12);
}

.student-photo,
.game-student-photo {
    object-fit: cover;
    background: #e9ecef;
    border: 4px solid #fff;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.16);
}

.student-photo {
    width: 112px;
    height: 112px;
    border-radius: 28px;
}

.game-student-photo {
    width: 54px;
    height: 54px;
    border-radius: 16px;
}

.student-meta {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.game-screen {
    min-height: calc(100vh - var(--navbar-height));
    padding: 0;
    display: flex;
    flex-direction: column;
}

.game-topbar {
    z-index: 20;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(12px);
    padding: 0.55rem 0.75rem;
    flex: 0 0 auto;
}

.game-content {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    padding-bottom: 0.35rem;
}

.task-card {
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid var(--border-soft);
    border-radius: 1.25rem;
    padding: 0.55rem 0.75rem;
}

.instruction-text {
    font-weight: 800;
    color: #172033;
    line-height: 1.2;
}

.doc-card {
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: 1.25rem;
    padding: 0.55rem;
    display: flex;
    flex-direction: column;
}

.doc-title {
    font-weight: 700;
    margin-bottom: 0.35rem;
    color: #1f2937;
}

.toolbar {
    display: flex;
    gap: 0.45rem;
    flex-wrap: wrap;
    margin-bottom: 0.45rem;
}

.tool-btn {
    min-width: 46px;
    width: 46px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.2rem;
}

.tool-btn img {
    width: 24px;
    height: 24px;
    object-fit: contain;
    pointer-events: none;
}

.doc-area {
    flex: 1 1 auto;
    min-height: clamp(220px, 40vh, 300px);
    background: var(--surface-muted);
    border: 1px solid rgba(31, 41, 55, 0.2);
    border-radius: 0.9rem;
    padding: 0.65rem 0.7rem;
    overflow: auto;
    line-height: 1.3;
    font-size: 0.97rem;
}

.doc-area p,
.doc-area li,
.doc-area h1,
.doc-area h2,
.doc-area h3,
.doc-area h4,
.doc-area h5,
.doc-area h6 {
    margin-top: 0;
    margin-bottom: 0.35rem;
    line-height: 1.3;
}

.doc-area p:last-child,
.doc-area li:last-child,
.doc-area h1:last-child,
.doc-area h2:last-child,
.doc-area h3:last-child,
.doc-area h4:last-child,
.doc-area h5:last-child,
.doc-area h6:last-child {
    margin-bottom: 0;
}

.doc-area ol,
.doc-area ul {
    margin: 0 0 0.35rem;
    padding-left: 1.15rem;
}

.sample-doc {
    user-select: none;
}

.editor-doc {
    background: #fff;
}

.editor-doc:focus {
    outline: 3px solid rgba(13, 110, 253, 0.2);
    border-color: rgba(13, 110, 253, 0.55);
}

.feedback-panel {
    margin-top: 0.55rem;
    border-radius: 0.9rem;
    padding: 0.5rem 0.65rem;
    border: 1px solid transparent;
}

.feedback-success {
    background: rgba(25, 135, 84, 0.1);
    border-color: rgba(25, 135, 84, 0.3);
    color: #0a5132;
}

.feedback-error {
    background: rgba(220, 53, 69, 0.08);
    border-color: rgba(220, 53, 69, 0.28);
    color: #7a0f1a;
}

.result-panel {
    border: 1px solid rgba(13, 110, 253, 0.2);
    background: rgba(13, 110, 253, 0.07);
    border-radius: 0.9rem;
    padding: 0.5rem 0.65rem;
}

.finish-card {
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid var(--border-soft);
    border-radius: 1.2rem;
    padding: 1rem;
}

.finish-emoji {
    font-size: 2.2rem;
    line-height: 1;
    margin-bottom: 0.35rem;
}

.finish-grid {
    display: grid;
    gap: 0.55rem;
    grid-template-columns: repeat(3, minmax(120px, 1fr));
}

.finish-item {
    border: 1px solid rgba(13, 110, 253, 0.18);
    background: rgba(13, 110, 253, 0.06);
    border-radius: 0.8rem;
    padding: 0.6rem 0.7rem;
    text-align: center;
}

.finish-item span {
    display: block;
    font-size: 0.85rem;
    color: #4b5563;
}

.finish-item strong {
    display: block;
    margin-top: 0.2rem;
    font-size: 1.1rem;
    color: #0d6efd;
}

.average-box {
    border: 1px solid rgba(25, 135, 84, 0.25);
    background: rgba(25, 135, 84, 0.08);
    border-radius: 0.9rem;
    padding: 0.65rem 0.75rem;
    text-align: center;
}

.average-score {
    font-size: 1.45rem;
    font-weight: 800;
    color: #146c43;
}

@media (max-width: 768px) {
    :root {
        --navbar-height: 60px;
    }

    .navbar-title {
        font-size: 0.85rem;
    }

    .navbar-logo {
        width: 36px;
        height: 36px;
    }

    .doc-area {
        min-height: clamp(200px, 36vh, 260px);
    }

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