:root {
    --bg: #f7faf9;
    --card: #fff;
    --text: #1f2937;
    --muted: #64748b;
    --line: #e2e8f0;
    --green: #62c370;
    --yellow: #f5c542;
    --orange: #f59e0b;
    --red: #ef4444;
    --dark-red: #b91c1c;
    --primary: #2563eb;
    --primary-soft: #dbeafe;
    --shadow: 0 18px 45px rgba(15, 23, 42, .08);
    --radius: 24px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: Arial, Helvetica, sans-serif;
    background:
        radial-gradient(circle at top left, #e0f2fe 0, transparent 32%),
        radial-gradient(circle at bottom right, #fee2e2 0, transparent 28%),
        var(--bg);
    color: var(--text);
}

button,
input {
    font-family: inherit;
}

.app-header {
    max-width: 1180px;
    margin: 0 auto;
    padding: 24px 20px 18px;
    display: flex;
    justify-content: space-between;
    gap: 24px;
    align-items: center;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.brand-logo {
    width: 64px;
    height: 64px;
    object-fit: contain;
    border-radius: 16px;
    background: rgba(255, 255, 255, .92);
    box-shadow: var(--shadow);
    flex-shrink: 0;
}

h1 {
    margin: 0;
    font-size: clamp(34px, 5vw, 56px);
    line-height: 1;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-badge {
    min-width: 156px;
    background: var(--card);
    box-shadow: var(--shadow);
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 16px;
    text-align: center;
}

.header-badge span {
    display: block;
    color: var(--muted);
    font-size: 13px;
}

.header-badge strong {
    color: var(--dark-red);
}

.students-btn {
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, .92);
    color: #334155;
    border-radius: 18px;
    padding: 12px 14px;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}

.students-btn:hover {
    transform: translateY(-1px);
    border-color: #93c5fd;
}

.students-icon {
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.students-icon svg {
    width: 100%;
    height: 100%;
    fill: currentColor;
}

.layout {
    max-width: 1180px;
    margin: 0 auto;
    padding: 18px 20px 28px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(320px, 430px);
    gap: 24px;
    align-items: start;
}

.visual-card,
.info-card,
.questions-card,
.result-card,
.comparison article,
.comparison-recommendations {
    background: rgba(255, 255, 255, .9);
    backdrop-filter: blur(10px);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.visual-card {
    padding: 20px;
    position: sticky;
    top: 20px;
}

.organ-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    gap: 12px;
}

.organ-title span {
    font-size: 24px;
    font-weight: 800;
}

.organ-title small {
    color: var(--muted);
}

.anatomy-stage {
    position: relative;
    width: min(100%, 460px);
    aspect-ratio: 581 / 821;
    margin: 0 auto;
    border-radius: 26px;
    overflow: hidden;
    background: linear-gradient(180deg, rgba(255, 255, 255, .7), rgba(255, 255, 255, .92));
}

.digestive-diagram {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
    object-position: center;
}

.organ-hotspot {
    position: absolute;
    border-radius: 999px;
    opacity: .34;
    transition: opacity .35s ease, box-shadow .35s ease, transform .35s ease, background .35s ease, filter .35s ease;
    filter: saturate(1.15);
}

.stomach-hotspot {
    left: 54.5%;
    top: 50.5%;
    width: 14.5%;
    height: 10.5%;
    border-radius: 42% 58% 46% 54%;
    transform: rotate(8deg);
}

.appendix-hotspot {
    left: 36.6%;
    top: 78.2%;
    width: 6.2%;
    height: 5.4%;
    border-radius: 55% 45% 60% 40%;
    transform: rotate(-26deg);
}

.pain-area {
    position: absolute;
    border-radius: 999px;
    background: rgba(239, 68, 68, .14);
    border: 3px dashed rgba(239, 68, 68, .48);
    animation: pulsePain 1.5s linear infinite;
}

#navel-area {
    left: 44%;
    top: 58%;
    width: 9%;
    height: 6.5%;
}

#right-lower-area {
    left: 34%;
    top: 75.5%;
    width: 13%;
    height: 9%;
}

.hidden {
    opacity: 0;
    pointer-events: none;
}

.level-0 {
    background: rgba(98, 195, 112, .34);
    box-shadow: none;
}

.level-1 {
    background: rgba(245, 197, 66, .48);
    box-shadow: 0 0 24px rgba(245, 197, 66, .35);
}

.level-2 {
    background: rgba(245, 158, 11, .56);
    box-shadow: 0 0 34px rgba(245, 158, 11, .44);
}

.level-3 {
    background: rgba(239, 68, 68, .6);
    box-shadow: 0 0 42px rgba(239, 68, 68, .5);
}

.level-4 {
    background: rgba(185, 28, 28, .7);
    box-shadow: 0 0 56px rgba(185, 28, 28, .65);
    animation: pulseHotspot 1.15s ease-in-out infinite;
}

body[data-mode="gastritis"] .stomach-hotspot {
    opacity: .98;
    transform: rotate(8deg) scale(1.14);
    filter: saturate(1.3) brightness(1.08);
}

body[data-mode="gastritis"] .appendix-hotspot {
    opacity: .18;
}

body[data-mode="apendicitis"] .stomach-hotspot {
    opacity: .16;
}

body[data-mode="apendicitis"] .appendix-hotspot {
    opacity: 1;
    transform: rotate(-26deg) scale(1.2);
    filter: saturate(1.35) brightness(1.08);
}

@keyframes pulseHotspot {
    0%,
    100% {
        opacity: .9;
    }

    50% {
        opacity: 1;
    }
}

@keyframes pulsePain {
    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.06);
    }
}

.legend {
    display: flex;
    justify-content: center;
    gap: 14px;
    flex-wrap: wrap;
    color: var(--muted);
    font-size: 14px;
    padding-top: 10px;
}

