:root {
    --bg: #05050f;
    --card-bg: rgba(14, 14, 30, 0.75);
    --text: #e8e8f0;
    --text-secondary: #a2a2c2;
    --accent-1: #6c5ce7;
    --accent-2: #00cec9;
    --accent-3: #fd79a8;
    --accent-4: #fdcb6e;
    --glow-1: rgba(108, 92, 231, 0.5);
    --glow-2: rgba(0, 206, 201, 0.5);
    --glow-3: rgba(253, 121, 168, 0.5);
    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-glow: rgba(255, 255, 255, 0.16);
    --radius-lg: 22px;
    --radius-md: 14px;
    --transition-smooth: cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* ============ Sevnty9 ARCADE HOME ============ */
/* These scoped rules intentionally replace the legacy dark lobby only. The play
   screen above continues to use its original game-stage styling. */
html:has(body#games-page) {
    background: #edf5ff !important;
    scroll-behavior: smooth;
}

body#games-page {
    --arcade-blue: #0c5bef;
    --arcade-deep-blue: #092a82;
    --arcade-ink: #102968;
    --arcade-sky: #eaf4ff;
    min-width: 0;
    background:
        radial-gradient(circle at 8% 16%, rgba(55, 129, 255, .16), transparent 17rem),
        radial-gradient(circle at 92% 4%, rgba(134, 186, 255, .28), transparent 19rem),
        linear-gradient(135deg, #f9fcff 0%, #e7f1ff 48%, #f8fbff 100%) !important;
    color: var(--arcade-ink) !important;
    font-family: "Nunito Sans", Arial, sans-serif !important;
}

body#games-page :where(h1, h2, h3, p) {
    color: var(--arcade-ink) !important;
    font-family: "Nunito Sans", Arial, sans-serif !important;
}

#games-page #particles-canvas,
#games-page .bg-gradient-orb { display: none !important; }

#games-page .arcade-home {
    width: min(1180px, calc(100% - 40px));
    margin: clamp(20px, 4vw, 56px) auto;
    overflow: hidden;
    position: relative;
    border: 1px solid rgba(103, 157, 239, .38);
    border-radius: 30px;
    background: rgba(255,255,255,.92);
    box-shadow: 0 22px 50px rgba(50, 105, 190, .20), inset 0 1px rgba(255,255,255,.94);
}

#games-page .arcade-home::before,
#games-page .arcade-home::after {
    content: "";
    position: absolute;
    pointer-events: none;
    border-radius: 50%;
}

#games-page .arcade-home::before {
    width: 410px;
    height: 410px;
    top: -265px;
    right: -138px;
    background: radial-gradient(circle, rgba(71, 142, 255, .24), rgba(71,142,255,0) 70%);
}

#games-page .arcade-home::after {
    width: 290px;
    height: 290px;
    left: -176px;
    top: 162px;
    background: radial-gradient(circle, rgba(77, 146, 255, .17), rgba(77,146,255,0) 70%);
}

#games-page .arcade-home__spark {
    position: absolute;
    z-index: 2;
    color: #fdbd22;
    text-shadow: 0 5px 12px rgba(244,169,5,.36);
    font-size: 36px;
    animation: arcade-sparkle 3.2s ease-in-out infinite;
}
#games-page .arcade-home__spark--one { top: 40px; right: 43%; }
#games-page .arcade-home__spark--two { top: 190px; right: 7%; font-size: 20px; animation-delay: -1.4s; }
@keyframes arcade-sparkle { 50% { transform: scale(.76) rotate(18deg); opacity: .65; } }

#games-page .arcade-home__orb {
    position: absolute;
    z-index: 0;
    width: 52px;
    aspect-ratio: 1;
    border-radius: 50%;
    background: radial-gradient(circle at 31% 25%, #fff, #bad8ff 55%, #8db9f4);
    box-shadow: 0 10px 22px rgba(51,112,201,.15);
}
#games-page .arcade-home__orb--one { top: 45px; right: 76px; }
#games-page .arcade-home__orb--two { left: 38px; bottom: 55px; width: 27px; opacity: .78; }

#games-page .arcade-hero {
    position: relative;
    z-index: 1;
    min-height: 392px;
    display: grid;
    grid-template-columns: minmax(0, .9fr) minmax(370px, 1.1fr);
    align-items: center;
    padding: clamp(40px, 5vw, 76px) clamp(36px, 7vw, 93px) 35px;
    overflow: hidden;
    background:
      radial-gradient(ellipse at 43% 95%, rgba(86,151,255,.18), transparent 44%),
      linear-gradient(135deg, rgba(255,255,255,.96), rgba(236,246,255,.58));
}

#games-page .arcade-hero::after {
    content: "";
    position: absolute;
    z-index: -1;
    inset: auto -6% -57% 21%;
    height: 85%;
    border-radius: 50% 50% 0 0;
    background: linear-gradient(135deg, rgba(195,222,255,.56), rgba(117,174,255,.16));
    transform: rotate(-10deg);
}

#games-page .arcade-hero__copy { position: relative; z-index: 2; padding-bottom: 8px; }
#games-page .arcade-hero__eyebrow {
    display: inline-flex;
    align-items: center;
    margin-bottom: 17px;
    padding: 6px 11px;
    color: #1559dc;
    background: #e6f0ff;
    border-radius: 999px;
    font-size: .70rem;
    font-weight: 900;
    letter-spacing: .09em;
}
#games-page .arcade-hero h1 {
    margin: 0;
    font-size: clamp(2.5rem, 4.6vw, 4.15rem);
    line-height: .99;
    letter-spacing: -.055em;
    font-weight: 900;
}
#games-page .arcade-hero h1 span { color: var(--arcade-blue); }
#games-page .arcade-hero p {
    max-width: 360px;
    margin: 20px 0 24px;
    font-size: clamp(.9rem, 1.2vw, 1.03rem);
    line-height: 1.65;
    font-weight: 600;
}
#games-page .arcade-primary-button {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 47px;
    padding: 0 21px;
    border-radius: 11px;
    color: #fff !important;
    text-decoration: none;
    background: linear-gradient(135deg, #1976ff, #0753db);
    box-shadow: 0 11px 20px rgba(0, 88, 232, .26), inset 0 1px rgba(255,255,255,.25);
    font-size: .9rem;
    font-weight: 900;
    transition: transform .2s ease, box-shadow .2s ease;
}
#games-page .arcade-primary-button:hover { transform: translateY(-3px); box-shadow: 0 15px 27px rgba(0,88,232,.32); }
#games-page .arcade-primary-button lucide-icon { font-size: 1.25rem; }

#games-page .arcade-hero__art {
    height: 342px;
    min-width: 0;
    position: relative;
    align-self: end;
    isolation: isolate;
}
#games-page .arcade-hero__art::after {
    content: "";
    position: absolute;
    z-index: -1;
    width: 75%;
    height: 20%;
    left: 17%;
    bottom: 2%;
    border-radius: 50%;
    background: rgba(7,82,211,.28);
    filter: blur(22px);
}
#games-page .arcade-hero__art img {
    position: absolute;
    width: 132%;
    max-width: none;
    height: auto;
    right: -14%;
    bottom: -37%;
    mix-blend-mode: screen;
    filter: saturate(.92) contrast(1.04) drop-shadow(0 16px 19px rgba(16,72,168,.28));
}
#games-page .arcade-hero__star { position: absolute; z-index: 2; color: #ffc027; font-size: 33px; }
#games-page .arcade-hero__star--one { top: 36px; left: 12%; transform: rotate(14deg); }
#games-page .arcade-hero__star--two { right: 4%; top: 45%; font-size: 20px; }

#games-page .featured-games {
    position: relative;
    z-index: 2;
    padding: 30px clamp(22px, 4.5vw, 60px) 27px;
    border-top: 1px solid rgba(105,156,232,.17);
}
#games-page .featured-games__heading { display: flex; align-items: center; justify-content: center; gap: 15px; margin: 0 0 23px; text-align: center; }
#games-page .featured-games__heading > span { color: #1170ed; font-size: 1.05rem; }
#games-page .featured-games__heading h2 { margin: 0; font-size: clamp(1.25rem, 2.2vw, 1.7rem); line-height: 1; letter-spacing: -.04em; font-weight: 900; }
#games-page .featured-games__heading p { margin: 6px 0 0; color: #315294 !important; font-size: .76rem; font-weight: 800; }

