* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f0f4f8;
    color: #1e293b;
    line-height: 1.5;
    padding: 16px;
}

.app-container {
    max-width: 1050px;
    margin: 0 auto;
}

.card {
    background: #ffffff;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
    margin-bottom: 16px;
}

.app-header {
    background: linear-gradient(135deg, #1d4ed8, #1e40af);
    color: #ffffff;
    padding: 20px 24px;
    border-radius: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
}

.app-header h1 {
    font-size: 1.5rem;
}

.subtitle {
    font-size: 0.9rem;
    opacity: 0.9;
}

.header-actions {
    display: flex;
    gap: 8px;
}

.mobile-tip-banner {
    background: #eff6ff;
    border-left: 4px solid #2563eb;
    color: #1e3a8a;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.9rem;
    margin-bottom: 16px;
}

.status-bar {
    display: flex;
    justify-content: space-around;
    text-align: center;
    padding: 14px;
}

.status-item .label {
    display: block;
    font-size: 0.8rem;
    color: #64748b;
}

.status-item .value {
    font-size: 1.3rem;
    font-weight: 700;
    color: #1d4ed8;
}

.game-grid {
    display: grid;
    grid-template-columns: 1.3fr 1fr;
    gap: 16px;
}

@media (max-width: 820px) {
    .game-grid {
        grid-template-columns: 1fr;
    }
}

.ribbon-header {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    color: #1e40af;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 10px;
    margin-bottom: 14px;
}

.word-badge {
    background: #1d4ed8;
    color: #fff;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.toolbar-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 12px;
}

@media (max-width: 540px) {
    .toolbar-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.tool-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 48px;
    padding: 8px 10px;
    border: 2px solid #cbd5e1;
    background: #f8fafc;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95rem;
    transition: all 0.15s ease;
}

.tool-btn:hover {
    border-color: #2563eb;
    background: #eff6ff;
}

.tool-btn.active {
    background: #2563eb;
    color: #ffffff;
    border-color: #1d4ed8;
}

.tool-btn .icon {
    font-size: 1.15rem;
    width: 24px;
    text-align: center;
}

.tool-btn small {
    display: block;
    font-size: 0.72rem;
    opacity: 0.85;
}

.select-hint {
    font-size: 0.85rem;
    color: #475569;
    margin-bottom: 10px;
}

.word-paper {
    background: #ffffff;
    border: 2px solid #cbd5e1;
    border-radius: 8px;
    min-height: 230px;
    padding: 20px;
    box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.05);
}

.doc-line {
    padding: 10px 12px;
    margin-bottom: 8px;
    border: 1.5px dashed transparent;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.1rem;
    transition: background 0.15s, border-color 0.15s;
    text-align: left;
}

.doc-line:hover {
    background: #f8fafc;
    border-color: #94a3b8;
}

.doc-line.selected {
    background: #eff6ff;
    border-color: #2563eb;
}

.fmt-bold { font-weight: 700; }
.fmt-italic { font-style: italic; }
.fmt-underline { text-decoration: underline; }
.fmt-center { text-align: center; }

.editor-footer {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-top: 14px;
}

.btn {
    padding: 10px 16px;
    border-radius: 8px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    font-size: 0.95rem;
}

.btn-primary { background: #16a34a; color: #fff; }
.btn-primary:hover { background: #15803d; }
.btn-secondary { background: #e2e8f0; color: #1e293b; }
.btn-secondary:hover { background: #cbd5e1; }
.btn-outline { background: transparent; border: 1.5px solid #ffffff; color: #ffffff; }
.btn-danger { background: #dc2626; color: #fff; }

.feedback-box {
    margin-top: 12px;
    padding: 12px;
    border-radius: 8px;
    font-weight: 600;
}
.feedback-success { background: #dcfce7; color: #166534; border: 1px solid #86efac; }
.feedback-error { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }

.tasks-card h2 {
    font-size: 1.15rem;
    margin-bottom: 6px;
    color: #0f172a;
}

.task-intro {
    font-size: 0.88rem;
    color: #64748b;
    margin-bottom: 12px;
}

.task-item {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-left: 4px solid #3b82f6;
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 10px;
}

.task-item.done {
    border-left-color: #16a34a;
    background: #f0fdf4;
}

.task-line-preview {
    font-size: 0.85rem;
    color: #475569;
    margin-bottom: 6px;
}

.format-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.fmt-pill {
    background: #e0e7ff;
    color: #1e40af;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 999px;
}

.hidden { display: none !important; }

/* Certificate & Form */
.certificate-section { text-align: center; }
.student-form {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin: 16px 0;
}
.student-form input {
    padding: 10px 14px;
    border: 1.5px solid #cbd5e1;
    border-radius: 8px;
    font-size: 1rem;
    min-width: 220px;
}

.save-status {
    font-size: 0.9rem;
    margin-bottom: 12px;
    color: #166534;
    font-weight: 600;
}

.certificate-box {
    max-width: 720px;
    margin: 20px auto 0;
    background: #fffbeb;
    padding: 16px;
    border-radius: 12px;
    border: 3px solid #d97706;
}

.cert-border {
    border: 2px dashed #f59e0b;
    padding: 24px;
    border-radius: 8px;
}

.cert-top {
    letter-spacing: 2px;
    font-weight: 700;
    color: #b45309;
    font-size: 0.85rem;
}

.cert-student-name {
    font-size: 1.8rem;
    font-weight: 800;
    color: #1e3a8a;
    margin: 10px 0 4px;
    border-bottom: 2px solid #94a3b8;
    display: inline-block;
    padding: 0 24px;
}

.cert-grade {
    font-weight: 600;
    color: #475569;
    margin-bottom: 12px;
}

.cert-stats {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 18px;
    margin: 16px 0;
    background: #ffffff;
    padding: 10px;
    border-radius: 8px;
}

.cert-actions {
    margin-top: 16px;
    display: flex;
    justify-content: center;
    gap: 10px;
}

/* Teacher Dashboard Table */
.login-card { max-width: 420px; margin: 30px auto; text-align: center; }
.login-form { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.login-form input { padding: 10px; border: 1.5px solid #cbd5e1; border-radius: 8px; }
.table-header-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; flex-wrap: wrap; gap: 10px; }
.table-responsive { overflow-x: auto; }
.results-table { width: 100%; border-collapse: collapse; }
.results-table th, .results-table td { padding: 10px 12px; border-bottom: 1px solid #e2e8f0; text-align: left; }
.results-table th { background: #f8fafc; font-weight: 700; }
.badge-score { background: #dcfce7; color: #166534; padding: 3px 8px; border-radius: 6px; font-weight: 700; }
.alert-error { background: #fee2e2; color: #991b1b; padding: 10px; border-radius: 8px; margin-bottom: 10px; }

@media print {
    body * { visibility: hidden; }
    #certificateCard, #certificateCard * { visibility: visible; }
    #certificateCard { position: absolute; left: 0; top: 0; width: 100%; }
    .cert-actions { display: none; }
}