.dot {
    width: 12px;
    height: 12px;
    display: inline-block;
    border-radius: 999px;
    margin-right: 5px;
    vertical-align: -1px;
}

.dot-low {
    background: var(--green);
}

.dot-medium {
    background: var(--yellow);
}

.dot-high {
    background: var(--orange);
}

.dot-alert {
    background: var(--red);
}

.result-card-inline {
    margin-top: 16px;
    padding: 18px;
    border-radius: 20px;
}

.control-panel {
    display: grid;
    gap: 16px;
    min-width: 0;
}

.tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    background: #e2e8f0;
    padding: 6px;
    border-radius: 18px;
}

.tab {
    border: 0;
    padding: 14px 12px;
    border-radius: 14px;
    font-weight: 800;
    background: transparent;
    color: #475569;
    cursor: pointer;
    transition: .2s ease;
}

.tab.active {
    background: var(--card);
    color: var(--primary);
    box-shadow: 0 8px 18px rgba(15, 23, 42, .08);
}

.info-card,
.questions-card,
.result-card {
    padding: 20px;
}

.questions-card {
    display: flex;
    flex-direction: column;
}

.info-card h2,
.questions-card h3,
.result-card h3,
.comparison h2 {
    margin-top: 0;
}

.info-card p,
.comparison article p,
.result-message {
    color: var(--muted);
    line-height: 1.55;
}

.section-title,
.score-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.ghost-btn {
    border: 1px solid var(--line);
    background: #f8fafc;
    padding: 10px 12px;
    border-radius: 12px;
    cursor: pointer;
    color: #334155;
    font-weight: 700;
    flex-shrink: 0;
}

.questions-container {
    display: grid;
    gap: 10px;
    margin-top: 12px;
    max-height: min(46vh, 440px);
    overflow-y: auto;
    padding-right: 4px;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

.questions-container::-webkit-scrollbar {
    width: 8px;
}

.questions-container::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 999px;
}

.option-card {
    border: 1px solid var(--line);
    background: #f8fafc;
    border-radius: 16px;
    padding: 12px;
    display: grid;
    grid-template-columns: 22px 1fr auto;
    gap: 10px;
    align-items: center;
    cursor: pointer;
    transition: .2s ease;
}

.option-card:hover {
    border-color: #93c5fd;
    transform: translateY(-1px);
}

.option-card input {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

.option-card strong {
    display: block;
    font-size: 14px;
}

.option-card small {
    color: var(--muted);
}

.points {
    color: var(--muted);
    font-size: 12px;
    background: #eef2ff;
    padding: 5px 8px;
    border-radius: 999px;
}

.result-label {
    margin: 0 0 5px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
}

.score-pill {
    min-width: 76px;
    text-align: center;
    background: var(--primary-soft);
    color: var(--primary);
    border-radius: 18px;
    padding: 10px;
    font-weight: 800;
}

.score-pill span {
    font-size: 24px;
}

.progress-track {
    height: 12px;
    background: #e2e8f0;
    border-radius: 999px;
    overflow: hidden;
    margin: 12px 0 14px;
}

.progress-bar {
    height: 100%;
    width: 0%;
    background: var(--green);
    border-radius: inherit;
    transition: width .35s ease, background .35s ease;
}

.recommendations {
    background: #f8fafc;
    border-radius: 18px;
    padding: 14px 16px;
}

.recommendations h4 {
    margin: 0 0 8px;
}

.recommendations ul {
    margin: 0;
    padding-left: 18px;
    color: var(--muted);
    line-height: 1.55;
}

.comparison {
    max-width: 1180px;
    margin: 0 auto 48px;
    padding: 0 20px;
}

.comparison-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}

.comparison article {
    padding: 20px;
}

.comparison-recommendations {
    margin-top: 18px;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 50;
}

.modal.hidden {
    display: none;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, .5);
    backdrop-filter: blur(4px);
}

.modal-card {
    position: relative;
    z-index: 1;
    width: min(92vw, 420px);
    margin: min(14vh, 100px) auto 0;
    background: #fff;
    border-radius: 24px;
    border: 1px solid var(--line);
    box-shadow: 0 32px 80px rgba(15, 23, 42, .28);
    padding: 24px;
}

.modal-close {
    position: absolute;
    right: 14px;
    top: 14px;
    border: 0;
    background: #f8fafc;
    color: #475569;
    width: 38px;
    height: 38px;
    border-radius: 999px;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
}

.modal-eyebrow {
    margin: 0 0 8px;
    color: var(--primary);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .1em;
    font-size: 12px;
}

.modal-card h2 {
    margin: 0 0 16px;
}

.students-list {
    margin: 0;
    padding-left: 20px;
    color: var(--text);
    line-height: 1.8;
    font-size: 17px;
}

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

    .visual-card {
        position: static;
    }
}

@media (max-width: 920px) {
    .app-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .header-actions {
        width: 100%;
        justify-content: space-between;
    }

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

@media (max-width: 640px) {
    .layout,
    .app-header,
    .comparison {
        padding-left: 14px;
        padding-right: 14px;
    }

    .header-brand {
        align-items: flex-start;
    }

    .brand-logo {
        width: 56px;
        height: 56px;
    }

    .organ-title {
        flex-direction: column;
        align-items: flex-start;
    }

    .anatomy-stage {
        width: min(100%, 360px);
    }

    .questions-container {
        max-height: 38vh;
    }
}

@media (max-width: 520px) {
    .header-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .students-btn,
    .header-badge {
        width: 100%;
        justify-content: center;
    }

    .section-title,
    .score-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .option-card {
        grid-template-columns: 22px 1fr;
    }

    .points {
        grid-column: 2;
        width: fit-content;
    }
}