#games-page .cards-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 15px;
    perspective: 1000px;
}
#games-page .card-wrapper { opacity: 1 !important; transform: none !important; animation: none !important; perspective: 900px; min-width: 0; }
#games-page .card-wrapper[hidden] { display: none !important; }
#games-page .card-3d {
    display: flex;
    flex-direction: column;
    min-height: 294px;
    height: 100%;
    overflow: hidden;
    border: 1px solid #d8e6fa;
    border-radius: 15px;
    background: linear-gradient(145deg, #fff, #f6faff);
    box-shadow: 0 8px 16px rgba(50,94,167,.13);
    transition: border-color .25s ease, box-shadow .25s ease;
}
#games-page .card-3d:hover { border-color: #92bcfb; box-shadow: 0 15px 25px rgba(42,96,184,.2); }
#games-page .card-shine { display: none; }
#games-page .card-image-area {
    display: grid;
    place-items: center;
    height: 138px;
    padding: 9px 10px 0;
    overflow: hidden;
    background: radial-gradient(circle at 50% 100%, #dbeaff, #f9fcff 68%);
}
#games-page .card-image-area img { display: block; width: 128%; max-width: none; height: 142px; object-fit: cover; object-position: center; mix-blend-mode: multiply; }
#games-page .card-body { display: flex; flex: 1; flex-direction: column; align-items: center; padding: 11px 12px 13px; text-align: center; }
#games-page .game-title { margin: 0; font-size: .93rem; line-height: 1.15; font-weight: 900; }
#games-page .game-desc { margin: 7px 0 12px; color: #375387 !important; font-size: .70rem; line-height: 1.38; font-weight: 600; }
#games-page .card-footer { display: flex; align-items: center; gap: 7px; width: 100%; margin-top: auto; }
#games-page :is(.btn-play, .btn-how) { min-height: 30px; border-radius: 8px; font-family: inherit; font-size: .67rem; font-weight: 900; cursor: pointer; }
#games-page .btn-play { flex: 1; border: 1px solid #0d67f1; color: #fff; background: linear-gradient(135deg, #1a79ff, #0755dc); box-shadow: 0 4px 8px rgba(4,79,206,.2); }
#games-page .btn-how { flex: 1.18; border: 1px solid #adcaef; color: #164a9d; background: #fff; }
#games-page :is(.btn-play, .btn-how):hover { transform: translateY(-1px); }

#games-page .arcade-view-all { display: flex; align-items: center; justify-content: center; gap: 8px; min-width: 145px; min-height: 36px; padding: 0 14px; margin: 23px auto 0; border: 1px solid #82afea; border-radius: 9px; background: #fff; color: #0a58d9; font-family: inherit; font-size: .76rem; font-weight: 900; cursor: pointer; }
#games-page .arcade-view-all:hover { background: #f1f7ff; }

#games-page .arcade-stats { display: grid; grid-template-columns: repeat(3, 1fr); align-items: center; padding: 24px clamp(22px, 5vw, 70px); color: #fff; background: linear-gradient(115deg, #0f74f2, #0756db 65%, #0b4bc4); }
#games-page .arcade-stats > div { display: flex; align-items: center; justify-content: center; gap: 13px; min-width: 0; }
#games-page .arcade-stats > div + div { border-left: 1px solid rgba(255,255,255,.24); }
#games-page .arcade-stats__icon { display: grid; place-items: center; width: 43px; height: 43px; color: #ffd646; font-size: 29px; text-shadow: 0 3px 5px rgba(0,45,141,.25); }
#games-page .arcade-stats p { display: grid; margin: 0; color: #fff !important; }
#games-page .arcade-stats strong { color: #fff; font-size: clamp(1rem, 1.7vw, 1.38rem); font-weight: 900; line-height: 1; }
#games-page .arcade-stats small { margin-top: 4px; color: #e7f1ff; font-size: .68rem; font-weight: 800; }

#games-page .howto-modal { position: fixed; z-index: 1000; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(9,33,82,.4); opacity: 0; visibility: hidden; transition: .2s ease; }
#games-page .howto-modal.show { opacity: 1; visibility: visible; }
#games-page .howto-dialog { position: relative; width: min(580px, 100%); padding: 34px; border-radius: 20px; background: #fff; box-shadow: 0 24px 80px rgba(6,36,99,.35); color: var(--arcade-ink); }
#games-page .howto-dialog h2 { margin: 0 0 10px; font-weight: 900; }
#games-page .howto-summary { color: #315294 !important; font-weight: 600; }
#games-page .howto-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
#games-page .howto-panel { padding: 14px; border-radius: 12px; background: #f2f7ff; }
#games-page .howto-panel h3 { margin: 0 0 7px; font-size: .9rem; }
#games-page .howto-panel ul { margin: 0; padding-left: 17px; color: #315294; font-size: .8rem; line-height: 1.5; }
#games-page .btn-close-howto { position: absolute; top: 12px; right: 12px; display: grid; place-items: center; width: 31px; height: 31px; border: 0; border-radius: 50%; color: #174b9d; background: #edf4ff; cursor: pointer; }

@media (max-width: 1024px) {
    #games-page .arcade-home { width: min(850px, calc(100% - 32px)); }
    #games-page .arcade-hero { min-height: 335px; grid-template-columns: .84fr 1.16fr; padding: 46px 50px 20px; }
    #games-page .arcade-hero h1 { font-size: clamp(2.25rem, 5.9vw, 3.55rem); }
    #games-page .arcade-hero__art { height: 290px; }
    #games-page .arcade-hero__art img { width: 145%; right: -23%; bottom: -43%; }
    #games-page .cards-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; max-width: 600px; margin: auto; }
    #games-page .card-3d { min-height: 309px; }
    #games-page .card-image-area { height: 151px; }
    #games-page .card-image-area img { height: 153px; }
}

@media (max-width: 620px) {
    #games-page .arcade-home { width: min(100% - 22px, 480px); margin: 12px auto 24px; border-radius: 22px; }
    #games-page .arcade-home__orb--one { top: 18px; right: 20px; width: 31px; }
    #games-page .arcade-home__spark--one { top: 22px; right: 31%; font-size: 22px; }
    #games-page .arcade-home__spark--two { top: 218px; right: 8%; font-size: 15px; }
    #games-page .arcade-hero { min-height: 435px; display: block; padding: 40px 25px 0; }
    #games-page .arcade-hero__eyebrow { margin-bottom: 11px; font-size: .58rem; }
    #games-page .arcade-hero h1 { font-size: clamp(2rem, 10.1vw, 2.8rem); }
    #games-page .arcade-hero p { max-width: 215px; margin: 13px 0 15px; font-size: .72rem; line-height: 1.55; }
    #games-page .arcade-primary-button { min-height: 35px; padding: 0 12px; border-radius: 8px; font-size: .65rem; }
    #games-page .arcade-primary-button lucide-icon { font-size: .95rem; }
    #games-page .arcade-hero__art { position: absolute; right: 0; bottom: 0; width: 70%; height: 250px; }
    #games-page .arcade-hero__art img { width: 182%; right: -46%; bottom: -33%; }
    #games-page .arcade-hero__star--one { top: 20px; left: 1%; font-size: 20px; }
    #games-page .arcade-hero__star--two { top: 47%; right: 4%; font-size: 13px; }
    #games-page .featured-games { padding: 23px 14px 19px; }
    #games-page .featured-games__heading { gap: 9px; margin-bottom: 15px; }
    #games-page .featured-games__heading h2 { font-size: 1rem; }
    #games-page .featured-games__heading p { font-size: .58rem; margin-top: 4px; }
    #games-page .cards-grid { gap: 10px; }
    #games-page .card-3d { min-height: 246px; border-radius: 11px; }
    #games-page .card-image-area { height: 105px; padding-top: 4px; }
    #games-page .card-image-area img { width: 137%; height: 111px; }
    #games-page .card-body { padding: 8px 7px 9px; }
    #games-page .game-title { font-size: .68rem; }
    #games-page .game-desc { margin: 5px 0 8px; font-size: .56rem; line-height: 1.28; }
    #games-page .card-footer { gap: 4px; }
    #games-page :is(.btn-play, .btn-how) { min-height: 25px; border-radius: 6px; font-size: .51rem; }
    #games-page .arcade-view-all { min-width: 119px; min-height: 30px; margin-top: 16px; font-size: .62rem; }
    #games-page .arcade-stats { padding: 15px 7px; }
    #games-page .arcade-stats > div { gap: 4px; }
    #games-page .arcade-stats__icon { width: 27px; height: 28px; font-size: 18px; }
    #games-page .arcade-stats strong { font-size: .72rem; }
    #games-page .arcade-stats small { margin-top: 2px; font-size: .43rem; }
    #games-page .howto-dialog { padding: 28px 19px 20px; }
    #games-page .howto-grid { grid-template-columns: 1fr; }
}

/* ============ GLOBAL OVERRIDES FOR Sevnty9 INTEGRATION ============ */
html {
    background: #05050f !important;
    background-color: #05050f !important;
}

body#games-page:not(#home):not(#quiz-page),
body#play-page:not(#home):not(#quiz-page) {
    background: #05050f !important;
    background-color: #05050f !important;
    color: #e8e8f0 !important;
    font-family: var(--gx-font-body) !important;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body#games-page:not(#home):not(#quiz-page)::before,
