:root {
    --bg: #eef7ff;
    --bg-soft: #f8fbff;
    --surface: #ffffff;
    --surface-blue: #eaf4ff;
    --primary: #0b56c5;
    --primary-dark: #073c8c;
    --secondary: #1ea7ff;
    --accent: #ff4f8b;
    --accent-soft: #ffe7ef;
    --sun: #ffd44d;
    --success: #27ae60;
    --warning: #f59e0b;
    --danger: #ef4444;
    --ink: #14213d;
    --muted: #5d6b82;
    --line: #d8e8f8;
    --shadow: 0 18px 48px rgba(8, 72, 150, 0.16);
    --shadow-soft: 0 10px 26px rgba(8, 72, 150, 0.10);
    --radius: 24px;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    font-family: "Sarabun", "Tahoma", system-ui, sans-serif;
    background:
        radial-gradient(circle at 8% 8%, rgba(255, 212, 77, 0.28), transparent 18rem),
        radial-gradient(circle at 92% 12%, rgba(30, 167, 255, 0.20), transparent 20rem),
        linear-gradient(145deg, #f9fcff 0%, var(--bg) 58%, #d9ecff 100%);
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image:
        linear-gradient(135deg, rgba(11, 86, 197, 0.08) 0 2px, transparent 2px 20px),
        linear-gradient(45deg, rgba(255, 79, 139, 0.05) 0 2px, transparent 2px 24px);
    mask-image: linear-gradient(to bottom, rgba(0,0,0,0.45), transparent 70%);
}

a {
    color: inherit;
}

.app-shell {
    width: min(1120px, calc(100% - 32px));
    margin: 0 auto;
    padding: 24px 0 32px;
}

.center-shell {
    min-height: 100vh;
    width: min(1080px, calc(100% - 32px));
    margin: 0 auto;
    display: grid;
    align-items: center;
    padding: 28px 0;
}

.hero-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(320px, 0.95fr);
    gap: 32px;
    align-items: center;
}

