/* === Reset & Base === */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Nunito', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

.hidden {
    display: none !important;
}

/* === Brand Logo Styles === */
.brand-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 0.5rem;
}

.brand-logo {
    width: 120px;
    height: 120px;
    margin-bottom: 0.8rem;
    filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.25));
    animation: logoFloat 3s ease-in-out infinite;
}

@keyframes logoFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.brand-hero h1 {
    font-size: 2.8rem;
    font-weight: 900;
    color: white;
    letter-spacing: 1px;
    text-shadow: 0 3px 15px rgba(0, 0, 0, 0.2);
    margin-bottom: 0;
    line-height: 1.1;
}

.brand-jp {
    font-size: 1.3rem;
    color: rgba(255, 255, 255, 0.85);
    font-weight: 700;
    letter-spacing: 4px;
    display: block;
    margin-top: 0.2rem;
}

.page-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 0.5rem;
}

.page-logo {
    width: 80px;
    height: 80px;
    margin-bottom: 0.5rem;
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.2));
}

/* === Header === */
header {
    background: rgba(255, 255, 255, 0.97);
    padding: 0.6rem 2rem;
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.08);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.header-content {
    max-width: 900px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.header-logo {
    width: 38px;
    height: 38px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

header h1 {
    font-size: 1.4rem;
    font-weight: 800;
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

#user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

#user-name {
    font-weight: 600;
    color: #555;
}

/* === Buttons === */
.btn {
    padding: 0.7rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.btn-primary {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #5a6fd6, #6a4292);
}

.btn-full {
    width: 100%;
}

.btn-small {
    padding: 0.4rem 1rem;
    font-size: 0.85rem;
    background: #f0f0f0;
    color: #555;
    border-radius: 6px;
}

.btn-small:hover {
    background: #e0e0e0;
}

/* === Auth Page === */
.auth-container {
    max-width: 420px;
    margin: 0 auto;
    padding: 3rem 2rem;
    text-align: center;
}

.auth-container h1 {
    font-size: 2.5rem;
    color: white;
    margin-bottom: 0.5rem;
}

.subtitle {
    color: rgba(255, 255, 255, 0.85);
    font-size: 1.1rem;
    margin-bottom: 2rem;
}

.auth-form {
    background: white;
    padding: 2rem;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
}

.auth-form h2 {
    margin-bottom: 1.5rem;
    color: #333;
}

.form-group {
    margin-bottom: 1.2rem;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 0.4rem;
    font-weight: 600;
    color: #555;
    font-size: 0.9rem;
}

.form-group input {
    width: 100%;
    padding: 0.8rem 1rem;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
}

.switch-form {
    margin-top: 1.2rem;
    color: #777;
    font-size: 0.9rem;
}

.switch-form a {
    color: #667eea;
    font-weight: 600;
    text-decoration: none;
}

.error-msg {
    background: #ffe0e0;
    color: #d32f2f;
    padding: 0.8rem;
    border-radius: 8px;
    margin-top: 1rem;
    font-size: 0.9rem;
}

/* === Class Selection === */
.class-container {
    max-width: 700px;
    margin: 2rem auto;
    padding: 2rem;
    text-align: center;
}

.class-container h2 {
    color: white;
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.class-container p {
    color: rgba(255, 255, 255, 0.85);
    margin-bottom: 2rem;
}

.class-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}

.class-card {
    background: white;
    padding: 1.5rem 1rem;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.class-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

.class-card .class-number {
    font-size: 2rem;
    font-weight: 700;
    color: #667eea;
}

.class-card .class-label {
    font-size: 0.85rem;
    color: #777;
    margin-top: 0.3rem;
}

/* === Topic Selection === */
.topic-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.topic-card {
    background: white;
    padding: 1.2rem 1rem;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    text-align: left;
}

.topic-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
    border-left: 4px solid #667eea;
}

.topic-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: #667eea;
    margin-bottom: 0.3rem;
}

.topic-desc {
    font-size: 0.85rem;
    color: #777;
    line-height: 1.4;
}

/* === Quiz Page === */
.quiz-container {
    max-width: 700px;
    margin: 2rem auto;
    padding: 0 1.5rem;
}

.quiz-header {
    background: white;
    padding: 1rem 1.5rem;
    border-radius: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.8rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.quiz-stats {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.badge {
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.badge:nth-child(1) {
    background: #e3f2fd;
    color: #1565c0;
}

.badge:nth-child(2) {
    background: #fff3e0;
    color: #e65100;
}

.badge:nth-child(3) {
    background: #e8f5e9;
    color: #2e7d32;
}

.quiz-score {
    font-weight: 700;
    font-size: 1.1rem;
    color: #333;
}

/* === Question Area === */
#question-area {
    background: white;
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    min-height: 300px;
}

.question-number {
    color: #999;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.question-text {
    font-size: 1.6rem;
    font-weight: 700;
    color: #333;
    margin-bottom: 2rem;
    line-height: 1.4;
    padding: 1rem;
    background: #f8f9ff;
    border-radius: 12px;
    border-left: 4px solid #667eea;
}

.answer-input {
    font-size: 1.3rem !important;
    text-align: center;
    letter-spacing: 1px;
}

/* === Multiple Choice === */
.choices-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin: 1.5rem 0 1rem;
}

.choice-btn {
    padding: 1rem 1.2rem;
    font-size: 1.1rem;
    font-family: 'Nunito', sans-serif;
    font-weight: 600;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    background: #fff;
    color: #333;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

.choice-btn:hover {
    border-color: #667eea;
    background: #f0f0ff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

.choice-btn.selected {
    border-color: #667eea;
    background: #667eea;
    color: #fff;
}

.choice-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.or-divider {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 0.5rem 0;
    color: #999;
    font-size: 0.85rem;
}

.or-divider::before,
.or-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #ddd;
}

/* === Hints System === */
.hints-section {
    margin: 1rem 0 0.5rem;
}

.hint-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    font-family: 'Nunito', sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    border: 2px dashed #f0ad4e;
    border-radius: 10px;
    background: #fff9f0;
    color: #b8860b;
    cursor: pointer;
    transition: all 0.2s ease;
}

.hint-btn:hover:not(:disabled) {
    background: #fff3e0;
    border-color: #e09900;
    transform: translateY(-1px);
}

.hint-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    border-style: solid;
    border-color: #ddd;
    background: #f5f5f5;
    color: #999;
}

.hint-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    font-size: 0.75rem;
    border-radius: 10px;
    background: #f0ad4e;
    color: #fff;
}

.hints-display {
    margin-top: 0.75rem;
}

.hint-item {
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
    border-radius: 10px;
    font-size: 0.95rem;
    line-height: 1.5;
    animation: hintFadeIn 0.3s ease;
}

.hint-label {
    font-weight: 700;
    margin-right: 0.3rem;
}

.hint-level-1 {
    background: #f0f9ff;
    border-left: 4px solid #64b5f6;
    color: #1565c0;
}

.hint-level-2 {
    background: #fff8e1;
    border-left: 4px solid #ffb74d;
    color: #e65100;
}

.hint-level-3 {
    background: #fce4ec;
    border-left: 4px solid #ef5350;
    color: #c62828;
}

@keyframes hintFadeIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* === Loading Spinner === */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #e0e0e0;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading p {
    color: #777;
    font-size: 1rem;
}