body#games-page:not(#home):not(#quiz-page)::after,
body#play-page:not(#home):not(#quiz-page)::before,
body#play-page:not(#home):not(#quiz-page)::after {
    display: none !important;
    content: none !important;
    background: none !important;
}

/* Fix text and heading contrast for lobby and play pages */
body#games-page:not(#home):not(#quiz-page) :where(h1, h2, h3, h4, h5, h6, p, .subtitle, .coming-text, .btn-back-home, .filter-tag),
body#play-page:not(#home):not(#quiz-page) :where(h1, h2, h3, h4, h5, h6, p, .subtitle, .btn-close-modal, .stat-box, .control-help) {
    color: #e8e8f0 !important;
}

body#games-page:not(#home):not(#quiz-page) :where(main, .cards-grid) :where(h1, h2, .game-title),
body#play-page:not(#home):not(#quiz-page) :where(.play-container, .game-modal-inline) :where(h2, #modalGameTitle) {
    color: #ffffff !important;
}

/* Remove white box background and borders under Sevnty9 Arcade header */
body#games-page:not(#home):not(#quiz-page) .header,
body#play-page:not(#home):not(#quiz-page) .header {
    background: transparent !important;
    background-color: transparent !important;
    border: none !important;
    border-bottom: none !important;
    box-shadow: none !important;
    padding: 0 !important;
}

body#games-page:not(#home):not(#quiz-page) .header h1 {
    color: #ffffff !important;
    text-shadow: 0 0 20px rgba(0, 206, 201, 0.45) !important;
    background: none !important;
    -webkit-text-fill-color: #ffffff !important;
    background-clip: unset !important;
}

#games-page {
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ============ GAMEPLAY PAGE STYLES ============ */
body#play-page:not(#home):not(#quiz-page) {
    min-height: 100vh;
    min-height: 100dvh;
    overflow: hidden;
    position: relative;
}

.play-container {
    position: relative;
    z-index: 1;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.game-modal-inline {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

#play-page .game-modal-content {
    background: transparent;
    border: none;
    box-shadow: none;
    --game-stage-width: min(98vw, calc((100dvh - 130px) * 1.5), 1600px);
}

/* ============ ANIMATED BACKGROUND ============ */
#particles-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    opacity: 0.55;
}

.bg-gradient-orb {
    position: fixed;
    border-radius: 50%;
    filter: blur(140px);
    opacity: 0.25;
    pointer-events: none;
    z-index: 0;
    animation: orbFloat 22s ease-in-out infinite;
}
.bg-gradient-orb.orb-1 {
    width: 650px;
    height: 650px;
    background: radial-gradient(circle, #6c5ce7 0%, transparent 70%);
    top: -10%;
    left: -8%;
}
.bg-gradient-orb.orb-2 {
    width: 550px;
    height: 550px;
    background: radial-gradient(circle, #00cec9 0%, transparent 70%);
    bottom: -8%;
    right: -6%;
    animation-duration: 25s;
    animation-delay: -5s;
}
.bg-gradient-orb.orb-3 {
    width: 450px;
    height: 450px;
    background: radial-gradient(circle, #fd79a8 0%, transparent 70%);
    top: 40%;
    left: 55%;
    animation-duration: 27s;
    animation-delay: -10s;
}

@keyframes orbFloat {
    0%, 100% { transform: translate(0, 0) scale(1); }
    25% { transform: translate(60px, -40px) scale(1.1); }
    50% { transform: translate(-30px, 35px) scale(0.95); }
    75% { transform: translate(-45px, -25px) scale(1.05); }
}

/* ============ MAIN CONTAINER ============ */
.main-container {
    position: relative;
    z-index: 1;
    max-width: 1500px;
    margin: 0 auto;
    padding: 32px clamp(16px, 3vw, 42px) 80px;
}

/* ============ ARCADE TOP BAR ============ */
.arcade-top-bar {
    display: flex;
    justify-content: flex-start;
    margin-bottom: 20px;
}
.btn-back-home {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    padding: 10px 20px;
    border-radius: 50px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-subtle);
    transition: all 0.3s var(--transition-smooth);
}
.btn-back-home:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.07);
    border-color: var(--border-glow);
    box-shadow: 0 4px 20px rgba(108, 92, 231, 0.15);
    transform: translateX(-3px);
}

/* ============ HEADER ============ */
.header {
    text-align: center;
    margin-bottom: 40px;
    animation: fadeInDown 0.9s var(--transition-smooth) forwards;
}
@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-30px); }
    to { opacity: 1; transform: translateY(0); }
}
.header .logo-icon {
    display: inline-flex;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
    border-radius: 18px;
    margin-bottom: 12px;
    box-shadow: 0 8px 32px rgba(108, 92, 231, 0.4);
    animation: logoPulse 3s ease-in-out infinite;
    font-size: 30px;
    align-items: center;
    justify-content: center;
}
@keyframes logoPulse {
    0%, 100% { box-shadow: 0 8px 32px rgba(108, 92, 231, 0.4); }
    50% { box-shadow: 0 8px 55px rgba(0, 206, 201, 0.65); }
}
.header h1 {
    font-size: 3rem;
    font-weight: 850;
    letter-spacing: -0.03em;
    background: linear-gradient(135deg, #ffffff 0%, #c4c4e0 40%, #a0d2db 70%, #ffffff 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 4px 0;
}
.header .subtitle {
    font-size: 1.05rem;
    color: var(--text-secondary);
    letter-spacing: 0.02em;
    font-weight: 400;
}

/* ============ FILTER TAGS ============ */
.filter-tags {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    margin-bottom: 45px;
    animation: fadeInUp 0.8s var(--transition-smooth) 0.2s forwards;
    opacity: 0;
}
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
.filter-tag {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 22px;
    border-radius: 50px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.35s var(--transition-smooth);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    user-select: none;
}
.filter-tag:hover {
    background: rgba(255, 255, 255, 0.07);
    border-color: var(--border-glow);
    color: #fff;
    box-shadow: 0 4px 20px rgba(108, 92, 231, 0.2);
    transform: translateY(-2px);
}
.filter-tag.active {
    background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
    border-color: transparent;
    color: #fff;
    font-weight: 700;
    box-shadow: 0 6px 24px var(--glow-1);
}

/* ============ CARDS GRID ============ */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: clamp(20px, 2.4vw, 36px);
    perspective: 2000px;
    position: relative;
    z-index: 2;
}

/* ============ 3D CARD ============ */
.card-wrapper {
    perspective: 900px;
    animation: cardAppear 0.7s var(--transition-smooth) forwards;
    opacity: 0;
    transform: translateY(30px);
}
@keyframes cardAppear {
    to { opacity: 1; transform: translateY(0); }
}
.card-wrapper:nth-child(1) { animation-delay: 0.05s; }
.card-wrapper:nth-child(2) { animation-delay: 0.1s; }
.card-wrapper:nth-child(3) { animation-delay: 0.15s; }
.card-wrapper:nth-child(4) { animation-delay: 0.2s; }
.card-wrapper:nth-child(5) { animation-delay: 0.25s; }

.card-3d {
    position: relative;
    width: 100%;
    min-height: 430px;
    border-radius: var(--radius-lg);
    background: var(--card-bg);
    border: 1px solid var(--border-subtle);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    cursor: pointer;
    transition: box-shadow 0.5s var(--transition-smooth), border-color 0.5s var(--transition-smooth);
    transform-style: preserve-3d;
    transform: rotateX(0deg) rotateY(0deg);
    will-change: transform;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
}
.card-3d:hover {
    border-color: var(--border-glow);
    box-shadow: 0 20px 60px rgba(108, 92, 231, 0.25), 0 0 0 1px rgba(255, 255, 255, 0.06) inset;
}
.card-3d .card-shine {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
    border-radius: var(--radius-lg);
    background: radial-gradient(ellipse at center, rgba(255,255,255,0.05) 0%, transparent 70%);
    opacity: 0;
    transition: opacity 0.5s;
}
.card-3d:hover .card-shine { opacity: 1; }

