:root {
    --card-ratio: 2 / 3;
    --brand: #53575a;
    --brand-soft: #eef0ef;
    --brand-paper: #f0e17b;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    min-height: 100%;
    margin: 0;
}

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--brand-paper);
    color: var(--brand);
}

.app {
    min-height: 100dvh;
}

.screen {
    min-height: 100dvh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.screen.is-hidden {
    display: none;
}

.screen-start {
    align-content: center;
    gap: 32px;
    background: var(--brand-paper);
}

.brand-mark {
    width: min(54vw, 210px);
    height: auto;
}

.primary-button {
    min-width: 180px;
    min-height: 48px;
    border: 1px solid #171717;
    background: #171717;
    color: #fff;
    font: inherit;
    cursor: pointer;
}

.start-button {
    min-width: 168px;
    border-color: var(--brand);
    background: var(--brand);
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 14px;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.start-button:hover {
    border-color: #65696c;
    background: #65696c;
}

.start-button:active {
    transform: translateY(1px);
}

.game-layout {
    width: min(100%, 440px);
    display: grid;
    gap: 18px;
}

.memory-card {
    width: 100%;
    aspect-ratio: var(--card-ratio);
    border: 0;
    padding: 0;
    position: relative;
    background: transparent;
    cursor: pointer;
    perspective: 800px;
    display: block;
}

.screen-game {
    align-content: center;
    background: var(--brand-paper);
}

.game-board {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
}

.game-status {
    min-height: 34px;
    display: grid;
    justify-items: center;
    align-content: start;
    gap: 14px;
    text-align: center;
}

.timer {
    min-height: 34px;
    font-size: 24px;
    font-weight: 700;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(240, 225, 123, 0.78);
    backdrop-filter: blur(8px);
}

.modal.is-hidden {
    display: none;
}

.modal-panel {
    width: min(100%, 320px);
    display: grid;
    justify-items: center;
    gap: 14px;
    padding: 28px 24px;
    border: 1px solid rgba(83, 87, 90, 0.18);
    background: var(--brand-paper);
    color: var(--brand);
    text-align: center;
    box-shadow: 0 24px 70px rgba(83, 87, 90, 0.18);
}

.modal-panel strong {
    font-size: 24px;
}

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

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

.memory-card-face {
    width: 100%;
    height: 100%;
    position: absolute;
    inset: 0;
    display: block;
    backface-visibility: hidden;
    overflow: hidden;
    border: 1px solid rgba(23, 23, 23, 0.16);
    background: #fff;
}

.memory-card-face img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.memory-card-front {
    transform: rotateY(180deg);
}