/* === Result Display === */
.result-icon {
    font-size: 4rem;
    text-align: center;
    margin-bottom: 1rem;
}

.result-message {
    text-align: center;
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
}

.result-message.correct {
    color: #2e7d32;
}

.result-message.incorrect {
    color: #d32f2f;
}

.result-details {
    background: #f5f5f5;
    padding: 1rem 1.5rem;
    border-radius: 10px;
    margin-bottom: 1.5rem;
}

.result-details p {
    margin: 0.4rem 0;
    font-size: 1rem;
}

.explanation-box {
    background: #e3f2fd;
    padding: 1.2rem 1.5rem;
    border-radius: 10px;
    margin-bottom: 1.5rem;
    border-left: 4px solid #1565c0;
}

.explanation-box h3 {
    margin-bottom: 0.5rem;
    color: #1565c0;
}

.explanation-box p {
    color: #333;
    line-height: 1.6;
}

/* === Subscription Page === */
.sub-card {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    text-align: center;
    margin-bottom: 1.5rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.sub-plan-badge {
    display: inline-block;
    padding: 0.3rem 1rem;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    background: #e0e0e0;
    color: #555;
}

.sub-plan-badge.pro {
    background: linear-gradient(135deg, #FFD700, #FFA500);
    color: #333;
}

.sub-plans {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.sub-plan-card {
    background: white;
    padding: 1.5rem;
    border-radius: 14px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    position: relative;
    text-align: center;
}

.sub-plan-card.pro {
    border: 2px solid #667eea;
}

.sub-popular {
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: 0.2rem 0.8rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 700;
    white-space: nowrap;
}

.sub-plan-card h3 {
    font-size: 1.2rem;
    color: #333;
    margin-bottom: 0.5rem;
}

.sub-price {
    font-size: 2rem;
    font-weight: 900;
    color: #667eea;
    margin-bottom: 0.8rem;
}

.sub-per {
    font-size: 0.9rem;
    font-weight: 400;
    color: #999;
}

.sub-features {
    list-style: none;
    text-align: left;
    margin-bottom: 1rem;
}

.sub-features li {
    padding: 0.3rem 0;
    font-size: 0.9rem;
    color: #555;
}

.sub-features .muted {
    color: #bbb;
    text-decoration: line-through;
}

.sub-plan-label {
    color: #999;
    font-size: 0.85rem;
    font-weight: 600;
}

.sub-message {
    background: #e8f5e9;
    color: #2e7d32;
    padding: 0.8rem;
    border-radius: 8px;
    text-align: center;
    font-weight: 600;
}

.sub-message.error {
    background: #ffe0e0;
    color: #d32f2f;
}

.sub-header-pro {
    background: linear-gradient(135deg, #FFD700, #FFA500) !important;
    color: #333 !important;
}

.daily-limit-banner {
    background: #fff3e0;
    border: 1px solid #FFB74D;
    color: #e65100;
    padding: 0.6rem 1rem;
    border-radius: 8px;
    text-align: center;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    font-weight: 600;
}

.daily-limit-banner a {
    color: #667eea;
    cursor: pointer;
    text-decoration: underline;
}

/* === Admin Dashboard === */
.admin-container {
    max-width: 900px;
    margin: 1.5rem auto;
    padding: 0 1rem;
}

.admin-header-btn {
    background: #e8f5e9 !important;
    color: #2e7d32 !important;
    border: 1px solid #a5d6a7 !important;
}

.admin-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.admin-stat-card {
    background: #fff;
    border-radius: 14px;
    padding: 1.5rem;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    border-top: 4px solid #667eea;
}

.admin-stat-card.pro {
    border-top-color: #f0ad4e;
}

.admin-stat-card.live {
    border-top-color: #4caf50;
}

.admin-stat-number {
    font-size: 2.5rem;
    font-weight: 800;
    color: #333;
    line-height: 1.2;
}

.admin-stat-label {
    font-size: 0.85rem;
    color: #888;
    margin-top: 0.3rem;
    font-weight: 600;
}

.admin-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 1rem;
    border-bottom: 2px solid #e0e0e0;
}

.admin-tab {
    padding: 0.75rem 1.5rem;
    font-family: 'Nunito', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    border: none;
    background: transparent;
    color: #888;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s ease;
}

.admin-tab.active {
    color: #667eea;
    border-bottom-color: #667eea;
}

.admin-tab:hover:not(.active) {
    color: #555;
}

.admin-panel {
    background: #fff;
    border-radius: 14px;
    padding: 1rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
}

.admin-table-wrap {
    overflow-x: auto;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.admin-table th {
    text-align: left;
    padding: 0.75rem 0.5rem;
    font-weight: 700;
    color: #555;
    border-bottom: 2px solid #eee;
    white-space: nowrap;
}

.admin-table td {
    padding: 0.65rem 0.5rem;
    border-bottom: 1px solid #f5f5f5;
    color: #333;
}

.admin-table tr:hover td {
    background: #f8f9ff;
}

.admin-empty {
    text-align: center;
    padding: 2rem !important;
    color: #aaa;
    font-style: italic;
}

.badge-pro {
    background: #fff3e0;
    color: #e65100;
    padding: 0.2rem 0.6rem;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.78rem;
}

.badge-active {
    background: #e8f5e9;
    color: #2e7d32;
    padding: 0.2rem 0.6rem;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.78rem;
}

.badge-live {
    background: #4caf50;
    color: #fff;
    padding: 0.2rem 0.6rem;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.78rem;
    animation: livePulse 2s ease-in-out infinite;
}

@keyframes livePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* === Responsive: Tablet (max-width: 768px) === */
@media (max-width: 768px) {
    .admin-stats {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.5rem;
    }

    .admin-stat-number {
        font-size: 1.8rem;
    }

    .admin-stat-card {
        padding: 1rem 0.5rem;
    }

    header {
        padding: 0.5rem 1rem;
    }

    .header-logo {
        width: 32px;
        height: 32px;
    }

    header h1 {
        font-size: 1.2rem;
    }

    .class-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.8rem;
    }

    .topic-grid {
        grid-template-columns: 1fr;
    }

    .class-container {
        padding: 1.5rem 1rem;
        margin: 1rem auto;
    }

    .quiz-container {
        padding: 0 1rem;
        margin: 1rem auto;
    }

    .quiz-header {
        padding: 0.8rem 1rem;
        gap: 0.6rem;
    }

    #question-area {
        padding: 1.5rem;
    }

    .question-text {
        font-size: 1.4rem;
        padding: 0.8rem;
    }

    .result-details {
        padding: 0.8rem 1rem;
    }

    .explanation-box {
        padding: 1rem;
    }
}

/* === Responsive: Mobile (max-width: 480px) === */
@media (max-width: 480px) {
    body {
        background: linear-gradient(160deg, #667eea 0%, #764ba2 100%);
        min-height: 100dvh; /* dynamic viewport height for mobile browsers */
    }

    header {
        padding: 0.4rem 0.8rem;
    }

    .header-brand {
        gap: 0.4rem;
    }

    .header-logo {
        width: 28px;
        height: 28px;
    }

    header h1 {
        font-size: 1.05rem;
    }

    #user-info {
        gap: 0.5rem;
    }

    #user-name {
        font-size: 0.85rem;
        max-width: 100px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .btn-small {
        padding: 0.35rem 0.7rem;
        font-size: 0.78rem;
    }

    /* Auth page mobile */
    .auth-container {
        padding: 1.5rem 1rem;
    }

    .brand-logo {
        width: 90px;
        height: 90px;
        margin-bottom: 0.5rem;
    }

    .brand-hero h1 {
        font-size: 2rem;
    }

    .brand-jp {
        font-size: 1rem;
        letter-spacing: 3px;
    }

    .subtitle {
        font-size: 0.95rem;
        margin-bottom: 1.2rem;
    }

    .sub-plans {
        grid-template-columns: 1fr;
    }

    .auth-form {
        padding: 1.5rem 1.2rem;
        border-radius: 14px;
    }

    .auth-form h2 {
        font-size: 1.3rem;
        margin-bottom: 1rem;
    }

    .form-group {
        margin-bottom: 1rem;
    }

    .form-group input {
        padding: 0.75rem 0.8rem;
        font-size: 16px; /* prevents iOS zoom on focus */
        border-radius: 10px;
    }

    .btn {
        padding: 0.8rem 1.2rem;
        font-size: 1rem;
        border-radius: 10px;
        /* larger touch target */
        min-height: 48px;
    }

    .switch-form {
        font-size: 0.85rem;
    }

    /* Class selection mobile */
    .page-logo {
        width: 60px;
        height: 60px;
    }

    .class-container h2 {
        font-size: 1.5rem;
    }

    .class-container p {
        font-size: 0.9rem;
        margin-bottom: 1.2rem;
    }

    .class-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.6rem;
    }

    .class-card {
        padding: 1rem 0.6rem;
        border-radius: 10px;
    }

    .class-card .class-number {
        font-size: 1.6rem;
    }

    .class-card .class-label {
        font-size: 0.75rem;
    }

    /* Quiz page mobile */
    .quiz-container {
        padding: 0 0.6rem;
        margin: 0.8rem auto;
    }

    .quiz-header {
        flex-direction: column;
        align-items: stretch;
        padding: 0.7rem;
        gap: 0.5rem;
        border-radius: 10px;
        margin-bottom: 0.8rem;
    }

    .quiz-stats {
        justify-content: center;
    }

    .badge {
        padding: 0.25rem 0.6rem;
        font-size: 0.72rem;
    }

    .quiz-score {
        text-align: center;
        font-size: 1rem;
    }

    .quiz-header .btn-small {
        align-self: center;
    }

    #question-area {
        padding: 1.2rem;
        border-radius: 14px;
        min-height: 250px;
    }

    .question-number {
        font-size: 0.8rem;
    }

    .question-text {
        font-size: 1.2rem;
        padding: 0.8rem;
        margin-bottom: 1.2rem;
        border-radius: 10px;
    }

    .answer-input {
        font-size: 1.1rem !important;
        padding: 0.8rem !important;
        min-height: 48px;
    }

    .choices-grid {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    .choice-btn {
        font-size: 1rem;
        padding: 0.85rem 1rem;
    }

    /* Result display mobile */
    .result-icon {
        font-size: 3rem;
        margin-bottom: 0.6rem;
    }

    .result-message {
        font-size: 1.2rem;
        margin-bottom: 1rem;
    }

    .result-details {
        padding: 0.8rem;
        border-radius: 8px;
        margin-bottom: 1rem;
    }

    .result-details p {
        font-size: 0.9rem;
    }

    .explanation-box {
        padding: 0.8rem 1rem;
        border-radius: 8px;
        margin-bottom: 1rem;
    }

    .explanation-box h3 {
        font-size: 1rem;
    }

    .explanation-box p {
        font-size: 0.9rem;
        line-height: 1.5;
    }

    .loading {
        padding: 2rem 1rem;
    }

    .spinner {
        width: 40px;
        height: 40px;
    }
}

/* === Responsive: Very small phones (max-width: 360px) === */
@media (max-width: 360px) {
    .brand-logo {
        width: 70px;
        height: 70px;
    }

    .brand-hero h1 {
        font-size: 1.7rem;
    }

    .brand-jp {
        font-size: 0.85rem;
    }

    .class-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .question-text {
        font-size: 1.05rem;
    }

    .auth-form {
        padding: 1.2rem 1rem;
    }
}

/* === Touch device optimizations === */
@media (hover: none) and (pointer: coarse) {
    .btn:hover {
        transform: none;
        box-shadow: none;
    }

    .btn:active {
        transform: scale(0.97);
        opacity: 0.9;
    }

    .class-card:hover {
        transform: none;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    }

    .class-card:active {
        transform: scale(0.96);
        background: #f0f0ff;
    }

    .btn-small:hover {
        background: #f0f0f0;
    }

    .btn-small:active {
        background: #d5d5d5;
    }
}

/* === Safe area support for notched phones === */
@supports (padding: env(safe-area-inset-bottom)) {
    body {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }

    header {
        padding-left: max(0.8rem, env(safe-area-inset-left));
        padding-right: max(0.8rem, env(safe-area-inset-right));
    }

    #question-area {
        padding-bottom: max(1.2rem, env(safe-area-inset-bottom));
    }
}

/* === Landscape mobile === */
@media (max-height: 500px) and (orientation: landscape) {
    .brand-logo {
        width: 60px;
        height: 60px;
        margin-bottom: 0.3rem;
    }

    .brand-hero h1 {
        font-size: 1.6rem;
    }

    .auth-container {
        padding: 0.8rem 1rem;
    }

    .auth-form {
        padding: 1rem;
    }

    .form-group {
        margin-bottom: 0.6rem;
    }

    .class-grid {
        grid-template-columns: repeat(6, 1fr);
        gap: 0.5rem;
    }

    .class-card {
        padding: 0.6rem 0.4rem;
    }

    .class-card .class-number {
        font-size: 1.3rem;
    }
}