.brand-mark {
    width: 72px;
    height: 72px;
    display: grid;
    place-items: center;
    border-radius: 22px;
    background: linear-gradient(145deg, var(--primary), #0a76df);
    color: #fff;
    font-size: 26px;
    font-weight: 900;
    box-shadow: var(--shadow-soft);
}

.hero-title {
    margin: 18px 0 12px;
    color: var(--primary-dark);
    font-size: clamp(34px, 6vw, 64px);
    line-height: 1.05;
    letter-spacing: 0;
}

.hero-copy {
    margin: 0 0 24px;
    color: var(--muted);
    font-size: clamp(18px, 2.5vw, 25px);
    line-height: 1.55;
    font-weight: 700;
}

.feature-list {
    display: grid;
    gap: 16px;
    margin: 24px 0;
}

.feature-item {
    display: grid;
    grid-template-columns: 58px 1fr;
    gap: 14px;
    align-items: center;
}

.feature-icon {
    width: 58px;
    height: 58px;
    display: grid;
    place-items: center;
    border-radius: 18px;
    background: #fff;
    box-shadow: var(--shadow-soft);
    font-size: 28px;
}

.feature-item strong {
    display: block;
    color: var(--primary-dark);
    font-size: 20px;
}

.feature-item span {
    display: block;
    color: var(--muted);
    font-size: 15px;
    line-height: 1.45;
}

.phone-card {
    position: relative;
    max-width: 430px;
    margin: 0 auto;
    padding: 16px;
    border: 12px solid #101828;
    border-radius: 42px;
    background: #fff;
    box-shadow: 0 24px 70px rgba(10, 39, 90, 0.28);
    transform: rotate(2deg);
}

.phone-card::before {
    content: "";
    position: absolute;
    top: 11px;
    left: 50%;
    width: 104px;
    height: 24px;
    border-radius: 999px;
    background: #101828;
    transform: translateX(-50%);
}

.phone-screen {
    min-height: 600px;
    padding: 38px 18px 18px;
    border-radius: 28px;
    background: linear-gradient(180deg, #f8fbff, #edf6ff);
    overflow: hidden;
}

.login-panel,
.soft-card,
.dashboard-card,
.result-card {
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid rgba(216, 232, 248, 0.9);
    border-radius: var(--radius);
    box-shadow: var(--shadow-soft);
}

.login-panel {
    padding: 24px;
}

.panel-title {
    margin: 0 0 8px;
    color: var(--primary-dark);
    font-size: 26px;
}

.panel-subtitle {
    margin: 0 0 20px;
    color: var(--muted);
    line-height: 1.55;
}

.input-stack {
    display: grid;
    gap: 14px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    color: var(--primary-dark);
    font-weight: 800;
}

.text-input,
.select-input {
    width: 100%;
    min-height: 54px;
    padding: 12px 16px;
    border: 2px solid #c9ddf4;
    border-radius: 16px;
    background: #fff;
    color: var(--ink);
    font: inherit;
    font-size: 18px;
    outline: none;
}

.text-input:focus,
.select-input:focus {
    border-color: var(--secondary);
    box-shadow: 0 0 0 4px rgba(30, 167, 255, 0.16);
}

.student-code {
    text-align: center;
    font-size: 28px;
    font-weight: 900;
    letter-spacing: 2px;
}

.btn {
    min-height: 52px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 18px;
    border: 0;
    border-radius: 16px;
    color: #fff;
    font: inherit;
    font-size: 18px;
    font-weight: 900;
    text-decoration: none;
    cursor: pointer;
    box-shadow: var(--shadow-soft);
    transition: transform 0.16s ease, box-shadow 0.16s ease, opacity 0.16s ease;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary { background: linear-gradient(135deg, var(--primary), #1587ff); }
.btn-accent { background: linear-gradient(135deg, var(--accent), #ff7bad); }
.btn-success { background: linear-gradient(135deg, var(--success), #5bd080); }
.btn-warning { background: linear-gradient(135deg, var(--warning), #ffc247); color: #4b3100; }
.btn-danger { background: linear-gradient(135deg, var(--danger), #ff7a7a); }
.btn-muted { background: #e8eef6; color: var(--ink); }
.btn-full { width: 100%; }

.alert {
    padding: 12px 14px;
    border-radius: 16px;
    font-weight: 800;
    line-height: 1.45;
}

.alert-error {
    background: #ffe7e7;
    color: #b42318;
    border: 1px solid #ffc9c9;
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.identity {
    display: flex;
    align-items: center;
    gap: 14px;
}

.avatar {
    width: 64px;
    height: 64px;
    display: grid;
    place-items: center;
    border-radius: 22px;
    background: linear-gradient(145deg, #fff, #e8f4ff);
    color: var(--primary);
    font-size: 26px;
    font-weight: 900;
    box-shadow: var(--shadow-soft);
}

.eyebrow {
    margin: 0 0 4px;
    color: var(--secondary);
    font-size: 14px;
    font-weight: 900;
}

.page-title {
    margin: 0;
    color: var(--primary-dark);
    font-size: clamp(28px, 5vw, 44px);
    line-height: 1.15;
}

.meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 11px;
    border-radius: 999px;
    background: #fff;
    border: 1px solid var(--line);
    color: var(--muted);
    font-size: 14px;
    font-weight: 800;
}

.pill-blue { color: var(--primary); background: #eaf4ff; }
.pill-green { color: #12743c; background: #e8f7ee; }
.pill-pink { color: #bf1d59; background: var(--accent-soft); }
.pill-yellow { color: #7a4c00; background: #fff5cc; }

.stats-grid,
.menu-grid,
.story-grid {
    display: grid;
    gap: 14px;
}

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

.action-card {
    min-height: 144px;
    display: grid;
    gap: 8px;
    align-content: space-between;
    padding: 18px;
    border-radius: 22px;
    border: 2px solid transparent;
    background: #fff;
    color: var(--ink);
    text-decoration: none;
    box-shadow: var(--shadow-soft);
    transition: transform 0.16s ease, border-color 0.16s ease;
}

.action-card:hover {
    transform: translateY(-2px);
}

.action-card strong {
    color: var(--primary-dark);
    font-size: 20px;
}

.action-card .number {
    color: var(--primary);
    font-size: 42px;
    font-weight: 900;
    line-height: 1;
}

.card-new { border-color: #9fd6ff; }
.card-pass { border-color: #a6e8bd; }
.card-help { border-color: #ffd887; }
.card-fail { border-color: #ffb0bf; }

.progress-wrap {
    display: grid;
    gap: 8px;
}

.progress-track {
    position: relative;
    height: 18px;
    overflow: hidden;
    border-radius: 999px;
    background: #dcecff;
}

.progress-fill {
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--secondary), var(--success));
}

.practice-shell {
    min-height: 100vh;
    min-height: 100dvh;
    width: min(820px, calc(100% - 20px));
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 12px 0 18px;
}

.practice-top {
    display: grid;
    gap: 10px;
}

.practice-titlebar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.practice-title {
    margin: 0;
    color: var(--primary-dark);
    font-size: clamp(36px, 8vw, 64px);
    line-height: 1.08;
    letter-spacing: 0;
}

.practice-home {
    flex: 0 0 auto;
    min-height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 14px;
    border-radius: 18px;
    background: rgba(255,255,255,0.86);
    border: 1px solid var(--line);
    color: var(--ink);
    font-size: 18px;
    font-weight: 900;
    text-decoration: none;
    box-shadow: var(--shadow-soft);
}

.practice-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.practice-main {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.practice-progress {
    flex: 0 0 auto;
}

.word-card {
    flex: 1 1 auto;
    min-height: 260px;
    display: grid;
    place-items: center;
    padding: clamp(14px, 4vw, 42px);
    border-radius: 34px;
    background: #fff;
    border: 2px solid #dcecff;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.word-text {
    max-width: 100%;
    color: var(--primary-dark);
    font-size: clamp(128px, 34vw, 280px);
    line-height: 1.05;
    font-weight: 900;
    overflow-wrap: anywhere;
    text-align: center;
}

.practice-buttons {
    flex: 0 0 auto;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.practice-buttons .btn {
    min-height: 92px;
    flex-direction: column;
    font-size: 23px;
    line-height: 1.15;
    border-radius: 24px;
}

.practice-buttons .btn small {
    font-size: 15px;
    font-weight: 800;
    opacity: 0.88;
}

.result-list {
    display: grid;
    gap: 10px;
}

.result-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px dashed var(--line);
    font-size: 20px;
}

.story-card {
    display: block;
    padding: 18px;
    border-radius: 22px;
    background: #fff;
    border: 1px solid var(--line);
    box-shadow: var(--shadow-soft);
    color: var(--ink);
    text-decoration: none;
}

.story-title {
    margin: 0 0 10px;
    color: var(--primary-dark);
    font-size: 22px;
}

.story-content {
    color: #20304f;
    font-size: clamp(21px, 4vw, 28px);
    line-height: 1.9;
}

.choice-label {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 12px;
    align-items: center;
    padding: 14px;
    border: 2px solid #cfe2f7;
    border-radius: 18px;
    background: #fff;
    font-size: 20px;
    cursor: pointer;
}

.choice-label:has(input:checked) {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.empty-state {
    padding: 24px;
    text-align: center;
}

.admin-link {
    margin-top: 18px;
    text-align: center;
    color: var(--muted);
    font-weight: 800;
}

.admin-link a {
    text-decoration: none;
}

.desktop-only {
    display: block;
}

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

    .phone-card {
        transform: none;
        max-width: 100%;
    }

    .desktop-only {
        display: none;
    }
}

@media (max-width: 640px) {
    .app-shell,
    .center-shell,
    .practice-shell {
        width: min(100% - 20px, 640px);
    }

    .app-header {
        align-items: flex-start;
        flex-direction: column;
    }

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

    .phone-screen {
        min-height: auto;
    }

    .feature-item {
        grid-template-columns: 52px 1fr;
    }

    .feature-icon {
        width: 52px;
        height: 52px;
        border-radius: 16px;
    }

    .practice-shell {
        gap: 10px;
        padding: 10px 0 12px;
    }

    .practice-title {
        font-size: clamp(34px, 10vw, 48px);
    }

    .practice-home {
        min-height: 44px;
        padding: 8px 12px;
        font-size: 17px;
    }

    .practice-chips .pill {
        flex: 0 0 auto;
        font-size: 13px;
        padding: 6px 9px;
    }

    .practice-chips {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 2px;
        scrollbar-width: none;
    }

    .practice-chips::-webkit-scrollbar {
        display: none;
    }

    .word-card {
        min-height: 245px;
        border-radius: 30px;
    }

    .word-text {
        font-size: clamp(150px, 42vw, 250px);
    }

    .practice-buttons {
        grid-template-columns: 1fr;
        gap: 9px;
    }

    .practice-buttons .btn {
        min-height: 68px;
        font-size: 25px;
    }

    .practice-buttons .btn small {
        font-size: 15px;
    }
}