.card-image-area {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 7;
    min-height: 190px;
    overflow: hidden;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    transform: translateZ(20px);
}
.card-image-area img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    transition: transform 0.7s var(--transition-smooth);
}
.card-3d:hover .card-image-area img { transform: scale(1.1); }
.card-image-area .game-badge {
    position: absolute;
    top: 14px;
    right: 14px;
    padding: 6px 14px;
    border-radius: 50px;
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(255,255,255,0.2);
    color: #fff;
    z-index: 2;
    transform: translateZ(25px);
    background: rgba(0, 206, 201, 0.75);
}
.card-body {
    padding: 20px 20px 14px;
    transform: translateZ(15px);
    position: relative;
    z-index: 1;
}
.card-body .game-title {
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: -0.01em;
    margin-bottom: 5px;
    color: #fff;
    transition: color 0.4s;
}
.card-3d:hover .game-title {
    background: linear-gradient(135deg, #fff, #c4d4ff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.card-body .game-genre {
    font-size: 0.8rem;
    color: var(--text-secondary);
    letter-spacing: 0.03em;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.game-genre .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}
.card-body .game-desc {
    font-size: 0.82rem;
    color: #9393a8;
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 8px;
}
.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    margin-top: 8px;
    transform: translateZ(18px);
}
.card-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.card-footer .btn-play,
.card-footer .btn-how {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 20px;
    border-radius: 50px;
    font-weight: 700;
    font-size: 0.82rem;
    letter-spacing: 0.03em;
    cursor: pointer;
    transition: all 0.35s var(--transition-smooth);
    color: #fff;
    background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
    box-shadow: 0 4px 16px rgba(108,92,231,0.35);
    position: relative;
    overflow: hidden;
}
.card-footer .btn-play {
    border: none;
}
.card-footer .btn-how {
    color: #d8d8ee;
    background: rgba(255, 255, 255, 0.045);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: none;
}
.card-footer .btn-how:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.09);
    border-color: rgba(255, 255, 255, 0.22);
    transform: translateY(-2px);
}
.btn-play::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.25) 0%, transparent 60%);
    opacity: 0;
    transition: opacity 0.35s;
}
.btn-play:hover::after { opacity: 1; }
.btn-play:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 28px rgba(108,92,231,0.5);
}

.card-3d.accent-purple:hover { box-shadow: 0 20px 60px rgba(108,92,231,0.35), 0 0 0 1px rgba(108,92,231,0.25) inset; }
.card-3d.accent-teal:hover   { box-shadow: 0 20px 60px rgba(0,206,201,0.35), 0 0 0 1px rgba(0,206,201,0.25) inset; }
.card-3d.accent-pink:hover  { box-shadow: 0 20px 60px rgba(253,121,168,0.35), 0 0 0 1px rgba(253,121,168,0.25) inset; }
.card-3d.accent-gold:hover  { box-shadow: 0 20px 60px rgba(253,203,110,0.35), 0 0 0 1px rgba(253,203,110,0.25) inset; }

/* ============ COMING SOON ============ */
.coming-soon-section {
    margin-top: 60px;
    text-align: center;
    animation: fadeInUp 0.8s var(--transition-smooth) 0.3s forwards;
    opacity: 0;
}
.loading-bar {
    width: 240px;
    height: 6px;
    background: rgba(255,255,255,0.06);
    border-radius: 20px;
    margin: 0 auto 16px;
    overflow: hidden;
    box-shadow: 0 0 12px rgba(108,92,231,0.25);
}
.loading-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-2), var(--accent-1), var(--accent-3));
    border-radius: 20px;
    animation: loadPulse 2.2s ease-in-out infinite;
    background-size: 200% 100%;
}
.coming-text {
    font-family: var(--gx-font-body) ;
    font-size: 0.85rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-secondary);
    animation: textGlow 2.5s ease-in-out infinite alternate;
    margin-top: 10px;
}

@keyframes loadPulse {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

@keyframes textGlow {
    0% {
        color: #a2a2c2;
        text-shadow: 0 0 5px rgba(108, 92, 231, 0.2);
    }
    100% {
        color: #ffffff;
        text-shadow: 0 0 12px var(--accent-2), 0 0 20px var(--accent-1);
    }
}

/* ============ FULLSCREEN INTERACTIVE MODAL OVERLAY ============ */
.game-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #020206;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s cubic-bezier(0.23, 1, 0.32, 1);
}

.game-modal.show {
    opacity: 1;
    pointer-events: all;
}

.game-modal-content {
    background: #04040a;
    width: 100%;
    height: 100%;
    padding: clamp(14px, 2.2vw, 32px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: clamp(10px, 1.5vh, 18px);
    position: relative;
    max-width: 100%;
}

.btn-close-modal {
    position: absolute;
    top: clamp(10px, 2vw, 24px);
    right: clamp(10px, 2.5vw, 32px);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255,255,255,0.08);
    color: var(--text-secondary);
    font-size: 1.25rem;
    font-weight: 300;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.25s var(--transition-smooth);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    line-height: 1;
}
.btn-close-modal:hover {
    color: #fff;
    background: rgba(231, 76, 60, 0.2);
    border-color: rgba(231, 76, 60, 0.4);
    box-shadow: 0 0 20px rgba(231, 76, 60, 0.3);
    transform: scale(1.05) rotate(90deg);
}

.game-header {
    width: 100%;
    max-width: var(--game-stage-width, 980px);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.game-header h2 {
    font-size: clamp(1.35rem, 2.4vw, 2.5rem);
    font-weight: 900;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, #fff 0%, #a29bfe 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.game-stats {
    display: flex;
    gap: 12px;
}

.stat-box {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.07);
    padding: 8px 16px;
    border-radius: 50px;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    color: var(--text-secondary);
}

.glow-val {
    color: var(--accent-2);
    font-weight: 800;
    text-shadow: 0 0 10px rgba(0, 206, 201, 0.6);
}

.game-canvas-container {
    position: relative;
    width: 100%;
    max-width: var(--game-stage-width, 980px);
    aspect-ratio: 3 / 2;
    border-radius: 20px;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.07);
    background: #010103;
    box-shadow: 0 10px 45px rgba(0,0,0,0.8), inset 0 0 40px rgba(0,0,0,0.9);
}

#gameCanvas {
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none; /* Prevents default browser swipe/scroll behaviors during touch play */
}

/* Modal screens overlay */
.overlay-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(4, 4, 10, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
    text-align: center;
    padding: clamp(16px, 3vw, 28px);
    overflow-y: auto;
}

.overlay-interior h3 {
    font-size: clamp(1.6rem, 4vw, 3.2rem);
    font-weight: 950;
    letter-spacing: 0.08em;
    color: #fff;
    text-shadow: 0 0 20px rgba(108, 92, 231, 0.7);
    margin: 0 0 12px;
    text-transform: uppercase;
}

.overlay-interior p {
    font-size: clamp(0.86rem, 1.45vw, 1rem);
    color: var(--text-secondary);
    margin-bottom: clamp(18px, 3vh, 30px);
    max-width: 560px;
    line-height: 1.6;
    margin-left: auto;
    margin-right: auto;
}

.btn-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 34px;
    font-size: 0.92rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    border: none;
    border-radius: 50px;
    color: #fff;
    cursor: pointer;
    background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
    box-shadow: 0 6px 20px rgba(108, 92, 231, 0.4);
    transition: all 0.3s var(--transition-smooth);
    text-transform: uppercase;
}
.btn-action:hover {
    transform: translateY(-2px) scale(1.03);
    box-shadow: 0 8px 30px rgba(108, 92, 231, 0.55);
}

