:root {
    --blue: #0f6fff;
    --teal: #14b8a6;
    --green: #22c55e;
    --red: #ef4444;
    --navy: #083344;
    --ink: #102033;
    --muted: #64748b;
    --card: rgba(255, 255, 255, 0.96);
    --line: #dbeafe;
    --shadow: 0 24px 70px rgba(8, 51, 68, 0.28);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: white;
    background:
        radial-gradient(circle at 15% 10%, rgba(20, 184, 166, 0.8), transparent 32%),
        radial-gradient(circle at 85% 0%, rgba(15, 111, 255, 0.65), transparent 30%),
        linear-gradient(135deg, #052e3f 0%, #075985 48%, #082f49 100%);
    overflow-x: hidden;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    background-image:
        radial-gradient(circle, rgba(255, 255, 255, 0.5) 0 2px, transparent 2px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px),
        linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px);
    background-size: 120px 120px, 60px 60px, 60px 60px;
    opacity: 0.22;
    pointer-events: none;
}

.app {
    position: relative;
    z-index: 1;
    width: min(1220px, 94vw);
    margin: 0 auto;
    padding: 28px 0 38px;
}

.top-bar {
    display: grid;
    grid-template-columns: 260px 1fr 150px;
    gap: 20px;
    align-items: center;
    margin-bottom: 24px;
    animation: slideDown 0.55s ease both;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-icon {
    width: 52px;
    height: 52px;
    display: grid;
    place-items: center;
    border-radius: 16px;
    color: white;
    background: linear-gradient(180deg, var(--teal), #0d9488);
    font-size: 2rem;
    font-weight: 900;
    box-shadow: 0 14px 28px rgba(0, 0, 0, 0.2);
}

.brand strong {
    display: block;
    font-size: 1.45rem;
    line-height: 1;
}

.brand span:last-child {
    display: block;
    opacity: 0.85;
    font-weight: 700;
}

.title-block {
    text-align: center;
}

.title-block h1 {
    margin: 0;
    font-size: clamp(2rem, 4vw, 3.3rem);
    letter-spacing: -0.055em;
    line-height: 1;
}

.title-block p {
    margin: 12px 0 0;
    color: rgba(255, 255, 255, 0.9);
    font-size: 1.08rem;
}

.score-card {
    justify-self: end;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 13px 16px;
    border-radius: 18px;
    background: rgba(5, 46, 63, 0.72);
    border: 1px solid rgba(255, 255, 255, 0.18);
    box-shadow: 0 18px 35px rgba(0, 0, 0, 0.22);
}

.score-card>span {
    font-size: 2rem;
    animation: pulse 1.4s ease-in-out infinite;
}

.score-card strong {
    display: block;
    font-size: 1.8rem;
    line-height: 1;
}

.score-card small {
    display: block;
    font-weight: 800;
    opacity: 0.85;
}

.layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 22px;
}

.side-panel {
    display: grid;
    gap: 16px;
    animation: slideInLeft 0.55s ease both 0.1s;
}

.patient-panel,
.info-card,
.game-shell {
    border: 1px solid rgba(255, 255, 255, 0.24);
    box-shadow: var(--shadow);
}

.patient-panel {
    position: relative;
    min-height: 520px;
    overflow: hidden;
    border-radius: 22px;
    background:
        radial-gradient(circle at 50% 25%, rgba(236, 254, 255, 0.95), transparent 34%),
        linear-gradient(160deg, rgba(45, 212, 191, 0.92), rgba(14, 116, 144, 0.92));
}

.badge {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 22px;
    border-radius: 0 0 16px 16px;
    background: linear-gradient(180deg, #22c55e, #16a34a);
    color: white;
    font-weight: 900;
    letter-spacing: 0.04em;
    z-index: 4;
}

.patient {
    position: absolute;
    left: 50%;
    top: 88px;
    transform: translateX(-50%);
    width: 220px;
    height: 300px;
    animation: bob 2.4s ease-in-out infinite;
}

.head {
    position: absolute;
    left: 35px;
    top: 24px;
    width: 150px;
    height: 165px;
    border-radius: 48% 48% 44% 44%;
    background: #ffd2aa;
    border: 4px solid rgba(77, 46, 28, 0.22);
    z-index: 3;
}

.hair {
    position: absolute;
    left: -3px;
    top: -25px;
    width: 152px;
    height: 78px;
    background: #4b2415;
    border-radius: 55% 45% 45% 35%;
    box-shadow: inset -18px 10px 0 #2f160d;
}

.eye {
    position: absolute;
    top: 65px;
    width: 28px;
    height: 34px;
    border-radius: 50%;
    background: white;
}

.eye.left {
    left: 38px;
}

.eye.right {
    right: 38px;
}

.eye::after {
    content: "";
    position: absolute;
    left: 8px;
    top: 10px;
    width: 12px;
    height: 16px;
    border-radius: 50%;
    background: #1f130e;
}

.mouth {
    position: absolute;
    left: 51px;
    top: 116px;
    width: 48px;
    height: 26px;
    border-radius: 0 0 44px 44px;
    background: #4a1414;
    transition: all 0.25s ease;
}

.body {
    position: absolute;
    left: 38px;
    bottom: 0;
    width: 145px;
    height: 130px;
    border-radius: 42px 42px 24px 24px;
    background: linear-gradient(180deg, #ffffff, #dbeafe);
    box-shadow: inset -18px 0 0 rgba(15, 111, 255, 0.14);
    z-index: 1;
}

.body::before {
    content: "✚";
    position: absolute;
    left: 50%;
    top: 38px;
    transform: translateX(-50%);
    color: var(--teal);
    font-size: 2.8rem;
    font-weight: 900;
}

.speech {
    position: absolute;
    left: 20px;
    right: 20px;
    bottom: 24px;
    padding: 16px 18px;
    border-radius: 16px;
    background: white;
    color: var(--ink);
    font-weight: 850;
    line-height: 1.35;
    box-shadow: 0 16px 32px rgba(0, 0, 0, 0.22);
    animation: pop 0.35s ease both;
}

.info-card {
    padding: 22px;
    border-radius: 22px;
    color: var(--ink);
    background: var(--card);
}

.info-card h2 {
    margin: 0 0 8px;
    color: #0f766e;
    font-size: 1.6rem;
}

.info-card p {
    margin: 0;
    color: #334155;
    font-weight: 650;
    line-height: 1.45;
}

.game-shell {
    padding: 22px;
    border-radius: 22px;
    background: var(--card);
    color: var(--ink);
    animation: slideInRight 0.55s ease both 0.15s;
}

.controls {
    display: grid;
    grid-template-columns: repeat(3, 1fr) 210px 120px;
    gap: 12px;
    margin-bottom: 18px;
}

.stat,
.difficulty-select,
.restart-btn {
    border: 2px solid var(--line);
    border-radius: 16px;
    background: #f8fdff;
}

.stat {
    padding: 13px 16px;
}

.stat span {
    display: block;
    color: #0f766e;
    font-size: 0.82rem;
    font-weight: 900;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.stat strong {
    display: block;
    font-size: 1.45rem;
}

.difficulty-select {
    padding: 0 14px;
    color: var(--ink);
    font-weight: 850;
    cursor: pointer;
}

.restart-btn {
    padding: 13px 16px;
    color: white;
    background: linear-gradient(180deg, var(--blue), #075bd8);
    border: 0;
    font-size: 1rem;
    font-weight: 900;
    cursor: pointer;
    box-shadow: 0 12px 24px rgba(15, 111, 255, 0.24);
    transition: transform 0.18s ease, filter 0.18s ease;
}

.restart-btn:hover {
    transform: translateY(-2px);
    filter: brightness(1.05);
}

.game-board {
    display: grid;
    grid-template-columns: repeat(4, minmax(110px, 1fr));
    gap: 14px;
    perspective: 1200px;
}

.card {
    min-height: 132px;
    border: 0;
    background: transparent;
    cursor: pointer;
    perspective: 1000px;
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 132px;
    transform-style: preserve-3d;
    transition: transform 0.45s cubic-bezier(.2, .8, .2, 1);
}

.card.flipped .card-inner,
.card.matched .card-inner {
    transform: rotateY(180deg);
}

.card-front,
.card-back {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 14px;
    border-radius: 18px;
    backface-visibility: hidden;
    box-shadow: 0 12px 24px rgba(8, 51, 68, 0.14);
}

.card-front {
    color: white;
    background:
        radial-gradient(circle at 25% 20%, rgba(255, 255, 255, 0.35), transparent 28%),
        linear-gradient(160deg, var(--blue), var(--teal));
    font-size: 2.4rem;
}

.card-back {
    transform: rotateY(180deg);
    color: var(--ink);
    background: white;
    border: 3px solid #dbeafe;
    font-weight: 850;
    line-height: 1.25;
    text-align: center;
    font-size: 0.98rem;
}

.card.matched .card-back {
    background: #ecfdf5;
    border-color: #86efac;
    color: #166534;
}

.card.wrong .card-inner {
    animation: shake 0.35s ease;
}

.message {
    margin-top: 18px;
    min-height: 58px;
    display: grid;
    place-items: center;
    padding: 14px 18px;
    border-radius: 16px;
    background: #f0fdfa;
    border: 2px solid #ccfbf1;
    color: #0f766e;
    font-weight: 850;
    text-align: center;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 10;
    display: grid;
    place-items: center;
    padding: 22px;
    background: rgba(5, 46, 63, 0.72);
    backdrop-filter: blur(8px);
}

.modal-card {
    width: min(520px, 94vw);
    padding: 34px;
    border-radius: 26px;
    background: white;
    color: var(--ink);
    text-align: center;
    box-shadow: var(--shadow);
    animation: pop 0.35s ease both;
}

.modal-icon {
    font-size: 4rem;
    margin-bottom: 10px;
}

.modal-card h2 {
    margin: 0 0 10px;
    font-size: 2.2rem;
}

.modal-card p {
    margin: 0 0 22px;
    color: #334155;
    font-weight: 650;
    line-height: 1.5;
}

.hidden {
    display: none;
}

.mood-happy .mouth {
    width: 56px;
    height: 28px;
    left: 47px;
    border-radius: 0 0 50px 50px;
}

.mood-neutral .mouth {
    height: 8px;
    top: 126px;
    border-radius: 999px;
}

.mood-worried .mouth {
    top: 129px;
    height: 22px;
    background: transparent;
    border-top: 6px solid #4a1414;
    border-radius: 50px 50px 0 0;
}

.mood-excited .patient {
    animation: bounce 0.8s ease-in-out infinite;
}

.mood-excited .mouth {
    width: 62px;
    height: 34px;
    left: 44px;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-18px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-22px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(22px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes bob {

    0%,
    100% {
        transform: translateX(-50%) translateY(0);
    }

    50% {
        transform: translateX(-50%) translateY(-8px);
    }
}

@keyframes bounce {

    0%,
    100% {
        transform: translateX(-50%) translateY(0) scale(1);
    }

    50% {
        transform: translateX(-50%) translateY(-16px) scale(1.03);
    }
}

@keyframes pop {
    from {
        opacity: 0;
        transform: scale(0.94);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1) rotate(0deg);
    }

    50% {
        transform: scale(1.12) rotate(6deg);
    }
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-7px);
    }

    50% {
        transform: translateX(7px);
    }

    75% {
        transform: translateX(-4px);
    }
}

@media (max-width: 1040px) {

    .top-bar,
    .layout {
        grid-template-columns: 1fr;
        text-align: center;
    }

    .brand,
    .score-card {
        justify-self: center;
    }

    .controls {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 680px) {
    .game-board {
        grid-template-columns: repeat(2, minmax(120px, 1fr));
    }

    .controls {
        grid-template-columns: 1fr;
    }

    .card,
    .card-inner {
        min-height: 118px;
    }
}