:root {
    --cream: #f4efe6;
    --warm: #e4c09a;
    --ink: #17191c;
    --muted: #64615b;
    --green: #0d4d3a;
    --green-2: #153f32;
    --card: rgba(255, 255, 255, 0.82);
    --line: rgba(23, 25, 28, 0.12);
    --shadow: 0 30px 90px rgba(65, 42, 22, 0.16);
    --radius: 28px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, Cairo, Arial, sans-serif;
    color: var(--ink);
    background:
        radial-gradient(circle at 78% 8%, rgba(255, 255, 255, 0.96), transparent 22%),
        radial-gradient(circle at 12% 88%, rgba(222, 226, 202, 0.78), transparent 28%),
        linear-gradient(135deg, #fbfaf7 0%, var(--cream) 48%, #dfc09e 100%);
}

a { color: inherit; }
button, input, select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.landing-shell {
    width: min(1180px, calc(100% - 34px));
    margin: 0 auto;
    padding: 34px 0;
}

.hero-panel {
    border: 1px solid rgba(255, 255, 255, 0.9);
    border-radius: 36px;
    background: rgba(255, 255, 255, 0.54);
    box-shadow: var(--shadow);
    backdrop-filter: blur(20px);
    padding: clamp(22px, 4vw, 44px);
}

.brand-lockup {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    color: #4e4e4e;
    line-height: 1.05;
}

.brand-lockup strong { display: block; font-family: Cairo, sans-serif; font-weight: 900; }
.brand-lockup span { display: block; font-weight: 800; }
.brand-lockup.mini { margin-bottom: 24px; }

.brand-mark {
    position: relative;
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
}
.brand-mark.small { width: 32px; height: 32px; flex-basis: 32px; }
.brand-mark span {
    position: absolute;
    width: 55%;
    height: 28%;
    left: 24%;
    top: 36%;
    border-radius: 100% 12% 100% 12%;
    transform-origin: 10% 50%;
}
.brand-mark span:nth-child(1) { background: #e1261c; transform: rotate(16deg); }
.brand-mark span:nth-child(2) { background: #f58220; transform: rotate(88deg); }
.brand-mark span:nth-child(3) { background: #1aa651; transform: rotate(160deg); }
.brand-mark span:nth-child(4) { background: #0072bc; transform: rotate(232deg); }
.brand-mark span:nth-child(5) { background: #00a5df; transform: rotate(304deg); }

.hero-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(310px, 0.75fr);
    gap: clamp(28px, 6vw, 70px);
    align-items: center;
    margin-top: 34px;
}

.pill {
    display: inline-flex;
    align-items: center;
    width: max-content;
    padding: 8px 14px;
    border-radius: 999px;
    background: rgba(13, 77, 58, 0.08);
    color: var(--green);
    border: 1px solid rgba(13, 77, 58, 0.14);
    font-size: 13px;
    font-weight: 900;
    letter-spacing: 0.02em;
}

h1, h2, p { margin: 0; }
h1 {
    margin-top: 18px;
    font-family: Cairo, Inter, sans-serif;
    font-size: clamp(48px, 8vw, 92px);
    letter-spacing: -0.075em;
    line-height: 0.9;
}

.lead {
    max-width: 650px;
    margin-top: 20px;
    color: var(--muted);
    font-size: 18px;
    line-height: 1.8;
}

.feature-row {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-top: 30px;
}
.feature-row div, .dialog-grid div {
    padding: 18px;
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.68);
    border: 1px solid rgba(255, 255, 255, 0.9);
}
.feature-row strong, .dialog-grid strong { display: block; font-size: 26px; }
.feature-row span, .dialog-grid span { display: block; color: var(--muted); font-size: 13px; font-weight: 800; }

.last-winner {
    margin-top: 22px;
    padding: 14px 16px;
    width: fit-content;
    border-radius: 18px;
    color: var(--green);
    background: rgba(13, 77, 58, 0.08);
    font-weight: 800;
}

.setup-card, .panel-card {
    border: 1px solid rgba(255, 255, 255, 0.92);
    border-radius: var(--radius);
    background: var(--card);
    box-shadow: 0 18px 55px rgba(62, 42, 20, 0.1);
}

.setup-card {
    padding: 24px;
}
.setup-card h2, .panel-card h2 {
    font-size: 24px;
    letter-spacing: -0.04em;
}
.setup-card label {
    display: grid;
    gap: 8px;
    margin-top: 16px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 900;
}
.setup-card input, .setup-card select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.75);
    color: var(--ink);
    outline: none;
}
.setup-card input:focus, .setup-card select:focus { border-color: rgba(13, 77, 58, 0.5); }
.is-hidden { display: none !important; }

.primary-btn, .secondary-btn, .ghost-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 13px 22px;
    border-radius: 999px;
    border: 0;
    cursor: pointer;
    text-decoration: none;
    font-weight: 900;
    transition: transform 0.2s ease, opacity 0.2s ease;
}
.primary-btn { width: 100%; margin-top: 22px; background: var(--green); color: #fff; }
.secondary-btn { background: rgba(13, 77, 58, 0.09); color: var(--green); border: 1px solid rgba(13, 77, 58, 0.15); }
.ghost-link { color: var(--muted); }
.primary-btn:hover, .secondary-btn:hover, .ghost-link:hover { transform: translateY(-2px); }

.rules-strip {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-top: 16px;
}
.rules-strip article {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.54);
    border: 1px solid rgba(255, 255, 255, 0.8);
}
.rules-strip strong {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--ink);
    color: #fff;
}
.rules-strip span { color: var(--muted); font-weight: 800; font-size: 14px; }