.game-footer-controls {
    width: 100%;
    max-width: var(--game-stage-width, 980px);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.control-help {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.btn-sound {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
    padding: 8px 18px;
    border-radius: 50px;
    cursor: pointer;
    font-weight: 700;
    transition: all 0.25s;
}
.btn-sound:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.orientation-callout {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 10px;
    max-width: 620px;
    margin: 0 auto 16px;
    padding: 10px 14px;
    border-radius: 14px;
    border: 1px solid rgba(0, 206, 201, 0.24);
    background: rgba(0, 206, 201, 0.08);
    color: #dff;
    font-size: 0.86rem;
    font-weight: 700;
    line-height: 1.45;
}

/* ============ HOW TO PLAY MODAL ============ */
.howto-modal {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(3, 3, 8, 0.82);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.howto-modal.show {
    opacity: 1;
    pointer-events: all;
}

.howto-dialog {
    width: min(720px, 100%);
    max-height: min(760px, 92dvh);
    overflow-y: auto;
    position: relative;
    padding: clamp(22px, 3vw, 34px);
    border-radius: 20px;
    background: rgba(10, 10, 24, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55), 0 0 42px rgba(0, 206, 201, 0.12);
}

.btn-close-howto {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 40px;
    height: 40px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    color: #d8d8ee;
    cursor: pointer;
    transition: all 0.25s var(--transition-smooth);
}

.btn-close-howto:hover {
    color: #fff;
    background: rgba(253, 121, 168, 0.16);
    border-color: rgba(253, 121, 168, 0.4);
}

.howto-dialog h2 {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0 46px 12px 0;
    color: #fff;
    font-size: clamp(1.45rem, 3vw, 2.1rem);
    font-weight: 900;
}

.howto-dialog h2 i {
    color: var(--accent-2);
}

.howto-summary {
    margin: 0 0 22px;
    color: #b8b8d0;
    line-height: 1.65;
}

.howto-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.howto-panel {
    padding: 18px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.035);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.howto-panel h3 {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 12px;
    color: #fff;
    font-size: 1rem;
    font-weight: 850;
}

.howto-panel ul {
    margin: 0;
    padding-left: 18px;
    color: #c7c7dc;
    line-height: 1.55;
    font-size: 0.92rem;
}

.howto-panel li + li {
    margin-top: 8px;
}

/* ============ EXIT CONFIRMATION MODAL OVERLAY ============ */
.confirm-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(3, 3, 8, 0.85);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    /* visibility as well as opacity: an invisible full-screen blur layer would otherwise
       stay composited over the game canvas for the whole session. */
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.3s ease, visibility 0s linear 0.3s;
}

.confirm-modal.show {
    opacity: 1;
    visibility: visible;
    pointer-events: all;
    transition-delay: 0s;
}

.confirm-modal-content {
    background: rgba(18, 10, 30, 0.95);
    border: 2px solid #fd79a8;
    box-shadow: 0 0 50px rgba(253, 121, 168, 0.3), inset 0 0 20px rgba(253, 121, 168, 0.1);
    border-radius: 24px;
    padding: 35px;
    max-width: 440px;
    width: 90%;
    text-align: center;
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.23, 1, 0.32, 1);
}

.confirm-modal.show .confirm-modal-content {
    transform: scale(1);
}

.confirm-modal-content h3 {
    font-size: 1.6rem;
    font-weight: 900;
    color: #fd79a8;
    text-shadow: 0 0 15px rgba(253, 121, 168, 0.5);
    margin-bottom: 12px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.confirm-modal-content p {
    font-size: 0.92rem;
    color: #b8b8d0;
    line-height: 1.55;
    margin-bottom: 28px;
}

.confirm-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.btn-confirm {
    padding: 11px 24px;
    border-radius: 50px;
    font-size: 0.88rem;
    font-weight: 750;
    cursor: pointer;
    border: none;
    transition: all 0.25s ease;
}

.btn-confirm.btn-yes {
    background: #e17055;
    color: #fff;
    box-shadow: 0 4px 15px rgba(225, 112, 85, 0.35);
}
.btn-confirm.btn-yes:hover {
    background: #ff7675;
    box-shadow: 0 6px 22px rgba(225, 112, 85, 0.55);
    transform: translateY(-2px);
}

.btn-confirm.btn-no {
    background: rgba(255, 255, 255, 0.04);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.12);
}
.btn-confirm.btn-no:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: #fff;
    transform: translateY(-2px);
}

/* ============ RESPONSIVE ============ */
@media (max-width: 768px) {
    .header h1 { font-size: 2.2rem; }
    .main-container { padding-top: 30px; }
    .cards-grid {
        grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
        gap: 20px;
    }
    .card-3d {
        height: auto;
        min-height: 0;
    }
    .card-image-area {
        min-height: 170px;
    }
    .card-footer {
        align-items: flex-start;
        flex-direction: column;
    }
    .card-actions {
        width: 100%;
        justify-content: flex-start;
    }
    .card-body .game-title { font-size: 1.1rem; }
    .game-modal-content { padding: 20px; }
    .overlay-interior h3 { font-size: 1.8rem; }
    .btn-close-modal { top: 20px; right: 20px; width: 40px; height: 40px; font-size: 1.4rem; }
    .howto-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .cards-grid { grid-template-columns: 1fr; gap: 16px; }
    .card-3d { height: auto; }
    .header h1 { font-size: 1.8rem; }
    .game-header { flex-direction: column; align-items: flex-start; gap: 10px; }
    .game-footer-controls { flex-direction: column; gap: 15px; align-items: flex-start; }
    .card-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }
    .card-footer .btn-play,
    .card-footer .btn-how {
        width: 100%;
        padding-inline: 12px;
        white-space: nowrap;
    }
    #play-page .game-header {
        flex-direction: row;
        align-items: center;
    }
    #play-page .game-footer-controls {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
    #play-page .game-stats {
        flex-wrap: wrap;
    }
}

@media (pointer: coarse) and (orientation: portrait) {
    #play-page .game-modal-content {
        --game-stage-width: min(96vw, 720px);
        justify-content: flex-start;
        padding-top: clamp(54px, 8dvh, 86px);
    }

    .orientation-callout {
        display: flex;
    }
}

@media (max-height: 560px) and (orientation: landscape) {
    #play-page .game-modal-content {
        --game-stage-width: min(78vw, calc((100dvh - 24px) * 1.5));
        align-items: flex-start;
        justify-content: center;
        padding: 8px 58px 8px 10px;
    }

    #play-page .game-canvas-container {
        width: var(--game-stage-width);
        max-width: none;
    }

    #play-page .game-header,
    #play-page .game-footer-controls {
        position: absolute;
        left: calc(var(--game-stage-width) + 24px);
        width: calc(100vw - var(--game-stage-width) - 92px);
        max-width: none;
    }

    #play-page .game-header {
        top: 12px;
        flex-direction: column;
        align-items: flex-start;
    }

    #play-page .game-header h2 {
        font-size: 1.1rem;
        margin: 0;
    }

    #play-page .game-stats {
        flex-direction: column;
        gap: 8px;
    }

    #play-page .stat-box {
        padding: 7px 11px;
        font-size: 0.76rem;
    }

    #play-page .game-footer-controls {
        bottom: 12px;
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    #play-page .control-help {
        font-size: 0.76rem;
        line-height: 1.35;
    }

    #play-page .btn-sound {
        padding: 7px 12px;
        font-size: 0.78rem;
    }

    #play-page .btn-close-modal {
        top: 10px;
        right: 10px;
        width: 40px;
        height: 40px;
    }
}

/* ==========================================================================
   REDESIGNED MODERN NEON GAMEPLAY UI STYLES
   ========================================================================== */

