/* ============================================================
   חדר המשחקים + משחק "תותח החלל"
   משתמש במשתני העיצוב של game-ui2.css (--u-*)
   ============================================================ */

/* ---------- כפתור בסרגל הצד ---------- */
.action-rail .games-btn { --c1: #ffa06b; --c2: #ff6a3d; --edge: #c43c14; }
.action-rail .toolbar-btn-base:nth-child(7) { animation-delay: .58s; }
.action-rail .toolbar-btn-base:nth-child(8) { animation-delay: .66s; }
.action-rail .games-btn .gh-btn-ico { display: block; animation: ghWiggle 3.2s ease-in-out infinite; }
@keyframes ghWiggle { 0%, 82%, 100% { transform: rotate(0); } 86% { transform: rotate(-14deg) scale(1.12); } 92% { transform: rotate(12deg) scale(1.12); } }

/* ---------- שכבת החלון ---------- */
.gh-popup {
    position: fixed; inset: 0; z-index: 2100; display: grid; place-items: center; padding: 12px; direction: rtl;
    background: radial-gradient(circle at 50% 18%, rgba(124, 77, 255, .55), rgba(11, 40, 100, .86));
    animation: uFade .25s ease; font-family: var(--u-font);
}
.gh-popup.hidden { display: none !important; }
.gh-popup * { box-sizing: border-box; }

/* כוכבים מנצנצים ברקע החלון */
.gh-stars { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.gh-stars i { position: absolute; width: 4px; height: 4px; border-radius: 50%; background: #fff; box-shadow: 0 0 8px #fff; animation: ghTwinkle 2.4s ease-in-out infinite; }
@keyframes ghTwinkle { 0%, 100% { opacity: .2; transform: scale(.7); } 50% { opacity: 1; transform: scale(1.2); } }

/* ---------- חלון הלובי ---------- */
.gh {
    position: relative; width: min(940px, 96vw); max-height: 94vh; display: flex; flex-direction: column; overflow: hidden; border-radius: 44px; padding: 14px 14px 18px;
    background: linear-gradient(180deg, #ff7ab8, #7c4dff 58%, #2e9bff);
    box-shadow: 0 14px 0 #4a23b8, 0 44px 80px rgba(11, 61, 145, .55); animation: uWindow .55s var(--u-ease);
}
.gh-top { position: relative; display: flex; align-items: center; justify-content: center; padding: 10px 56px 14px; }
.gh-top h2 { margin: 0; font: 400 clamp(1.6rem, 4.4vw, 2.4rem) var(--u-font); color: #fff; letter-spacing: 1px; text-shadow: 0 4px 0 rgba(40, 10, 120, .55); }
.gh-top h2 span { display: inline-block; animation: ghBob 2.2s ease-in-out infinite; }
.gh-top h2 span:nth-child(2) { animation-delay: .25s; }
@keyframes ghBob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
.gh-marquee { position: absolute; inset: 0 8px auto; display: flex; justify-content: space-between; pointer-events: none; }
.gh-marquee i { width: 12px; height: 12px; border-radius: 50%; background: #ffd93b; box-shadow: 0 0 10px #ffd93b; animation: uBulb 1.2s infinite; }
.gh-marquee i:nth-child(even) { animation-delay: .6s; }
.gh-close {
    position: absolute; inset-inline-end: 6px; top: 6px; width: 44px; height: 44px; border: 0; border-radius: 50%; cursor: pointer; z-index: 3;
    font: 400 1.8rem/1 var(--u-font); color: #fff; background: rgba(255, 255, 255, .22); transition: transform .2s var(--u-ease), background .2s;
}
.gh-close:hover { transform: rotate(90deg); background: rgba(255, 77, 87, .9); }
.gh-close:focus-visible { outline: 4px solid #ffd93b; outline-offset: 2px; }

.gh-body { position: relative; background: #fff; border-radius: 32px; padding: 22px; overflow: auto; }
.gh-lead { margin: 0 0 18px; text-align: center; font: 600 1.1rem 'Rubik', system-ui, sans-serif; color: var(--u-soft); }
.gh-lead b { color: var(--u-violet-d); }
.gh-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 18px; }

/* ---------- כרטיס משחק ---------- */
.gh-card {
    --a: #6cc4ff; --b: var(--u-sky); --edge: var(--u-sky-d); --tint: var(--u-sky-50);
    position: relative; display: flex; flex-direction: column; text-align: center; border-radius: 30px; overflow: hidden; cursor: pointer; padding: 0;
    background: var(--tint); border: 4px solid color-mix(in srgb, var(--b) 35%, #fff); box-shadow: 0 8px 0 color-mix(in srgb, var(--b) 40%, #fff);
    transition: transform .22s var(--u-ease), box-shadow .22s; animation: uCardIn .5s var(--u-ease) both; font: inherit; color: var(--u-ink);
}
.gh-card:nth-child(2) { animation-delay: .1s; } .gh-card:nth-child(3) { animation-delay: .2s; }
.gh-card:hover, .gh-card:focus-visible { transform: translateY(-8px) rotate(-1deg) scale(1.02); box-shadow: 0 16px 0 color-mix(in srgb, var(--b) 40%, #fff), 0 24px 30px rgba(11, 61, 145, .25); outline: none; }
.gh-card:active { transform: translateY(2px) scale(.98); box-shadow: 0 3px 0 color-mix(in srgb, var(--b) 40%, #fff); }
.gh-card--runner { --a: #6cc4ff; --b: #2e9bff; --edge: #1565d8; --tint: #f3fbff; }
.gh-card--cannon { --a: #b9a2ff; --b: #7c4dff; --edge: #5b2bd1; --tint: #f6f2ff; }
.gh-card--soon { --a: #d3dbe8; --b: #9fb0c9; --edge: #7a8cab; --tint: #f3f5f9; cursor: default; }
.gh-card--soon:hover { transform: none; box-shadow: 0 8px 0 color-mix(in srgb, var(--b) 40%, #fff); }
.gh-art { position: relative; height: 150px; overflow: hidden; background: linear-gradient(180deg, var(--a), var(--b)); }
.gh-art svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.gh-info { padding: 14px 16px 18px; display: flex; flex-direction: column; gap: 8px; align-items: center; flex: 1; }
.gh-info h3 { margin: 0; font: 400 1.45rem var(--u-font); color: var(--u-ink); }
.gh-info p { margin: 0; font: 500 .95rem/1.4 'Rubik', system-ui, sans-serif; color: var(--u-soft); }
.gh-chips { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.gh-chip { padding: 4px 12px; border-radius: 999px; font: 400 .85rem var(--u-font); background: #fff4cf; border: 2px solid var(--u-yellow); color: #7a4300; }
.gh-chip--best { background: #e3f5ff; border-color: var(--u-sky-300); color: var(--u-sky-d); }
.gh-go {
    margin-top: auto; padding: 10px 28px; border-radius: 18px; font: 400 1.2rem var(--u-font); color: #fff; text-shadow: 0 2px 0 rgba(0, 0, 0, .25);
    background: linear-gradient(180deg, var(--a), var(--b)); box-shadow: 0 5px 0 var(--edge), inset 0 2px 0 rgba(255, 255, 255, .5);
}
.gh-card:hover .gh-go { filter: brightness(1.08); }
.gh-soon-badge { position: absolute; top: 12px; inset-inline-start: 12px; padding: 4px 12px; border-radius: 999px; font: 400 .9rem var(--u-font); color: #fff; background: #7a8cab; z-index: 2; }

/* ---------- אנימציות הציורים בכרטיסים ---------- */
.gh-art .a-cloud { animation: ghDrift 9s linear infinite; }
.gh-art .a-cloud.b { animation-duration: 13s; animation-delay: -5s; }
@keyframes ghDrift { from { transform: translateX(-80px); } to { transform: translateX(340px); } }
.gh-art .a-run { animation: ghRun .5s ease-in-out infinite alternate; transform-origin: center bottom; }
@keyframes ghRun { from { transform: translateY(0) rotate(-3deg); } to { transform: translateY(-9px) rotate(3deg); } }
.gh-art .a-coin { animation: ghSpinCoin 1.3s linear infinite; transform-box: fill-box; transform-origin: center; }
@keyframes ghSpinCoin { 0% { transform: scaleX(1); } 50% { transform: scaleX(.15); } 100% { transform: scaleX(1); } }
.gh-art .a-ufo { animation: ghUfo 3.4s ease-in-out infinite; }
.gh-art .a-ufo.b { animation-duration: 4.4s; animation-delay: -1.6s; }
@keyframes ghUfo { 0%, 100% { transform: translate(0, 0); } 50% { transform: translate(36px, -10px); } }
.gh-art .a-barrel { transform-origin: 150px 150px; animation: ghAim 3.6s ease-in-out infinite; }
@keyframes ghAim { 0%, 100% { transform: rotate(-26deg); } 50% { transform: rotate(18deg); } }
.gh-art .a-shot { animation: ghShot 1.8s ease-out infinite; }
@keyframes ghShot { 0% { transform: translate(0, 0) scale(.6); opacity: 0; } 15% { opacity: 1; } 100% { transform: translate(40px, -120px) scale(1); opacity: 0; } }
.gh-art .a-twinkle { animation: ghTwinkle 2s ease-in-out infinite; }

/* ============================================================
   חלון משחק התותח
   ============================================================ */
.gc {
    position: relative; width: min(980px, 96vw); max-height: 96vh; display: flex; flex-direction: column; overflow: hidden; border-radius: 44px; padding: 12px 12px 16px;
    background: linear-gradient(180deg, #5b2bd1, #2a1a7a 70%, #14104a);
    box-shadow: 0 14px 0 #1c1060, 0 44px 80px rgba(5, 10, 50, .65); animation: uWindow .55s var(--u-ease);
}
.gc-top { position: relative; display: flex; align-items: center; justify-content: center; padding: 8px 56px 12px; }
.gc-top h2 { margin: 0; font: 400 clamp(1.4rem, 4vw, 2.1rem) var(--u-font); color: #fff; text-shadow: 0 4px 0 rgba(10, 0, 70, .6); }
.gc-top .gh-close { background: rgba(255, 255, 255, .18); }
.gc-mute {
    position: absolute; inset-inline-start: 8px; top: 6px; width: 44px; height: 44px; border: 0; border-radius: 50%; cursor: pointer; font-size: 1.3rem; line-height: 1;
    color: #fff; background: rgba(255, 255, 255, .18); transition: transform .2s var(--u-ease), background .2s;
}
.gc-mute:hover { transform: scale(1.12); background: rgba(255, 255, 255, .32); }

.gc-stage { position: relative; display: flex; flex-direction: column; gap: 10px; padding: 10px; border-radius: 32px; background: #0b0a2e; border: 3px solid rgba(255, 255, 255, .12); }
.gc-hud { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.gc-pill { display: inline-flex; align-items: center; gap: 8px; padding: 5px 18px; border-radius: 999px; font: 400 1.2rem var(--u-font); color: #fff; box-shadow: 0 4px 0 rgba(0, 0, 0, .3); min-width: 92px; justify-content: center; transition: transform .15s var(--u-ease); }
.gc-pill b { font-weight: 400; }
.gc-pill--lives { background: linear-gradient(180deg, #ff8fb0, var(--u-pink)); text-shadow: 0 2px 0 rgba(120, 10, 70, .35); letter-spacing: 3px; }
.gc-pill--score { background: linear-gradient(180deg, #ffd35e, #ff9a1f); color: #5a2a00; }
.gc-pill--combo { background: linear-gradient(180deg, #a98aff, var(--u-violet)); text-shadow: 0 2px 0 rgba(40, 10, 120, .4); }
.gc-pill--time { background: linear-gradient(180deg, #6cc4ff, var(--u-sky)); text-shadow: 0 2px 0 rgba(10, 50, 130, .4); }
.gc-pill.pop { animation: gcPop .3s var(--u-ease); }
.gc-pill--lives.hurt { animation: gcHurt .5s ease; }
@keyframes gcPop { 0% { transform: scale(1.3); } 100% { transform: scale(1); } }
@keyframes gcHurt { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-9px); } 40% { transform: translateX(9px); } 60% { transform: translateX(-6px); } 80% { transform: translateX(6px); } }
.gc-timebar { height: 8px; border-radius: 99px; background: rgba(255, 255, 255, .12); overflow: hidden; }
.gc-timebar i { display: block; height: 100%; width: 100%; border-radius: 99px; background: linear-gradient(90deg, #3ddc84, #ffd93b, #ff5a5a); background-size: 300% 100%; transform-origin: right center; }

.gc-view { position: relative; width: min(100%, calc(62vh * 1.6)); aspect-ratio: 16 / 10; margin: 0 auto; border-radius: 24px; overflow: hidden; background: #0b0a2e; outline: none; cursor: crosshair; touch-action: none; user-select: none; -webkit-user-select: none; }
.gc-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.gc-overlay { position: absolute; inset: 0; z-index: 3; display: grid; place-content: center; justify-items: center; gap: 14px; padding: 16px; text-align: center; color: #fff; background: rgba(9, 6, 50, .72); animation: uFade .25s ease; }
.gc-overlay.hidden { display: none !important; }
.gc-overlay h3 { margin: 0; font: 400 clamp(1.6rem, 5vw, 2.6rem) var(--u-font); text-shadow: 0 4px 0 rgba(10, 0, 70, .6); }
.gc-overlay p { margin: 0; font: 500 1rem/1.5 'Rubik', system-ui, sans-serif; max-width: 520px; color: #dcd6ff; }
.gc-legend { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.gc-legend > div { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 14px; border-radius: 22px; min-width: 150px; font: 400 .95rem var(--u-font); }
.gc-legend canvas { width: 86px; height: 56px; }
.gc-legend .good { background: rgba(61, 220, 132, .18); border: 3px solid #3ddc84; }
.gc-legend .good em { color: #7cf0ae; }
.gc-legend .bad { background: rgba(255, 77, 140, .18); border: 3px solid #ff4d8c; }
.gc-legend .bad em { color: #ff9ac4; }
.gc-legend em { font-style: normal; font-size: .85rem; }
.gc-legend .gold { background: rgba(255, 217, 59, .16); border: 3px solid #ffd93b; }
.gc-legend .gold em { color: #ffe27a; }
.gc-play {
    padding: 14px 40px; border: 0; border-radius: 24px; cursor: pointer; font: 400 1.5rem var(--u-font); color: #5a2a00; transition: transform .15s var(--u-ease);
    background: linear-gradient(180deg, var(--u-orange-300), var(--u-orange)); box-shadow: 0 7px 0 var(--u-orange-d), inset 0 3px 0 rgba(255, 255, 255, .55);
    animation: ctaPulse2 1.8s ease-in-out infinite;
}
.gc-play:hover { transform: translateY(-3px) scale(1.05); }
.gc-play:active { transform: translateY(5px); box-shadow: none; }
.gc-play--ghost { color: #fff; background: rgba(255, 255, 255, .16); box-shadow: 0 6px 0 rgba(0, 0, 0, .3); animation: none; font-size: 1.1rem; padding: 10px 26px; }
.gc-actions { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.gc-keys { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; color: #cfc6ff; font: 500 .95rem 'Rubik', system-ui, sans-serif; }
.gc-keys span { display: inline-flex; align-items: center; gap: 6px; }
.gc-keys kbd { min-width: 32px; height: 32px; font-size: .9rem; }
.gc-result-grid { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.gc-result-grid > div { min-width: 118px; padding: 12px 16px; border-radius: 22px; background: #fff; color: var(--u-ink); box-shadow: 0 5px 0 rgba(0, 0, 0, .3); animation: uCardIn .5s var(--u-ease) both; }
.gc-result-grid > div:nth-child(2) { animation-delay: .1s; } .gc-result-grid > div:nth-child(3) { animation-delay: .2s; } .gc-result-grid > div:nth-child(4) { animation-delay: .3s; }
.gc-result-grid b { display: block; font: 400 2rem/1.1 var(--u-font); }
.gc-result-grid span { font: 700 .85rem 'Rubik', system-ui, sans-serif; color: var(--u-soft); }
.gc-result-grid .award { background: linear-gradient(180deg, #ffe27a, #ffb12e); }
.gc-result-grid .award b { color: #7a3a00; }
.gc-newbest { padding: 4px 16px; border-radius: 999px; font: 400 1.1rem var(--u-font); color: #5a2a00; background: linear-gradient(180deg, #ffe27a, #ffb12e); animation: gcPop .6s var(--u-ease) both; }
.gc-countdown { position: absolute; inset: 0; z-index: 2; display: grid; place-items: center; pointer-events: none; font: 400 clamp(4rem, 14vw, 8rem) var(--u-font); color: #fff; text-shadow: 0 6px 0 #5b2bd1, 0 14px 30px rgba(0, 0, 0, .5); }
.gc-countdown.hidden { display: none; }
.gc-countdown.pop { animation: ghCount .7s var(--u-ease); }
@keyframes ghCount { 0% { transform: scale(2.4); opacity: 0; } 40% { transform: scale(.9); opacity: 1; } 100% { transform: scale(1); opacity: 1; } }

@media (max-width: 720px) {
    .gh, .gc { border-radius: 30px; }
    .gh-body { padding: 14px; }
    .gc-view { width: 100%; }
    .gc-pill { font-size: 1rem; padding: 4px 12px; min-width: 0; }
    .gc-legend > div { min-width: 110px; }
}
@media (prefers-reduced-motion: reduce) {
    .gh-art *, .gh-stars i, .gh-card, .gc-play, .gh-top h2 span { animation: none !important; }
}