.game-layout {
    width: min(1440px, calc(100% - 28px));
    margin: 0 auto;
    min-height: 100vh;
    display: grid;
    grid-template-columns: 340px 1fr;
    gap: 22px;
    padding: 24px 0;
}

.score-sidebar {
    position: sticky;
    top: 24px;
    align-self: start;
    display: grid;
    gap: 14px;
}
.panel-card { padding: 18px; }
.label { color: var(--muted); font-size: 12px; font-weight: 900; text-transform: uppercase; letter-spacing: 0.08em; }
.current-turn-card strong { display: block; margin: 8px 0 8px; font-size: 28px; letter-spacing: -0.04em; }
.current-turn-card p { color: var(--muted); line-height: 1.55; font-weight: 700; }
.current-turn-card p.success { color: #168445; }
.current-turn-card p.error, .current-turn-card p.warning { color: #b74b35; }
.current-turn-card p.info { color: var(--green); }

.mini-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.mini-stats div {
    padding: 14px;
    border-radius: 18px;
    background: rgba(13, 77, 58, 0.06);
}
.mini-stats span { display: block; color: var(--muted); font-size: 12px; font-weight: 900; }
.mini-stats strong { display: block; margin-top: 5px; font-size: 26px; }

.scoreboard { display: grid; gap: 9px; margin-top: 14px; }
.score-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.58);
    border: 1px solid transparent;
    font-weight: 900;
}
.score-row.active {
    color: var(--green);
    border-color: rgba(13, 77, 58, 0.22);
    background: rgba(13, 77, 58, 0.08);
}
.score-row strong {
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: #fff;
}

.how-to ol { margin: 14px 0 0; padding-left: 22px; color: var(--muted); line-height: 1.7; font-weight: 700; }
.side-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.side-actions .secondary-btn { flex: 1; }

.board-section {
    min-width: 0;
    padding: clamp(16px, 3vw, 30px);
    border: 1px solid rgba(255, 255, 255, 0.86);
    border-radius: 36px;
    background: rgba(255, 255, 255, 0.44);
    box-shadow: var(--shadow);
}
.board-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 20px;
}
.board-header h1 {
    font-size: clamp(34px, 5vw, 64px);
}
.rules-btn { width: auto; }

.cards-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(118px, 1fr));
    gap: clamp(10px, 1.6vw, 18px);
    perspective: 1000px;
}