/* 1. PORTRAIT WARNING OVERLAY FOR MOBILE */
.portrait-warning-overlay {
    position: fixed;
    inset: 0;
    background: radial-gradient(circle at center, #0a0a20 0%, #030308 100%);
    z-index: 9999999;
    display: none; /* Shown via media query */
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 30px;
}

.phone-rotate-icon {
    font-size: 4.5rem;
    background: linear-gradient(135deg, #00cec9 0%, #6c5ce7 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 24px;
    filter: drop-shadow(0 0 15px rgba(0, 206, 201, 0.4));
    animation: rotatePhone 2s infinite ease-in-out;
}

@keyframes rotatePhone {
    0%, 100% { transform: rotate(0deg); }
    40%, 60% { transform: rotate(90deg); }
}

.portrait-warning-title {
    font-size: 1.6rem;
    font-weight: 900;
    color: #ffffff !important;
    text-shadow: 0 0 15px rgba(0, 206, 201, 0.5);
    margin-bottom: 12px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.portrait-warning-desc {
    font-size: 0.95rem;
    color: #a2a2c2 !important;
    max-width: 320px;
    line-height: 1.6;
}

@media (pointer: coarse) and (orientation: portrait) {
    .portrait-warning-overlay {
        display: flex !important;
    }
}

/* 2. GAME LAYOUT STABILIZATION */
#play-page .game-modal-content {
    background: radial-gradient(circle at center, #05050f 0%, #010103 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 24px;
    gap: 16px;
    width: 100%;
    height: 100%;
    max-width: 100%;
    position: relative;
    overflow: hidden;
}

/* 3. NEW TOP HEADER BAR */
.game-header-bar {
    width: 100%;
    max-width: var(--game-stage-width, 980px);
    height: 60px;
    padding: 0 24px;
    border-radius: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    z-index: 10;
    
    /* Neon Gradient Border */
    border: 1.5px solid transparent;
    background: linear-gradient(#05050f, #05050f) padding-box, linear-gradient(90deg, #6c5ce7 0%, #00cec9 100%) border-box;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 20px rgba(108, 92, 231, 0.15);
}

.game-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-back-btn {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #a2a2c2 !important;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s ease;
    margin-right: 4px;
}

.header-back-btn:hover {
    color: #ffffff !important;
    background: rgba(255, 255, 255, 0.12);
    border-color: #6c5ce7;
    box-shadow: 0 0 10px rgba(108, 92, 231, 0.4);
    transform: scale(1.05);
}

.game-title-icon {
    font-size: 1.2rem;
    background: linear-gradient(135deg, #00cec9 0%, #6c5ce7 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 0 5px rgba(0, 206, 201, 0.5));
}

.game-title-text {
    font-size: 1.15rem;
    font-weight: 850;
    color: #ffffff !important;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.15);
}

.header-divider {
    color: #2c2c4d;
    font-weight: 300;
    font-size: 1.1rem;
}

.header-stat {
    font-size: 0.85rem;
    font-weight: 750;
    color: #a2a2c2 !important;
    letter-spacing: 0.03em;
}

.header-stat-val {
    color: #00cec9 !important;
    font-weight: 900;
    margin-left: 3px;
    text-shadow: 0 0 10px rgba(0, 206, 201, 0.6);
}

.game-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-btn {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #a2a2c2 !important;
    font-weight: 750;
    cursor: pointer;
    transition: all 0.25s ease;
}

.btn-sound {
    padding: 8px 16px;
    border-radius: 50px;
    font-size: 0.8rem;
    letter-spacing: 0.03em;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-sound:not(.sound-muted) {
    color: #00cec9 !important;
    border-color: rgba(0, 206, 201, 0.35);
    background: rgba(0, 206, 201, 0.05);
    box-shadow: 0 0 12px rgba(0, 206, 201, 0.15);
}

.btn-sound.sound-muted {
    color: #fd79a8 !important;
    border-color: rgba(253, 121, 168, 0.25);
    background: rgba(253, 121, 168, 0.03);
}

.header-btn:hover {
    color: #ffffff !important;
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-1px);
}

.btn-pause {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
    transition: all 0.25s ease;
}

.btn-pause:hover {
    border-color: #00cec9 !important;
    background: rgba(0, 206, 201, 0.08) !important;
    box-shadow: 0 0 15px rgba(0, 206, 201, 0.45) !important;
    color: #ffffff !important;
}

.btn-pause i,
.btn-pause svg {
    display: flex;
    align-items: center;
    justify-content: center;
    width: auto;
    height: auto;
}

/* 4. REDESIGNED START GAME SESSION SCREEN */
#gameStartScreen.overlay-screen {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at center, rgba(8, 8, 20, 0.96) 0%, rgba(3, 3, 8, 0.99) 100%);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px;
    overflow-y: auto;
}

#gameStartScreen.overlay-screen::before,
#gameStartScreen.overlay-screen::after {
    content: '';
    flex-grow: 1;
    min-height: 10px;
}

.start-session-container {
    margin: 0;
    width: 100%;
    max-width: 440px;
    padding: clamp(16px, 4vw, 28px);
    border-radius: 20px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-shrink: 0;
    
    /* Neon Borders Gradient */
    border: 2px solid transparent;
    background: linear-gradient(rgba(12, 12, 28, 0.95), rgba(12, 12, 28, 0.95)) padding-box, linear-gradient(135deg, #00cec9 0%, #6c5ce7 100%) border-box;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.75), 0 0 40px rgba(108, 92, 231, 0.25);
}

.mobile-landscape-tip {
    display: none; /* Hidden on desktop by default */
    background: rgba(0, 206, 201, 0.08);
    border: 1px solid rgba(0, 206, 201, 0.22);
    border-radius: 12px;
    padding: 10px 14px;
    color: #ddffff !important;
    font-size: 0.8rem;
    font-weight: 700;
    line-height: 1.45;
    margin-bottom: 24px;
    align-items: center;
    gap: 12px;
    text-align: left;
    max-width: 100%;
}

@media (pointer: coarse) {
    .mobile-landscape-tip {
        display: flex !important; /* Show only on mobile / touch screen layouts */
    }
}

.mobile-landscape-tip i {
    font-size: 1.2rem;
    color: #00cec9;
    flex-shrink: 0;
}

.start-game-title {
    font-size: clamp(1.8rem, 4.5vw, 2.6rem);
    font-weight: 900;
    font-style: italic;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    background: linear-gradient(135deg, #ffffff 40%, #c4bffd 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 0 12px rgba(108, 92, 231, 0.5));
    margin-bottom: 12px;
}

.start-divider {
    display: flex;
    align-items: center;
    width: 72%;
    gap: 10px;
    margin: 12px 0 20px;
}

.divider-line {
    flex: 1;
    height: 1.5px;
    background: linear-gradient(90deg, rgba(108, 92, 231, 0) 0%, rgba(108, 92, 231, 0.6) 50%, rgba(0, 206, 201, 0.6) 75%, rgba(0, 206, 201, 0) 100%);
}

.divider-diamond {
    width: 8px;
    height: 8px;
    background: #00cec9;
    transform: rotate(45deg);
    box-shadow: 0 0 10px #00cec9;
}

.start-game-desc {
    font-size: 0.92rem;
    color: #a2a2c2 !important;
    line-height: 1.6;
    margin-bottom: 28px;
    max-width: 380px;
}

.btn-start-session {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 14px 44px;
    font-size: 1rem;
    font-weight: 850;
    letter-spacing: 0.05em;
    border: none;
    border-radius: 50px;
    color: #ffffff;
    cursor: pointer;
    background: linear-gradient(90deg, #6c5ce7 0%, #00cec9 100%);
    box-shadow: 0 8px 24px rgba(108, 92, 231, 0.4), 0 0 15px rgba(0, 206, 201, 0.25);
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    text-transform: uppercase;
}

.btn-start-session:hover {
    transform: translateY(-2px) scale(1.03);
    box-shadow: 0 10px 30px rgba(108, 92, 231, 0.55), 0 0 25px rgba(0, 206, 201, 0.4);
}

.start-session-footer {
    width: 100%;
    max-width: 980px;
    padding: 0 40px;
    margin-top: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    z-index: 10;
    flex-shrink: 0;
}

.footer-left-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #a2a2c2 !important;
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.footer-left-controls i {
    color: #00cec9;
    font-size: 1rem;
}

.footer-sound-btn {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #a2a2c2 !important;
    padding: 8px 18px;
    border-radius: 50px;
    font-size: 0.8rem;
    font-weight: 750;
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.footer-sound-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff !important;
    border-color: #00cec9;
    box-shadow: 0 0 12px rgba(0, 206, 201, 0.25);
}

/* 5. REDESIGNED PAUSE MODAL OVERLAY */
.pause-modal-content {
    background: rgba(14, 8, 24, 0.98) !important;
    border: 2px solid #fd79a8 !important;
    box-shadow: 0 0 60px rgba(253, 121, 168, 0.25), inset 0 0 20px rgba(253, 121, 168, 0.05) !important;
    max-width: 420px !important;
    padding: clamp(24px, 6vw, 36px) !important;
    border-radius: 24px !important;
}

.pause-title {
    font-size: 1.6rem !important;
    font-weight: 900 !important;
    color: #fd79a8 !important;
    text-shadow: 0 0 15px rgba(253, 121, 168, 0.4) !important;
    margin-bottom: 10px !important;
    letter-spacing: 0.05em !important;
    text-transform: uppercase !important;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.pause-desc {
    font-size: 0.9rem !important;
    color: #a2a2c2 !important;
    line-height: 1.55 !important;
    margin-bottom: 26px !important;
}

.pause-buttons-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.btn-pause-action {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 12px 24px;
    font-size: 0.92rem;
    font-weight: 800;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    border: none;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.btn-keep-playing {
    background: linear-gradient(90deg, #00cec9 0%, #0984e3 100%);
    color: #ffffff !important;
    box-shadow: 0 4px 15px rgba(0, 206, 201, 0.35);
}

.btn-keep-playing:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 206, 201, 0.55);
}

/* Removed see-result button styles */

.btn-quit-game {
    background: rgba(225, 112, 85, 0.12);
    border: 1px solid rgba(225, 112, 85, 0.35);
    color: #ff7675 !important;
}

.btn-quit-game:hover {
    background: #e17055;
    color: #ffffff !important;
    border-color: #e17055;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(225, 112, 85, 0.45);
}

/* 6. REDESIGNED GAME OVER LAYOUT */
#gameOverScreen.overlay-screen {
    background: rgba(4, 4, 10, 0.92) !important;
}

.game-over-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 20px;
}

.game-over-title {
    font-size: clamp(2.2rem, 6.5vw, 3.8rem);
    font-weight: 950;
    font-style: italic;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    background: linear-gradient(135deg, #a29bfe 10%, #6c5ce7 50%, #00cec9 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 0 15px rgba(108, 92, 231, 0.6));
    margin-bottom: 8px;
    line-height: 1.1;
}

.game-over-score {
    font-size: clamp(1rem, 3vw, 1.35rem) !important;
    font-weight: 750 !important;
    color: #a2a2c2 !important;
    letter-spacing: 0.05em;
    margin-bottom: 28px !important;
}

.btn-play-again {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 36px;
    font-size: 0.92rem;
    font-weight: 850;
    letter-spacing: 0.05em;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    text-transform: uppercase;
    color: #ffffff !important;
    
    /* Transparent interior, gradient neon border */
    border: 2.5px solid transparent;
    background: linear-gradient(#05050f, #05050f) padding-box, linear-gradient(90deg, #6c5ce7 0%, #00cec9 100%) border-box;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
    border-radius: 50px;
}

.btn-play-again:hover {
    transform: translateY(-2px) scale(1.03);
    box-shadow: 0 0 20px rgba(0, 206, 201, 0.4), 0 0 10px rgba(108, 92, 231, 0.25);
    background: linear-gradient(135deg, rgba(108, 92, 231, 0.15), rgba(0, 206, 201, 0.15)) padding-box, linear-gradient(90deg, #6c5ce7 0%, #00cec9 100%) border-box;
}

/* 7. RESPONSIVE OPTIMIZATIONS */
@media (max-width: 768px) {
    .start-session-footer {
        padding: 0 24px;
        bottom: 16px;
    }
}

@media (max-width: 480px) {
    #play-page .game-modal-content {
        padding: 12px;
        gap: 12px;
    }
    
    .game-header-bar {
        height: 52px;
        padding: 0 12px;
    }
    
    .game-title-text {
        font-size: 0.95rem;
    }
    
    .header-divider {
        margin: 0 6px;
        font-size: 0.9rem;
    }
    
    .header-stat {
        font-size: 0.75rem;
    }
    
    .btn-sound {
        padding: 6px 12px;
        font-size: 0.72rem;
    }
    
    .btn-pause {
        width: 32px;
        height: 32px;
        border-radius: 8px;
        font-size: 0.85rem;
    }
    
    .start-session-container {
        padding: 20px;
    }
    
    .start-session-footer {
        flex-direction: column;
        gap: 12px;
        position: static;
        margin-top: 16px;
        padding: 0;
    }
    
    .footer-left-controls {
        font-size: 0.78rem;
    }
}

/* 8. MOBILE LANDSCAPE MAX CANVAS DYNAMIC OPTIMIZATIONS */
@media (max-height: 560px) and (orientation: landscape) {
    #play-page .game-modal-content {
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        padding: 6px !important;
        gap: 6px !important;
    }
    
    #play-page .game-header-bar {
        height: 38px !important;
        padding: 0 12px !important;
        border-radius: 10px !important;
        margin-bottom: 2px !important;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4) !important;
    }
    
    #play-page .header-back-btn {
        width: 26px !important;
        height: 26px !important;
        margin-right: 2px !important;
    }
    
    #play-page .game-title-text {
        font-size: 0.82rem !important;
    }
    
    #play-page .header-divider {
        margin: 0 8px !important;
        font-size: 0.8rem !important;
    }
    
    #play-page .header-stat {
        font-size: 0.72rem !important;
    }
    
    #play-page .header-btn {
        padding: 4px 10px !important;
        font-size: 0.7rem !important;
    }
    
    #play-page .btn-sound {
        padding: 4px 10px !important;
        gap: 5px !important;
    }
    
    #play-page .btn-pause {
        width: 28px !important;
        height: 28px !important;
        border-radius: 6px !important;
    }
    
    #play-page .game-canvas-container {
        /* Maximize canvas height dynamically based on viewport height, preserving 3:2 aspect ratio */
        width: min(92vw, calc((100dvh - 56px) * 1.5)) !important;
        height: min(calc(92vw / 1.5), calc(100dvh - 56px)) !important;
        max-width: none !important;
        border-radius: 12px !important;
        box-shadow: 0 4px 20px rgba(0,0,0,0.6) !important;
    }
    
    #play-page #gameStartScreen.overlay-screen {
        padding: 12px !important;
    }
    
    #play-page .start-session-container {
        max-width: 440px !important;
        padding: 14px 24px !important;
        border-radius: 16px !important;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6) !important;
    }
    
    #play-page .mobile-landscape-tip {
        display: none !important; /* Already rotated! */
    }
    
    #play-page .start-game-title {
        font-size: 1.6rem !important;
        margin-bottom: 4px !important;
    }
    
    #play-page .start-divider {
        margin: 4px 0 10px !important;
    }
    
    #play-page .start-game-desc {
        font-size: 0.8rem !important;
        margin-bottom: 12px !important;
        line-height: 1.4 !important;
    }
    
    #play-page .btn-start-session {
        padding: 8px 28px !important;
        font-size: 0.85rem !important;
    }
    
    #play-page .start-session-footer {
        position: static !important;
        margin-top: 8px !important;
        justify-content: center !important;
        gap: 24px !important;
    }
    
    #play-page .footer-left-controls {
        font-size: 0.72rem !important;
    }
    
    #play-page .footer-sound-btn {
        padding: 4px 12px !important;
        font-size: 0.72rem !important;
    }
}

