:root {
    --cm-ink: #402e2b;
    --cm-cream: #fff9e9;
    --cm-orange: #ed8245;
    --cm-gold: #f5bd58;
    --cm-red: #df4d4d;
    --cm-green: #3fa878;
}

html, body { width: 100%; max-width: 100%; min-height: 100%; overflow-x: hidden; }
body { margin: 0; }
body.cat-mouse-playing { overflow: hidden; overscroll-behavior: none; touch-action: none; }
button, a { -webkit-tap-highlight-color: transparent; }

.cat-mouse-page {
    min-height: 100dvh;
    overflow-x: clip;
    color: var(--cm-ink);
    background:
        radial-gradient(circle at 15% 12%, rgba(255,255,255,.78) 0 7%, transparent 7.2%),
        linear-gradient(145deg, #fff3c8 0%, #f6c875 48%, #e9a052 100%);
}

.cat-mouse-menu { min-height: 100dvh; padding: max(18px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(22px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left)); }
.cat-mouse-menu-shell { width: min(1040px, 100%); max-width: 100%; margin: 0 auto; overflow: hidden; }
.cat-mouse-back { display: inline-flex; min-height: 44px; align-items: center; color: #5d3930; font-size: .83rem; font-weight: 900; text-decoration: none; }

.cat-mouse-hero {
    display: grid;
    grid-template-columns: minmax(260px, .82fr) minmax(0, 1.18fr);
    align-items: center;
    gap: clamp(28px, 6vw, 72px);
    margin-top: clamp(18px, 5vh, 56px);
}
.cat-mouse-hero-copy { min-width: 0; }

.cat-mouse-hero-art {
    position: relative;
    width: min(390px, 100%);
    aspect-ratio: 1;
    display: grid;
    place-items: center;
    justify-self: center;
    border: 4px solid #633c32;
    border-radius: 34% 42% 36% 45%;
    background: rgba(255, 250, 229, .72);
    box-shadow: 16px 18px 0 rgba(111, 61, 45, .18);
    transform: rotate(-3deg);
}

.cat-mouse-hero-art::before,
.cat-mouse-hero-art::after { content: ""; position: absolute; z-index: 0; border-radius: 50%; background: rgba(237,130,69,.24); }
.cat-mouse-hero-art::before { width: 26%; aspect-ratio: 1; left: -8%; bottom: 12%; }
.cat-mouse-hero-art::after { width: 18%; aspect-ratio: 1; right: 3%; top: -6%; }
.cat-mouse-hero-art img { position: relative; z-index: 1; width: 78%; height: 78%; filter: drop-shadow(0 15px 12px rgba(70, 35, 28, .18)); }
.cat-mouse-kicker { color: #9a4d2e; font-size: .72rem; font-weight: 950; letter-spacing: .17em; }
.cat-mouse-hero h1 { max-width: 100%; margin: 7px 0 10px; color: #4d302b; font-size: clamp(3.2rem, 8vw, 6.4rem); line-height: .88; letter-spacing: -.075em; overflow-wrap: anywhere; white-space: normal; }
.cat-mouse-hero p { max-width: 620px; margin: 0; color: #76544b; font-size: clamp(1rem, 2vw, 1.22rem); font-weight: 700; line-height: 1.55; }
.cat-mouse-menu-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 25px; }
.cat-mouse-primary, .cat-mouse-secondary, .cat-mouse-sound {
    min-height: 52px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 24px;
    border: 2px solid #52332d;
    border-radius: 15px;
    font: 950 .82rem/1 inherit;
    letter-spacing: .06em;
    text-decoration: none;
    cursor: pointer;
}
.cat-mouse-primary { background: #4f342f; color: #ffffff; box-shadow: 5px 6px 0 #ed8245; }
.cat-mouse-secondary, .cat-mouse-sound { background: rgba(255,255,255,.72); color: #53352f; }
.cat-mouse-sound span { margin-left: 6px; color: #2f8d69; }
.cat-mouse-sound[aria-pressed="false"] span { color: #c64b4b; }
.cat-mouse-records { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: clamp(30px, 7vh, 72px); }
.cat-mouse-records > div { min-width: 0; padding: 16px 18px; border: 2px solid rgba(83,53,47,.16); border-radius: 18px; background: rgba(255,255,255,.48); }
.cat-mouse-records span { display: block; color: #936451; font-size: .64rem; font-weight: 950; letter-spacing: .12em; }
.cat-mouse-records strong { display: block; margin-top: 5px; color: #4d302b; font-size: 1.7rem; }
.cat-mouse-tip { margin: 12px 0 0; padding: 14px 17px; border-radius: 16px; background: rgba(255,255,255,.34); color: #74544c; font-size: .83rem; line-height: 1.5; overflow-wrap: anywhere; }
.cat-mouse-tip strong { margin-right: 7px; color: #9a4d2e; letter-spacing: .08em; }

.cat-mouse-game[hidden] { display: none; }
.cat-mouse-game { position: fixed; z-index: 100; inset: 0; width: 100vw; height: 100dvh; overflow: hidden; background: #d49b5c; touch-action: none; user-select: none; -webkit-user-select: none; }
#catMouseCanvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
.cat-mouse-hud { position: absolute; z-index: 4; top: max(10px, env(safe-area-inset-top)); left: max(10px, env(safe-area-inset-left)); right: max(10px, env(safe-area-inset-right)); display: grid; grid-template-columns: minmax(82px, auto) minmax(140px, 1fr) minmax(82px, auto) 44px; align-items: center; gap: 10px; pointer-events: none; }
.cat-mouse-hud-pill { min-height: 48px; display: flex; align-items: center; gap: 8px; padding: 0 14px; border: 2px solid rgba(64,46,43,.72); border-radius: 14px; background: rgba(255,249,233,.91); box-shadow: 3px 4px 0 rgba(90,55,45,.18); }
.cat-mouse-hud-pill span { color: #8d5e50; font-size: .58rem; font-weight: 950; letter-spacing: .1em; }
.cat-mouse-hud-pill strong { color: #4d302b; font-size: 1.35rem; }
.cat-mouse-combo strong { color: #d3543e; }
.cat-mouse-time { position: relative; height: 46px; overflow: hidden; border: 2px solid rgba(64,46,43,.72); border-radius: 14px; background: rgba(255,249,233,.91); box-shadow: 3px 4px 0 rgba(90,55,45,.18); }
.cat-mouse-time > span { position: absolute; inset: 0 auto 0 0; width: 100%; background: linear-gradient(90deg, #4fbe86, #f4c95d); transform-origin: left; }
.cat-mouse-time strong { position: absolute; inset: 0; display: grid; place-items: center; color: #3f302c; font-size: 1.22rem; text-shadow: 0 1px rgba(255,255,255,.7); }
.cat-mouse-quit { width: 44px; height: 44px; border: 2px solid rgba(64,46,43,.72); border-radius: 13px; background: rgba(255,249,233,.92); color: #51352f; font: 900 1.6rem/1 Arial, sans-serif; cursor: pointer; pointer-events: auto; }
.cat-mouse-countdown { position: absolute; z-index: 5; inset: 0; display: grid; place-items: center; background: rgba(69,42,34,.16); color: #ffffff; font-size: clamp(5rem, 22vw, 13rem); font-weight: 1000; letter-spacing: -.08em; text-shadow: 0 8px 0 #783f30, 0 18px 45px rgba(0,0,0,.25); pointer-events: none; }
.cat-mouse-countdown[hidden] { display: none; }
.cat-mouse-result { position: absolute; z-index: 7; inset: 0; display: grid; place-items: center; padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); background: rgba(53,34,29,.74); backdrop-filter: blur(8px); }
.cat-mouse-result[hidden] { display: none; }
.cat-mouse-result-card { width: min(540px, 100%); padding: clamp(20px, 4vw, 34px); border: 3px solid #54342e; border-radius: 25px; background: #fff9e9; box-shadow: 9px 10px 0 #ed8245; text-align: center; }
.cat-mouse-result-kicker { color: #a85838; font-size: .69rem; font-weight: 950; letter-spacing: .17em; }
.cat-mouse-result h2 { margin: 6px 0 8px; color: #4d302b; font-size: clamp(2rem, 7vw, 3.4rem); letter-spacing: -.055em; }
.cat-mouse-new-record { display: inline-block; margin-bottom: 10px; padding: 6px 10px; border-radius: 999px; background: #f6d365; color: #68452f; font-size: .68rem; font-weight: 950; letter-spacing: .1em; }
.cat-mouse-new-record[hidden] { display: none; }
.cat-mouse-result-score { margin: 9px 0 13px; padding: 13px; border-radius: 17px; background: #f2c56c; }
.cat-mouse-result-score span, .cat-mouse-result-stats span { display: block; color: #89604d; font-size: .62rem; font-weight: 950; letter-spacing: .1em; }
.cat-mouse-result-score strong { display: block; color: #4d302b; font-size: 3rem; line-height: 1; }
.cat-mouse-result-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.cat-mouse-result-stats > div { padding: 11px 6px; border: 1px solid rgba(83,53,47,.14); border-radius: 13px; background: #fffdf4; }
.cat-mouse-result-stats strong { display: block; margin-top: 4px; color: #4d302b; font-size: 1rem; }
.cat-mouse-result-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; }

@media (max-width: 700px) {
    .cat-mouse-menu { padding-left: 14px; padding-right: 14px; }
    .cat-mouse-hero { grid-template-columns: 1fr; gap: 24px; margin-top: 12px; text-align: center; }
    .cat-mouse-hero-art { width: min(250px, 66vw); }
    .cat-mouse-hero h1 { font-size: clamp(2.7rem, 12.5vw, 3.6rem); }
    .cat-mouse-hero p { margin-inline: auto; }
    .cat-mouse-menu-actions { justify-content: center; }
    .cat-mouse-records { gap: 7px; margin-top: 32px; }
    .cat-mouse-records > div { padding: 12px 7px; }
    .cat-mouse-records span { min-height: 2.1em; font-size: .54rem; }
    .cat-mouse-records strong { font-size: 1.3rem; }
    .cat-mouse-hud { grid-template-columns: 70px 1fr 70px 40px; gap: 6px; }
    .cat-mouse-hud-pill { min-height: 42px; justify-content: center; padding: 0 7px; }
    .cat-mouse-hud-pill span { display: none; }
    .cat-mouse-hud-pill strong { font-size: 1.15rem; }
    .cat-mouse-time { height: 40px; }
    .cat-mouse-quit { width: 40px; height: 40px; }
}

@media (max-width: 430px) {
    .cat-mouse-primary, .cat-mouse-sound { min-height: 50px; padding: 0 18px; }
    .cat-mouse-result-card { padding: 19px 14px; }
    .cat-mouse-result-stats { gap: 5px; }
    .cat-mouse-result-stats span { font-size: .51rem; }
    .cat-mouse-result-actions { grid-template-columns: 1fr; }
}

@media (max-height: 700px) and (orientation: landscape) {
    .cat-mouse-hero { margin-top: 8px; }
    .cat-mouse-hero-art { width: min(270px, 42vh); }
    .cat-mouse-records { margin-top: 18px; }
    .cat-mouse-tip { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    .cat-mouse-primary { transition: none; }
}