.memory-card {
    position: relative;
    aspect-ratio: 6 / 9;
    border: 0;
    padding: 0;
    background: transparent;
    cursor: pointer;
    perspective: 1000px;
}
.memory-card:disabled { cursor: default; }
.card-inner {
    position: absolute;
    inset: 0;
    transform-style: preserve-3d;
    transition: transform 0.48s cubic-bezier(.2,.75,.2,1);
}
.memory-card.is-flipped .card-inner { transform: rotateY(180deg); }
.card-face {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
    backface-visibility: hidden;
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: clamp(14px, 1.6vw, 22px);
    background: #fff;
    box-shadow: 0 18px 34px rgba(55, 35, 18, 0.16);
}
.card-front { transform: rotateY(180deg); padding: 9%; }
.card-back { align-items: center; padding: 9%; }
.back-logo {
    margin: auto 0;
    display: grid;
    place-items: center;
    text-align: center;
    color: #5c5c5c;
    line-height: 1.15;
}
.back-logo strong { font-family: Cairo, sans-serif; font-size: clamp(12px, 1.1vw, 16px); }
.back-logo span { font-size: clamp(11px, 1vw, 14px); font-weight: 900; }
.front-logo {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    color: #666;
    line-height: 1.1;
    font-size: clamp(10px, 0.85vw, 13px);
    font-weight: 900;
}
.front-logo strong { display: block; font-family: Cairo, sans-serif; }
.front-logo span { display: block; }
.paint-swatch {
    flex: 1;
    margin: 8% 0 6%;
    border-radius: 12px;
    background: #ddd;
    box-shadow: inset 0 0 0 1px rgba(0,0,0,.04);
}
.paint-info {
    text-align: center;
    padding-bottom: 6%;
    line-height: 1.1;
}
.paint-info strong { display: block; font-size: clamp(14px, 1.55vw, 23px); letter-spacing: -0.04em; }
.paint-info span { display: block; color: #555; font-size: clamp(11px, 1vw, 15px); font-weight: 800; margin-top: 4px; }
.color-bar {
    width: 100%;
    height: 6%;
    min-height: 8px;
    border-radius: 3px;
    background: linear-gradient(90deg,
        #f9c23b 0 10%, #f58220 10% 20%, #e1261c 20% 35%, #8e1b1b 35% 48%,
        #0072bc 48% 66%, #00a5df 66% 76%, #21a451 76% 90%, #0b6b2e 90% 100%);
}
.memory-card.is-matched .card-face {
    outline: 3px solid rgba(13, 77, 58, 0.3);
    box-shadow: 0 12px 30px rgba(13, 77, 58, 0.18);
}

.rules-dialog {
    width: min(620px, calc(100% - 32px));
    border: 0;
    border-radius: 28px;
    padding: 28px;
    background: #fffdf9;
    box-shadow: 0 35px 100px rgba(0,0,0,.22);
}
.rules-dialog::backdrop { background: rgba(20, 18, 15, 0.45); backdrop-filter: blur(7px); }
.rules-dialog h2 { font-family: Cairo, Inter, sans-serif; font-size: 38px; letter-spacing: -0.05em; }
.rules-dialog p { margin-top: 12px; color: var(--muted); line-height: 1.8; font-weight: 700; }
.close-dialog {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 50%;
    cursor: pointer;
    background: rgba(13,77,58,.08);
    color: var(--green);
    font-size: 24px;
    font-weight: 900;
}
.dialog-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 20px; }

.winner-overlay[hidden] {
    display: none !important;
}

.winner-overlay {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(28, 21, 13, 0.42);
    backdrop-filter: blur(12px);
}
.winner-card {
    width: min(560px, 100%);
    padding: 34px;
    border-radius: 34px;
    background: #fffdf8;
    box-shadow: 0 34px 120px rgba(0,0,0,.22);
    text-align: center;
}
.winner-card h2 { margin-top: 14px; font-size: clamp(38px, 7vw, 64px); letter-spacing: -0.07em; }
.winner-card p { margin-top: 12px; color: var(--muted); font-size: 18px; font-weight: 800; }
.winner-actions { display: flex; gap: 12px; justify-content: center; margin-top: 24px; flex-wrap: wrap; }
.winner-actions .primary-btn { width: auto; margin: 0; }

@media (max-width: 1080px) {
    .hero-grid { grid-template-columns: 1fr; }
    .game-layout { grid-template-columns: 1fr; }
    .score-sidebar { position: static; grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .score-sidebar .brand-lockup, .how-to, .side-actions { grid-column: 1 / -1; }
    .cards-grid { grid-template-columns: repeat(4, minmax(112px, 1fr)); }
}

@media (max-width: 720px) {
    .landing-shell, .game-layout { width: min(100% - 18px, 100%); }
    .feature-row, .rules-strip, .score-sidebar { grid-template-columns: 1fr 1fr; }
    .cards-grid { grid-template-columns: repeat(3, minmax(88px, 1fr)); }
    .board-header { align-items: flex-start; flex-direction: column; }
    .dialog-grid { grid-template-columns: 1fr 1fr; }
    .hero-panel, .board-section { border-radius: 26px; }
}

@media (max-width: 430px) {
    .feature-row, .rules-strip, .score-sidebar { grid-template-columns: 1fr; }
    .cards-grid { grid-template-columns: repeat(2, minmax(110px, 1fr)); }
}