/* Keep legacy generic lobby selectors from leaking into the redesigned page. */
body#games-page .arcade-home :where(h1, h2, h3, p, .game-title, .game-desc) {
    color: var(--arcade-ink) !important;
    text-shadow: none !important;
    -webkit-text-fill-color: currentColor !important;
}
body#games-page .arcade-home .arcade-hero h1 span { color: var(--arcade-blue) !important; }
body#games-page .arcade-home .arcade-primary-button,
body#games-page .arcade-home .btn-play { color: #fff !important; }
body#games-page .arcade-home .featured-games__heading p,
body#games-page .arcade-home .game-desc { color: #375387 !important; }
body#games-page .arcade-home .arcade-stats p,
body#games-page .arcade-home .arcade-stats strong { color: #fff !important; }

/* Legacy integration rules deliberately carry three ID selectors. Match that
   specificity so their dark-page colour defaults cannot wash out this page. */
body#games-page:not(#home):not(#quiz-page) {
    background:
        radial-gradient(circle at 8% 16%, rgba(55, 129, 255, .16), transparent 17rem),
        radial-gradient(circle at 92% 4%, rgba(134, 186, 255, .28), transparent 19rem),
        linear-gradient(135deg, #f9fcff 0%, #e7f1ff 48%, #f8fbff 100%) !important;
    color: var(--arcade-ink) !important;
}
body#games-page:not(#home):not(#quiz-page) .arcade-home :where(h1, h2, h3, p, .game-title, .game-desc) {
    color: var(--arcade-ink) !important;
    text-shadow: none !important;
    -webkit-text-fill-color: currentColor !important;
}
body#games-page:not(#home):not(#quiz-page) .arcade-home .arcade-hero h1 span { color: var(--arcade-blue) !important; }
body#games-page:not(#home):not(#quiz-page) .arcade-home .arcade-primary-button,
body#games-page:not(#home):not(#quiz-page) .arcade-home .btn-play { color: #fff !important; }
body#games-page:not(#home):not(#quiz-page) .arcade-home .featured-games__heading p,
body#games-page:not(#home):not(#quiz-page) .arcade-home .game-desc { color: #375387 !important; }
body#games-page:not(#home):not(#quiz-page) .arcade-home .arcade-stats p,
body#games-page:not(#home):not(#quiz-page) .arcade-home .arcade-stats strong { color: #fff !important; }

@media (max-width: 620px) {
    body#games-page:not(#home):not(#quiz-page) .arcade-home .cards-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 10px !important;
    }
    body#games-page:not(#home):not(#quiz-page) .arcade-home .card-footer {
        flex-direction: row !important;
        align-items: center !important;
    }
}

/* Final composition pass: the supplied 3D artwork is kept entirely within
   the hero and the game actions maintain comfortable tap targets. */
body#games-page:not(#home):not(#quiz-page) .arcade-home .arcade-hero {
    min-height: 492px;
    padding-bottom: 28px;
}
body#games-page:not(#home):not(#quiz-page) .arcade-home .arcade-hero__art {
    height: 420px;
    align-self: end;
}
body#games-page:not(#home):not(#quiz-page) .arcade-home .arcade-hero__art img {
    width: auto;
    height: 100%;
    right: 0;
    bottom: 0;
    object-fit: contain;
    object-position: right bottom;
}
body#games-page:not(#home):not(#quiz-page) .arcade-home .card-image-area {
    height: 158px;
    min-height: 0;
    padding: 13px 13px 0;
    background: linear-gradient(180deg, #f9fcff 0%, #e9f3ff 100%);
}
body#games-page:not(#home):not(#quiz-page) .arcade-home .card-image-area img {
    width: 100%;
    height: 100%;
    border-radius: 10px 10px 0 0;
    object-fit: cover;
    object-position: center;
    mix-blend-mode: normal;
}
body#games-page:not(#home):not(#quiz-page) .arcade-home .card-body {
    padding: 15px 16px 16px;
}
body#games-page:not(#home):not(#quiz-page) .arcade-home .game-desc {
    min-height: 2.8em;
    margin-bottom: 14px;
}
body#games-page:not(#home):not(#quiz-page) .arcade-home .card-footer {
    flex-direction: row;
    align-items: stretch;
    gap: 9px;
}
body#games-page:not(#home):not(#quiz-page) .arcade-home :is(.btn-play, .btn-how) {
    min-height: 43px;
    padding: 0 12px;
    border-radius: 9px;
    font-size: .76rem;
    line-height: 1;
    white-space: nowrap;
}
body#games-page:not(#home):not(#quiz-page) .arcade-home .btn-play { flex: .94; }
body#games-page:not(#home):not(#quiz-page) .arcade-home .btn-how { flex: 1.06; }

@media (max-width: 1024px) {
    body#games-page:not(#home):not(#quiz-page) .arcade-home .arcade-hero {
        min-height: 420px;
    }
    body#games-page:not(#home):not(#quiz-page) .arcade-home .arcade-hero__art {
        height: 350px;
    }
}

