@font-face {
    font-family: "ADJMN Arcade";
    src: url("/games/fonts/PressStart2P-Regular.ttf") format("truetype");
    font-style: normal;
    font-weight: 400;
    font-display: swap;
}

:root {
    color-scheme: dark;
    --red: #ef3049;
    --gold: #ffe17b;
    --cyan: #4ce8ff;
    --purple: #21163d;
    --ink: #f5f0ff;
    --body: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --pixel: "ADJMN Arcade", "Courier New", monospace;
}

* { box-sizing: border-box; }

body {
    min-width: 320px;
    margin: 0;
    color: var(--ink);
    background:
        radial-gradient(ellipse at 50% 8%, rgba(105, 54, 174, .32), transparent 38rem),
        radial-gradient(ellipse at 8% 70%, rgba(125, 28, 92, .12), transparent 34rem),
        linear-gradient(180deg, #130d2b, #100b21 54%, #190b23);
    font: 500 1rem/1.55 var(--body);
    -webkit-font-smoothing: antialiased;
}

.topbar {
    min-height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 10px clamp(16px, 5vw, 68px);
    border-bottom: 1px solid #35294b;
    background: rgba(12, 8, 25, .78);
}

.brand { display: inline-flex; min-height: 42px; align-items: center; }
.brand img { display: block; width: 132px; height: auto; }
.topbar nav { display: flex; align-items: center; gap: clamp(12px, 3vw, 28px); }
.top-link {
    color: #d8d0eb;
    font: 700 .875rem/1.2 var(--body);
    letter-spacing: .02em;
    text-decoration: none;
    text-transform: uppercase;
}
.top-link:hover { color: var(--cyan); }
.availability-link { color: #fff; border-bottom: 2px solid var(--red); padding: 7px 0; }

main { width: min(100% - 40px, 920px); margin: 0 auto; }
.intro { padding: clamp(28px, 5vw, 50px) 0 20px; }
.eyebrow {
    margin: 0 0 9px;
    color: var(--cyan);
    font-size: .78rem;
    font-weight: 800;
    letter-spacing: .14em;
    text-transform: uppercase;
}
.intro h1 {
    margin: 0;
    color: #fff1c2;
    font: 400 clamp(1.1rem, 3.7vw, 1.8rem)/1.5 var(--pixel);
    text-shadow: 2px 3px 0 #82325f, 0 0 18px rgba(255, 225, 123, .17);
}
.intro h1 span { color: var(--red); }
.intro > p:last-child { max-width: 58ch; margin: 12px 0 0; color: #d4cde3; font-size: .95rem; }

.arcade-cabinet {
    position: relative;
    width: min(100%, 700px);
    margin: 0 auto;
    padding: clamp(14px, 3vw, 24px);
    border: 5px solid var(--red);
    border-radius: 10px;
    background:
        repeating-linear-gradient(0deg, rgba(120, 113, 155, .04) 0, rgba(120, 113, 155, .04) 1px, transparent 1px, transparent 4px),
        linear-gradient(145deg, rgba(32, 24, 61, .98), rgba(13, 11, 31, .98));
    box-shadow: 0 0 0 4px #372352, 0 0 30px rgba(239, 48, 73, .22), inset 0 0 25px rgba(0, 0, 0, .5);
}

.cabinet-topline { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.cabinet-label { color: var(--cyan); font-size: .76rem; font-weight: 800; letter-spacing: .08em; }
.sound-toggle {
    min-height: 40px;
    padding: 7px 11px;
    border: 1px solid #8066bf;
    border-radius: 4px;
    color: #e4dcf7;
    background: #21163d;
    font: 700 .875rem/1.2 var(--body);
    cursor: pointer;
}
.sound-toggle:hover { border-color: var(--cyan); }
.sound-toggle:focus-visible,
.arcade-button:focus-visible,
.memory-card:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }

.arcade-cabinet > h2 {
    margin: 0;
    color: var(--gold);
    font: 400 clamp(.9rem, 2.8vw, 1.3rem)/1.7 var(--pixel);
    text-align: center;
    text-shadow: 2px 2px #8d3c90;
    text-transform: uppercase;
}
.subtitle {
    margin: 3px 0 15px;
    color: var(--cyan);
    font-size: .76rem;
    font-weight: 800;
    letter-spacing: .13em;
    text-align: center;
}

.hud {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin: 0 0 12px;
    padding: 11px 13px;
    border: 1px solid #655586;
    border-radius: 5px;
    background: #090817;
}
.hud > div { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.hud > div + div { border-left: 1px solid #42365b; padding-left: 12px; }
.hud span { color: #c5badb; font-size: .78rem; font-weight: 800; letter-spacing: .06em; }
.hud strong { color: var(--gold); font: 800 1rem/1.3 var(--body); font-variant-numeric: tabular-nums; }

.message {
    min-height: 44px;
    display: grid;
    place-items: center;
    margin: 0 0 12px;
    padding: 8px 12px;
    border: 1px dashed #ac4280;
    color: var(--cyan);
    background: rgba(5, 7, 20, .62);
    font-size: .9rem;
    font-weight: 700;
    text-align: center;
}
.message.is-good { color: var(--gold); border-color: var(--gold); }
.message.is-bad { color: #ff9eb3; border-color: var(--red); }

.memory-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: clamp(6px, 1.8vw, 10px);
    margin: 0 0 14px;
}
.memory-card {
    position: relative;
    min-width: 0;
    height: clamp(64px, 12vw, 84px);
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: transparent;
    cursor: pointer;
    perspective: 600px;
    touch-action: manipulation;
}
.memory-card:disabled { cursor: default; }
.card-inner {
    position: absolute;
    inset: 0;
    transform-style: preserve-3d;
    transition: transform .28s ease;
}
.memory-card.is-flipped .card-inner,
.memory-card.is-matched .card-inner,
.memory-card.is-hinted .card-inner { transform: rotateY(180deg); }
.card-face {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    overflow: hidden;
    border: 2px solid #5b4c80;
    border-radius: 6px;
    backface-visibility: hidden;
}
.card-front {
    color: var(--cyan);
    background:
        repeating-linear-gradient(0deg, rgba(76, 232, 255, .04) 0, rgba(76, 232, 255, .04) 1px, transparent 1px, transparent 4px),
        linear-gradient(145deg, #2c2152, #141129);
    box-shadow: inset 0 0 13px rgba(76, 232, 255, .09);
}
.record-icon { font-size: clamp(1.25rem, 4vw, 1.8rem); line-height: 1; }
.card-front small { color: #cabfe0; font: 700 .68rem/1.2 var(--body); letter-spacing: .06em; }
.card-back {
    transform: rotateY(180deg);
    border-color: var(--gold);
    color: #fff7df;
    background: radial-gradient(circle at 50% 25%, #51427d, #21163d 72%);
    box-shadow: inset 0 0 13px rgba(255, 225, 123, .08);
}
.genre-emoji { font-size: clamp(1.2rem, 4vw, 1.65rem); line-height: 1; }
.genre-name { max-width: 100%; color: var(--gold); font: 800 .72rem/1.2 var(--body); text-align: center; }
.memory-card.is-matched .card-back { border-color: #79e1b4; background: linear-gradient(145deg, #184e49, #102c31); }
.memory-card.is-matched .genre-name { color: #b4ffe0; }
.memory-card.is-wild .card-back { border-color: var(--cyan); background: radial-gradient(circle at 50% 25%, #19586b, #1c1640 75%); }
.memory-card.is-hinted .card-back { border-color: var(--cyan); box-shadow: 0 0 14px rgba(76, 232, 255, .45); }
.memory-card.is-spent .card-front { border-style: dotted; opacity: .62; }

.start-panel { text-align: center; }
.start-panel p { margin: 0 0 12px; color: #d4cde3; font-size: .9rem; line-height: 1.5; }
.arcade-button {
    min-height: 48px;
    padding: 11px 16px;
    border: 2px solid #ff829e;
    border-radius: 5px;
    color: #fff8f1;
    font: 800 1rem/1.2 var(--body);
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    box-shadow: 0 4px 0 #64142f, 0 0 16px rgba(239, 48, 73, .18), inset 0 0 10px rgba(255,255,255,.1);
    transition: transform .12s ease, filter .12s ease;
}
.arcade-button:hover:not(:disabled) { filter: brightness(1.13); transform: translateY(-1px); }
.arcade-button:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 #64142f; }
.arcade-button:disabled { opacity: .58; cursor: not-allowed; }
.primary-button { background: linear-gradient(180deg, #f34163, #bc1c48); }
.start-panel .primary-button { width: min(100%, 330px); }
.secondary-button { border-color: #8066bf; background: #30225a; box-shadow: 0 4px 0 #1a1032, 0 0 14px rgba(138, 99, 220, .18); }
.other-games { display: inline-flex; align-items: center; justify-content: center; border-color: #8066bf; background: #22163c; box-shadow: 0 4px 0 #120b23; }

.result-panel {
    padding: 16px;
    border: 1px solid #655586;
    border-radius: 6px;
    background: rgba(7, 6, 19, .75);
    text-align: center;
}
.result-panel h3 { margin: 0; color: var(--gold); font: 400 clamp(.8rem, 2vw, 1rem)/1.7 var(--pixel); }
.result-copy { margin: 10px 0 18px; color: var(--cyan); font-weight: 700; }
.result-panel form { max-width: 460px; margin: 0 auto; text-align: left; }
.result-panel label { display: block; margin-bottom: 7px; color: #eee7fa; font-weight: 800; }
.result-panel label span { color: #c4bfd6; font-weight: 500; }
.score-entry { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 9px; }
.score-entry input {
    min-width: 0;
    min-height: 48px;
    padding: 9px 12px;
    border: 1px solid #8066bf;
    border-radius: 4px;
    color: #fff;
    background: #100d20;
    font: 800 1rem/1.2 var(--body);
    text-transform: uppercase;
}
.score-entry input:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.form-help, .score-status { margin: 8px 0 0; color: #c4bfd6; font-size: .82rem; line-height: 1.45; }
.score-status { min-height: 1.4em; color: var(--gold); }
.score-status.is-error { color: #ff9eb3; }
.result-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 18px; }
.game-note { margin: 19px 0 0; color: #c4bfd6; font-size: .86rem; text-align: center; }
.game-note strong { color: #fff1c2; }

footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 8px 20px;
    margin-top: 34px;
    padding: 17px clamp(20px, 5vw, 68px);
    border-top: 1px solid #35294b;
    color: #c4bfd6;
    background: rgba(12, 8, 25, .72);
    font-size: .78rem;
}
footer p { margin: 0; }
footer a { color: #cbc2d7; text-decoration: none; }
footer a:hover { color: var(--cyan); }

[hidden] { display: none !important; }

@media (max-width: 520px) {
    .topbar { min-height: 62px; padding-right: 16px; padding-left: 16px; }
    .brand img { width: 116px; }
    .topbar nav { gap: 13px; }
    .top-link { font-size: .82rem; }
    main { width: min(100% - 28px, 440px); }
    .intro { padding-top: 29px; }
    .intro > p:last-child { font-size: .9rem; }
    .arcade-cabinet { border-width: 4px; padding: 12px; }
    .cabinet-topline { margin-bottom: 12px; }
    .cabinet-label { font-size: .68rem; }
    .sound-toggle { min-height: 38px; padding: 6px 9px; font-size: .8rem; }
    .hud { padding: 9px; }
    .hud > div { align-items: flex-start; flex-direction: column; gap: 2px; }
    .hud > div + div { padding-left: 10px; }
    .memory-grid { gap: 6px; }
    .memory-card { height: 68px; }
    .genre-name { font-size: .68rem; }
    .result-panel { padding: 12px 10px; }
    .result-actions { flex-direction: column; }
    .result-actions > * { width: 100%; }
}

@media (max-width: 360px) {
    .topbar nav { gap: 9px; }
    .brand img { width: 104px; }
    .top-link { font-size: .76rem; }
    main { width: calc(100% - 24px); }
    .arcade-cabinet { padding: 10px; }
    .memory-card { height: 64px; }
    .card-front small { font-size: .62rem; }
    .genre-name { font-size: .64rem; }
    .score-entry { grid-template-columns: 1fr; }
    .score-entry .arcade-button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        scroll-behavior: auto !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}
