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

:root {
    --orange: #ff4b1f;
    --orange-dark: #e63f17;
    --navy: #172033;
    --text: #243047;
    --muted: #748096;
    --light: #f6f8fb;
    --white: #ffffff;
    --border: #e4e9f0;
    --shadow: 0 18px 50px rgba(23, 32, 51, 0.08);
}

body {
    min-height: 100vh;
    font-family: Arial, Helvetica, sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at 10% 10%, rgba(255, 75, 31, 0.07), transparent 25%),
        radial-gradient(circle at 90% 30%, rgba(255, 75, 31, 0.06), transparent 25%),
        var(--light);
    display: flex;
    flex-direction: column;
}

.game-header {
    width: 100%;
    padding: 18px 6%;
    background: rgba(255,255,255,.92);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--navy);
    font-size: 25px;
    font-weight: 800;
}

.brand img {
    width: 42px;
    height: 42px;
    object-fit: contain;
}

.brand b {
    color: var(--orange);
}

.back-link {
    color: var(--muted);
    text-decoration: none;
    font-weight: 700;
    font-size: 14px;
}

.back-link:hover {
    color: var(--orange);
}

.game-page {
    width: 100%;
    flex: 1;
    padding: 55px 20px 70px;
}

.game-shell {
    width: min(980px, 100%);
    margin: auto;
}

.game-heading {
    text-align: center;
    margin-bottom: 28px;
}

.eyebrow {
    display: inline-block;
    color: var(--orange);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 2px;
    margin-bottom: 8px;
}

.game-heading h1 {
    color: var(--navy);
    font-size: clamp(32px, 5vw, 48px);
    margin-bottom: 10px;
}

.game-heading p {
    color: var(--muted);
    line-height: 1.7;
}

.screen-card,
.scores-panel {
    background: rgba(255,255,255,.96);
    border: 1px solid var(--border);
    border-radius: 24px;
    box-shadow: var(--shadow);
}

.screen-card {
    max-width: 540px;
    margin: auto;
    padding: 38px;
    text-align: center;
}

.start-icon,
.result-icon {
    font-size: 58px;
    margin-bottom: 12px;
}

.screen-card h2 {
    color: var(--navy);
    margin-bottom: 10px;
    font-size: 28px;
}

.screen-card > p {
    color: var(--muted);
    line-height: 1.6;
    margin-bottom: 22px;
}

.screen-card label {
    display: block;
    text-align: left;
    font-size: 14px;
    font-weight: 800;
    margin-bottom: 8px;
}

.screen-card input {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 11px;
    outline: none;
    font-size: 16px;
    margin-bottom: 13px;
    transition: .25s;
}

.screen-card input:focus {
    border-color: var(--orange);
    box-shadow: 0 0 0 4px rgba(255,75,31,.10);
}

.primary-btn,
.secondary-btn,
.clear-btn {
    border: 0;
    border-radius: 11px;
    padding: 13px 20px;
    font-weight: 800;
    cursor: pointer;
    transition: .25s;
}

.primary-btn {
    width: 100%;
    background: var(--orange);
    color: white;
}

.primary-btn:hover {
    background: var(--orange-dark);
    transform: translateY(-2px);
}

.primary-btn span {
    margin-left: 8px;
}

.secondary-btn {
    background: #eef2f6;
    color: var(--navy);
}

.secondary-btn:hover {
    background: #e2e8ef;
    transform: translateY(-2px);
}

.error-message {
    color: #d62828 !important;
    min-height: 20px;
    margin: 8px 0 0 !important;
    font-size: 13px;
}

.hidden {
    display: none !important;
}

.game-screen {
    width: 100%;
}

.stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    margin-bottom: 18px;
}

.stat-box {
    background: white;
    border: 1px solid var(--border);
    border-radius: 15px;
    padding: 14px;
    text-align: center;
    box-shadow: 0 8px 25px rgba(23,32,51,.04);
}

.stat-box span {
    display: block;
    color: var(--muted);
    font-size: 10px;
    letter-spacing: 1.3px;
    font-weight: 800;
    margin-bottom: 5px;
}

.stat-box strong {
    color: var(--navy);
    font-size: 19px;
}

.board {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    max-width: 680px;
    margin: 0 auto 20px;
    perspective: 1000px;
}

.memory-card {
    border: 0;
    background: transparent;
    padding: 0;
    aspect-ratio: 1 / 1;
    cursor: pointer;
    perspective: 900px;
}

.memory-card:disabled {
    cursor: default;
}

.card-inner {
    width: 100%;
    height: 100%;
    position: relative;
    transition: transform .45s ease;
    transform-style: preserve-3d;
}

.memory-card.flipped .card-inner,
.memory-card.matched .card-inner {
    transform: rotateY(180deg);
}

.card-face {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    border-radius: 17px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-front {
    background:
        linear-gradient(135deg, #ff4b1f, #ff744f);
    color: white;
    box-shadow: 0 9px 20px rgba(255,75,31,.18);
    font-size: 27px;
}

.card-back {
    transform: rotateY(180deg);
    background: white;
    border: 2px solid rgba(255,75,31,.18);
    box-shadow: 0 9px 22px rgba(23,32,51,.07);
    font-size: clamp(30px, 6vw, 48px);
}

.memory-card.matched .card-back {
    border-color: #40a96b;
    background: #f0fff6;
}

.game-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
}

.result-score {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin: 20px 0;
}

.result-score div {
    background: var(--light);
    border-radius: 14px;
    padding: 16px;
}

.result-score span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 6px;
}

.result-score strong {
    color: var(--navy);
    font-size: 25px;
}

.record-message {
    color: var(--orange) !important;
    font-weight: 800;
    min-height: 24px;
}

.result-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 10px;
}

.scores-panel {
    margin-top: 24px;
    padding: 28px;
}

.scores-title {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 15px;
}

.scores-title h2 {
    color: var(--navy);
    font-size: 25px;
}

.close-btn {
    border: 0;
    background: #eef2f6;
    color: var(--navy);
    width: 35px;
    height: 35px;
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
}

.scores-note {
    color: var(--muted);
    font-size: 13px;
    margin: 12px 0 18px;
    line-height: 1.6;
}

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 480px;
}

th,
td {
    padding: 14px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    color: var(--muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

td {
    color: var(--text);
    font-weight: 700;
}

td:first-child {
    color: var(--orange);
    font-size: 18px;
}

.clear-btn {
    margin-top: 18px;
    background: transparent;
    color: #b3261e;
    border: 1px solid #f0c4c1;
}

.clear-btn:hover {
    background: #fff3f2;
}

.game-footer {
    text-align: center;
    padding: 24px 20px;
    background: #111827;
    color: #aeb8c8;
    font-size: 13px;
}

.game-footer span {
    color: #ff4b1f;
}

.game-footer strong {
    color: white;
}

@media (max-width: 620px) {
    .game-header {
        padding: 15px 20px;
    }

    .brand {
        font-size: 20px;
    }

    .brand img {
        width: 35px;
        height: 35px;
    }

    .back-link {
        font-size: 12px;
    }

    .game-page {
        padding: 35px 14px 50px;
    }

    .screen-card {
        padding: 27px 20px;
    }

    .stats {
        gap: 8px;
    }

    .stat-box {
        padding: 11px 5px;
    }

    .stat-box strong {
        font-size: 16px;
    }

    .board {
        gap: 9px;
    }

    .card-front {
        font-size: 22px;
    }

    .game-actions,
    .result-actions {
        grid-template-columns: 1fr;
    }

    .game-actions {
        display: grid;
    }

    .scores-panel {
        padding: 20px 14px;
    }
}