@media (max-width: 620px) {
    body#games-page:not(#home):not(#quiz-page) .arcade-home .arcade-hero {
        min-height: 510px;
        padding: 38px 25px 0;
    }
    body#games-page:not(#home):not(#quiz-page) .arcade-home .arcade-hero__art {
        right: 0;
        bottom: 0;
        left: auto;
        width: 100%;
        height: 245px;
    }
    body#games-page:not(#home):not(#quiz-page) .arcade-home .arcade-hero__art img {
        width: auto;
        height: 100%;
        max-width: none;
        right: 0;
        bottom: 0;
    }
    body#games-page:not(#home):not(#quiz-page) .arcade-home .cards-grid {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }
    body#games-page:not(#home):not(#quiz-page) .arcade-home .card-3d {
        min-height: 129px;
        flex-direction: row;
        align-items: stretch;
    }
    body#games-page:not(#home):not(#quiz-page) .arcade-home .card-image-area {
        flex: 0 0 39%;
        width: 39%;
        height: auto;
        min-height: 129px;
        padding: 7px 0 7px 7px;
        background: #f3f8ff;
    }
    body#games-page:not(#home):not(#quiz-page) .arcade-home .card-image-area img {
        width: 100%;
        height: 100%;
        border-radius: 8px 0 0 8px;
    }
    body#games-page:not(#home):not(#quiz-page) .arcade-home .card-body {
        align-items: flex-start;
        padding: 11px 11px 10px;
        text-align: left;
    }
    body#games-page:not(#home):not(#quiz-page) .arcade-home .game-title {
        font-size: .75rem;
    }
    body#games-page:not(#home):not(#quiz-page) .arcade-home .game-desc {
        min-height: 0;
        margin: 4px 0 8px;
        font-size: .60rem;
        line-height: 1.28;
    }
    body#games-page:not(#home):not(#quiz-page) .arcade-home .card-footer {
        width: 100%;
        gap: 5px;
    }
    body#games-page:not(#home):not(#quiz-page) .arcade-home :is(.btn-play, .btn-how) {
        min-height: 29px;
        padding: 0 6px;
        border-radius: 6px;
        font-size: .54rem;
    }
}

/* Professional How to Play dialog */
body#games-page:not(#home):not(#quiz-page) .howto-modal {
    z-index: 100000;
    display: grid;
    place-items: center;
    padding: clamp(16px, 3vw, 42px);
    background: rgba(8, 35, 88, .47);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .22s ease, visibility .22s ease;
}
body#games-page:not(#home):not(#quiz-page) .howto-modal.show {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}
body#games-page:not(#home):not(#quiz-page) .howto-dialog {
    width: min(980px, 100%);
    max-height: min(760px, calc(100dvh - 32px));
    overflow: auto;
    position: relative;
    padding: clamp(28px, 4.2vw, 52px);
    border: 1px solid rgba(255,255,255,.96);
    border-radius: 32px;
    color: #153474;
    background: linear-gradient(145deg, #fff 0%, #fbfdff 100%);
    box-shadow: 0 28px 80px rgba(5, 28, 79, .34), 0 2px 0 rgba(255,255,255,.8) inset;
    transform: translateY(12px) scale(.985);
    transition: transform .24s cubic-bezier(.2,.8,.2,1);
    scrollbar-width: thin;
    scrollbar-color: #b6cff6 transparent;
}
body#games-page:not(#home):not(#quiz-page) .howto-modal.show .howto-dialog { transform: translateY(0) scale(1); }
body#games-page:not(#home):not(#quiz-page) .howto-dialog h2 {
    display: flex;
    align-items: center;
    gap: 15px;
    margin: 0 74px 16px 0;
    color: #173678 !important;
    font-size: clamp(1.72rem, 3.1vw, 2.6rem);
    line-height: 1.08;
    font-weight: 900;
    letter-spacing: -.04em;
    -webkit-text-fill-color: #173678 !important;
}
body#games-page:not(#home):not(#quiz-page) .howto-dialog h2 lucide-icon {
    display: grid;
    flex: 0 0 auto;
    place-items: center;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    color: #0d67ef;
    background: #edf5ff;
    font-size: 1.7rem;
}
body#games-page:not(#home):not(#quiz-page) .howto-summary {
    max-width: 790px;
    margin: 0 0 30px;
    color: #486499 !important;
    font-size: clamp(.97rem, 1.55vw, 1.13rem);
    line-height: 1.62;
    font-weight: 650;
    -webkit-text-fill-color: #486499 !important;
}
body#games-page:not(#home):not(#quiz-page) .howto-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: clamp(15px, 2vw, 22px);
}
body#games-page:not(#home):not(#quiz-page) .howto-panel {
    min-height: 250px;
    padding: clamp(19px, 2.3vw, 27px);
    border: 1px solid #e3edfc;
    border-radius: 20px;
    background: linear-gradient(145deg, #f4f8ff, #edf4ff);
}
body#games-page:not(#home):not(#quiz-page) .howto-panel h3 {
    margin: 0 0 15px;
    color: #2356ad !important;
    font-size: .94rem;
    font-weight: 900;
    letter-spacing: .01em;
    text-transform: uppercase;
    -webkit-text-fill-color: #2356ad !important;
}
body#games-page:not(#home):not(#quiz-page) .howto-panel ul {
    display: grid;
    gap: 12px;
    margin: 0;
    padding: 0 0 0 22px;
    color: #284f94;
    font-size: clamp(.91rem, 1.35vw, 1.06rem);
    line-height: 1.52;
    font-weight: 650;
}
body#games-page:not(#home):not(#quiz-page) .howto-panel li { padding-left: 2px; }
body#games-page:not(#home):not(#quiz-page) .howto-panel li::marker { color: #176cf2; font-size: 1.05em; }
body#games-page:not(#home):not(#quiz-page) .btn-close-howto {
    top: clamp(18px, 2.4vw, 28px);
    right: clamp(18px, 2.4vw, 28px);
    display: grid;
    place-items: center;
    width: 54px;
    height: 54px;
    border: 0;
    border-radius: 50%;
    color: #1956ab;
    background: #eef5ff;
    box-shadow: 0 8px 20px rgba(35,85,169,.10);
    font-size: 1.35rem;
}
body#games-page:not(#home):not(#quiz-page) .btn-close-howto:hover {
    color: #fff;
    border-color: transparent;
    background: #1669e9;
    transform: rotate(90deg);
}

@media (max-width: 620px) {
    body#games-page:not(#home):not(#quiz-page) .howto-modal { padding: 12px; align-items: end; }
    body#games-page:not(#home):not(#quiz-page) .howto-dialog {
        max-height: min(85dvh, 680px);
        padding: 25px 18px 20px;
        border-radius: 24px;
    }
    body#games-page:not(#home):not(#quiz-page) .howto-dialog h2 { margin: 0 48px 11px 0; font-size: 1.36rem; }
    body#games-page:not(#home):not(#quiz-page) .howto-dialog h2 lucide-icon { width: 39px; height: 39px; font-size: 1.25rem; }
    body#games-page:not(#home):not(#quiz-page) .howto-summary { margin-bottom: 18px; font-size: .84rem; }
    body#games-page:not(#home):not(#quiz-page) .howto-grid { grid-template-columns: 1fr; gap: 10px; }
    body#games-page:not(#home):not(#quiz-page) .howto-panel { min-height: 0; padding: 16px; border-radius: 15px; }
    body#games-page:not(#home):not(#quiz-page) .howto-panel h3 { margin-bottom: 9px; font-size: .77rem; }
    body#games-page:not(#home):not(#quiz-page) .howto-panel ul { gap: 6px; padding-left: 18px; font-size: .78rem; line-height: 1.43; }
    body#games-page:not(#home):not(#quiz-page) .btn-close-howto { top: 14px; right: 14px; width: 38px; height: 38px; font-size: 1rem; }
}

/* ---------- POPUP SIZING ----------
   These pages have no global border-box reset, so popup padding was added on top of
   width/height: 100% and pushed the panels wider and taller than the screen. */
.howto-dialog,
.game-modal-content,
.overlay-screen,
.overlay-screen > *,
.confirm-modal-content {
    box-sizing: border-box;
}

/* One full-width track, so the dialog's width: 100% means the screen, not its own content. */
.howto-modal {
    grid-template-columns: minmax(0, 1fr);
}

.confirm-modal {
    inset: 0;
    width: auto;
    height: auto;
    box-sizing: border-box;
    padding: 16px;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.confirm-modal-content {
    width: 100%;
    margin: auto; /* stays centred, and scrolls from the top when taller than the screen */
}

/* The game shell is opaque and covers the whole screen, so the animated background
   layers behind it are never visible. Leaving them running only costs frames mid-game. */
#play-page .bg-gradient-orb,
#play-page #particles-canvas {
    display: none;
}
