/* ============================================================
   SNOOKER CLUB — Premium Styles v2.2
   Canvas sizing fixed. Gameplay files untouched.
   ============================================================ */

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #0a0503;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    user-select: none;
    -webkit-user-select: none;
    overscroll-behavior: none;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

#app {
    position: relative;
    width: 100%;
    height: 100%;
}

/* ===== SCREENS ===== */
.screen {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 10;
}

.screen.active {
    opacity: 1;
    pointer-events: all;
}

.modal-screen {
    z-index: 30;
}

/* ===== LOADING ===== */
.loading-screen {
    z-index: 100;
    flex-direction: column;
    background: linear-gradient(180deg, #1a0f0a 0%, #0a0503 100%);
}

.loading-bg {
    position: absolute;
    inset: 0;
    overflow: hidden;
}

.loading-bg .bg-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 140vmax;
    height: 140vmax;
    transform: translate(-50%, -50%);
    background: radial-gradient(circle, rgba(212,175,55,0.08) 0%, transparent 55%);
    animation: loadGlow 4s ease-in-out infinite;
}

@keyframes loadGlow {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

.loading-content {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
    animation: fadeUp 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.loading-badge {
    position: relative;
    width: 88px;
    height: 88px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.4rem;
}

.loading-badge svg {
    filter: drop-shadow(0 4px 16px rgba(212,175,55,0.25));
    animation: loadBob 2.2s ease-in-out infinite;
}

@keyframes loadBob {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

.loading-ring {
    position: absolute;
    inset: -8px;
    border-radius: 50%;
    border: 2.5px solid transparent;
    border-top-color: #d4af37;
    border-right-color: rgba(212,175,55,0.3);
    animation: loadSpin 1.1s linear infinite;
}

@keyframes loadSpin {
    to { transform: rotate(360deg); }
}

.loading-title {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 2.2rem;
    letter-spacing: 0.12em;
    color: #f5e6c8;
    text-shadow: 0 2px 12px rgba(212,175,55,0.3);
}

.loading-tag {
    font-size: 0.8rem;
    color: rgba(245,230,200,0.5);
    letter-spacing: 0.03em;
    margin-bottom: 0.6rem;
}

.loading-bar-track {
    width: 220px;
    height: 6px;
    border-radius: 4px;
    background: rgba(255,255,255,0.08);
    overflow: hidden;
    position: relative;
}

.loading-bar-fill {
    height: 100%;
    width: 0%;
    border-radius: 4px;
    background: linear-gradient(90deg, #a37a1f, #d4af37, #f0dc94, #d4af37);
    background-size: 200% 100%;
    animation: loadShimmer 1.4s linear infinite;
    transition: width 0.15s linear;
}

@keyframes loadShimmer {
    to { background-position: -200% 0; }
}

.loading-pct {
    font-size: 0.72rem;
    color: rgba(245,230,200,0.45);
    letter-spacing: 0.05em;
    font-variant-numeric: tabular-nums;
}

/* ===== HOME ===== */
#screen-home {
    overflow: hidden;
    isolation: isolate;
    background: #080b07;
}

#screen-home::before {
    content: '';
    position: absolute;
    inset: 8px;
    z-index: 3;
    pointer-events: none;
    border: 1px solid rgba(226, 178, 55, .28);
    border-radius: clamp(18px, 3vw, 32px);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.015), 0 0 30px rgba(0,0,0,.25);
}

#screen-home .home-bg {
    position: absolute;
    inset: 0;
    overflow: hidden;
    z-index: 0;
    background: linear-gradient(180deg, #11170e, #050704);
}

.home-scene {
    position: absolute;
    inset: -5%;
    width: 110%;
    height: 110%;
    object-fit: cover;
    object-position: center 46%;
    filter: blur(7px) saturate(.85) brightness(.42);
    transform: scale(1.025);
    opacity: .62;
}

.home-scene-shade {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at 50% 26%, rgba(14,42,22,.12), transparent 36%),
        linear-gradient(180deg, rgba(2,4,2,.26) 0%, rgba(3,5,3,.36) 42%, rgba(1,2,1,.88) 100%),
        radial-gradient(ellipse at center, transparent 34%, rgba(0,0,0,.66) 100%);
}

.home-light {
    position: absolute;
    top: 10%;
    width: 28vw;
    height: 28vw;
    max-width: 420px;
    max-height: 420px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(242,189,57,.17), transparent 66%);
    filter: blur(8px);
    animation: homeLamp 5.5s ease-in-out infinite;
}
.home-light-left { left: -10%; }
.home-light-right { right: -10%; animation-delay: -2.4s; }
.home-felt-glow {
    position: absolute;
    left: 50%;
    bottom: -17%;
    width: 115%;
    height: 58%;
    transform: translateX(-50%);
    border-radius: 50% 50% 0 0;
    background: radial-gradient(ellipse at 50% 0%, rgba(6,126,61,.34), rgba(3,45,23,.1) 48%, transparent 70%);
    filter: blur(12px);
}
@keyframes homeLamp { 50% { opacity: .65; transform: scale(1.08); } }

#screen-home .home-content {
    position: relative;
    z-index: 4;
    width: min(90vw, 520px);
    max-width: 520px;
    padding: clamp(1.2rem, 3vh, 2rem) clamp(1rem, 4vw, 2rem);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: clamp(0.9rem, 2.2vh, 1.4rem);
    text-align: center;
    border-radius: clamp(20px, 3.5vw, 34px);
    background:
        linear-gradient(180deg, rgba(8,15,8,.78), rgba(4,7,4,.86)),
        radial-gradient(ellipse at 50% 0%, rgba(31,83,43,.22), transparent 52%);
    border: 1px solid rgba(226,178,55,.18);
    box-shadow: 0 38px 110px rgba(0,0,0,.62), inset 0 1px 0 rgba(255,255,255,.045);
    backdrop-filter: blur(18px) saturate(1.05);
    -webkit-backdrop-filter: blur(18px) saturate(1.05);
}

.home-top-mark {
    display: grid;
    place-items: center;
    margin-bottom: 0.2rem;
}
.premium-ball {
    width: clamp(64px, 10vw, 92px);
    aspect-ratio: 1;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background:
        radial-gradient(circle at 33% 26%, rgba(255,255,255,.28) 0 5%, transparent 14%),
        radial-gradient(circle at 38% 32%, #393939 0%, #101110 44%, #010201 76%);
    border: 3px solid #ddb42d;
    box-shadow: 0 12px 24px rgba(0,0,0,.5), 0 0 20px rgba(221,180,45,.15), inset -8px -10px 14px rgba(0,0,0,.58);
    animation: ballFloat 3.4s ease-in-out infinite;
}
.premium-ball span {
    width: 42%;
    aspect-ratio: 1;
    display: grid;
    place-items: center;
    border-radius: 50%;
    color: #111;
    background: #fff;
    font-family: 'Inter', sans-serif;
    font-size: clamp(0.9rem, 2.5vw, 1.3rem);
    font-weight: 800;
    box-shadow: inset 0 -2px 4px rgba(0,0,0,.18);
}
@keyframes ballFloat { 50% { transform: translateY(-4px); } }

#screen-home .logo-wrap { animation: none; width: 100%; }
.logo-kicker {
    margin-bottom: .3rem;
    color: rgba(232,199,104,.58);
    font-size: clamp(.52rem, 1.3vw, .68rem);
    font-weight: 700;
    letter-spacing: .34em;
}
#screen-home .logo-title {
    margin: 0;
    font-family: 'Bebas Neue', sans-serif;
    font-size: clamp(3.6rem, 14vw, 7.5rem);
    line-height: .78;
    letter-spacing: .045em;
    color: #f4f1e9;
    background: linear-gradient(180deg, #fff 8%, #f4f1e9 46%, #c7c1b3 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 6px 0 rgba(0,0,0,.18));
    text-shadow: none;
}
.club-lockup {
    margin-top: clamp(.35rem, 1vh, .6rem);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: clamp(.5rem, 2vw, 1rem);
}
#screen-home .logo-sub {
    margin: 0;
    font-family: 'Bebas Neue', sans-serif;
    font-size: clamp(1.8rem, 6vw, 3.2rem);
    line-height: 1;
    letter-spacing: .45em;
    padding-left: .45em;
    color: #ddb42d;
    background: linear-gradient(180deg, #ffe68b, #d4a514 60%, #a87500);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.club-line {
    width: clamp(28px, 8vw, 72px);
    height: 1px;
    background: linear-gradient(90deg, transparent, #ddb42d);
}
.club-line:last-child { transform: scaleX(-1); }
.logo-crown {
    margin-top: .1rem;
    color: #ddb42d;
    font-size: clamp(1rem, 2.5vw, 1.4rem);
    filter: drop-shadow(0 2px 4px rgba(0,0,0,.5));
}
#screen-home .logo-tag {
    margin-top: .35rem;
    color: rgba(243,235,208,.67);
    font-size: clamp(.6rem, 1.6vw, .78rem);
    font-weight: 600;
    letter-spacing: .27em;
}
#screen-home .logo-tag b { color: #ddb42d; }

#screen-home .home-buttons {
    width: min(100%, 260px);
    display: flex;
    flex-direction: column;
    gap: .7rem;
    animation: none;
    margin-top: .2rem;
}
#screen-home .btn {
    width: 100%;
    border: none;
    border-radius: 14px;
    font-family: 'Inter', sans-serif;
    font-weight: 700;
    font-size: clamp(.88rem, 2.2vw, 1rem);
    padding: 0.85rem 1.2rem;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    letter-spacing: 0.06em;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    position: relative;
    overflow: hidden;
    min-height: clamp(50px, 7vh, 62px);
}
#screen-home .home-primary {
    position: relative;
    color: #151104;
    border: 1px solid #ffe276;
    background: linear-gradient(180deg, #ffe26c 0%, #dcae18 60%, #b98200 100%);
    box-shadow: 0 10px 28px rgba(220,174,24,.22), inset 0 2px 0 rgba(255,255,255,.45), inset 0 -2px 0 rgba(88,56,0,.22);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
#screen-home .home-primary:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 14px 34px rgba(220,174,24,.3), inset 0 2px 0 rgba(255,255,255,.5), inset 0 -2px 0 rgba(88,56,0,.22);
}
#screen-home .home-primary:active {
    transform: translateY(0) scale(0.97);
}
#screen-home .home-primary::after {
    content: '';
    position: absolute;
    inset: 4px;
    border: 1px solid rgba(255,255,255,.18);
    border-radius: 10px;
    pointer-events: none;
}
.play-medallion {
    width: 26px;
    height: 26px;
    display: grid;
    place-items: center;
    padding-left: 2px;
    border-radius: 50%;
    color: #312100;
    background: rgba(255,255,255,.22);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.4);
    flex-shrink: 0;
}
#screen-home .home-secondary {
    color: #e6e2d6;
    border: 1px solid rgba(232,198,95,.22);
    background: linear-gradient(180deg, rgba(49,52,42,.85), rgba(14,17,13,.92));
    box-shadow: 0 10px 24px rgba(0,0,0,.22), inset 0 1px 0 rgba(255,255,255,.07);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
#screen-home .home-secondary:hover {
    transform: translateY(-2px);
    background: linear-gradient(180deg, rgba(60,64,52,.9), rgba(20,24,18,.95));
    border-color: rgba(232,198,95,.35);
}
#screen-home .home-secondary:active {
    transform: translateY(0) scale(0.97);
}
.book-icon { color: #d9b33b; font-size: 1.15em; flex-shrink: 0; }

#screen-home .home-highscore {
    min-height: 42px;
    padding: .5rem 1.1rem;
    gap: .5rem;
    border-radius: 999px;
    border: 1px solid rgba(221,180,45,.24);
    background: linear-gradient(180deg, rgba(28,34,24,.78), rgba(10,13,9,.8));
    box-shadow: inset 0 1px 0 rgba(255,255,255,.035), 0 6px 18px rgba(0,0,0,.18);
    animation: none;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: .1rem;
}
#screen-home .hs-text {
    color: rgba(238,235,225,.72);
    font-size: clamp(.68rem, 1.6vw, .8rem);
    letter-spacing: .11em;
    font-weight: 500;
}
#screen-home .hs-text b {
    color: #f2c936;
    font-size: 1.1em;
    font-weight: 700;
    margin-left: .25rem;
}
.laurel { color: rgba(221,180,45,.65); font-size: .9em; }
.hs-icon { font-size: 1em; }
.home-footnote {
    margin-top: -.2rem;
    color: rgba(255,255,255,.24);
    font-size: .58rem;
    font-weight: 600;
    letter-spacing: .18em;
    text-transform: uppercase;
}

/* ===== MODAL ===== */
.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.65);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.modal-box {
    position: relative;
    z-index: 2;
    background: linear-gradient(180deg, #1a2218 0%, #121a10 100%);
    border: 1px solid rgba(212,175,55,0.1);
    border-radius: 24px;
    padding: clamp(1.5rem, 5vw, 2.2rem);
    max-width: 420px;
    width: 90%;
    text-align: center;
    box-shadow:
        0 30px 80px rgba(0,0,0,0.6),
        inset 0 1px 0 rgba(255,255,255,0.04);
    animation: modalIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.94) translateY(12px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.08);
    background: rgba(255,255,255,0.04);
    color: #999;
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.modal-close:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
    border-color: rgba(255,255,255,0.15);
}

.modal-box h2 {
    font-family: 'Bebas Neue', sans-serif;
    font-size: clamp(1.8rem, 6vw, 2.4rem);
    color: #d4af37;
    letter-spacing: 0.12em;
    margin-bottom: 1.5rem;
}

.how-grid {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    text-align: left;
}

.how-item {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.7rem 0.9rem;
    background: rgba(255,255,255,0.025);
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.03);
    transition: all 0.2s;
}

.how-item:hover {
    background: rgba(255,255,255,0.05);
    border-color: rgba(255,255,255,0.06);
}

.how-icon {
    font-size: 1.4rem;
    flex-shrink: 0;
    width: 36px;
    text-align: center;
}

.how-text {
    display: flex;
    flex-direction: column;
    gap: 0.05rem;
}

.how-text strong {
    color: #fff;
    font-size: 0.85rem;
    font-weight: 600;
}

.how-text span {
    color: #999;
    font-size: 0.78rem;
    line-height: 1.4;
}

/* ===== GAME SCREEN ===== */
#screen-game {
    flex-direction: column;
    justify-content: flex-start;
    background: #0a0503;
}

.game-ui {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Top Bar */
.top-bar {
    position: relative;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px clamp(8px, 1.5vw, 16px);
    background:
        linear-gradient(180deg, rgba(35,15,10,.99), rgba(14,6,4,.99)),
        repeating-linear-gradient(90deg, rgba(255,255,255,.018) 0 1px, transparent 1px 34px);
    border-top: 1px solid rgba(255,221,139,.12);
    border-bottom: 1px solid rgba(213,164,53,.28);
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,.045),
        inset 0 -1px 0 rgba(0,0,0,.75),
        0 12px 30px rgba(0,0,0,.36);
    z-index: 5;
    flex-shrink: 0;
    min-height: 52px;
}

.top-bar::after {
    content: '';
    position: absolute;
    left: 50%; bottom: -1px;
    width: min(36vw, 400px); height: 1px;
    transform: translateX(-50%);
    background: linear-gradient(90deg, transparent, rgba(243,199,86,.8), transparent);
    box-shadow: 0 0 10px rgba(236,181,57,.35);
}

.top-left, .top-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.top-right {
    justify-content: flex-end;
}

.top-center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2;
}

.hud-title {
    display: flex;
    flex-direction: column;
    line-height: .9;
    letter-spacing: .12em;
    text-align: left;
    pointer-events: none;
}
.hud-title span {
    font-family: 'Bebas Neue', sans-serif;
    font-size: clamp(14px, 1.6vw, 20px);
    color: #f4e7c4;
    text-shadow: 0 2px 8px rgba(0,0,0,.6);
}
.hud-title small {
    margin-top: 2px;
    font: 700 7px/1 'Inter', sans-serif;
    letter-spacing: .34em;
    color: #d8ac36;
}

.icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    color: #e7d7b3;
    border: 1px solid rgba(232,193,94,.25);
    background:
        linear-gradient(180deg, rgba(255,255,255,.075), rgba(255,255,255,.015)),
        #1a0f0b;
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,.10),
        inset 0 -6px 12px rgba(0,0,0,.22),
        0 6px 16px rgba(0,0,0,.35);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.icon-btn:hover {
    color: #fff4d0;
    border-color: rgba(241,199,88,.58);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.12), 0 0 18px rgba(214,163,48,.18);
    transform: translateY(-1px);
}

.icon-btn:active {
    transform: scale(0.93) translateY(0);
}

.icon-btn svg {
    display: block;
}

/* Timer */
.timer-wrap {
    position: relative;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background:
        radial-gradient(circle at 42% 34%, #2e1c13 0%, #160b08 58%, #090403 100%);
    box-shadow:
        inset 0 0 0 1px rgba(255,255,255,.04),
        0 0 0 5px rgba(0,0,0,.22),
        0 6px 14px rgba(0,0,0,.48),
        0 0 18px rgba(216,168,45,.09);
    filter: drop-shadow(0 4px 10px rgba(0,0,0,.35));
}

.timer-ring {
    position: absolute;
    width: 100%;
    height: 100%;
}

.timer-ring-bg {
    stroke: rgba(255,255,255,0.06);
}

.timer-ring-fill {
    stroke: #e1b52f;
    transition: stroke-dashoffset 0.4s ease, stroke 0.3s ease;
    filter: drop-shadow(0 0 4px rgba(232,183,45,.45));
}

#timer-val {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.45rem;
    color: #fff8e6;
    line-height: 1;
    z-index: 1;
    text-shadow: 0 2px 8px rgba(0,0,0,0.3);
    transform: translateY(-2px);
}

.timer-label {
    position: absolute;
    bottom: 7px;
    font: 700 5px/1 'Inter', sans-serif;
    letter-spacing: .12em;
    color: rgba(239,218,169,.46);
}

.timer-wrap.warning .timer-ring-fill {
    stroke: #e74c3c;
    animation: ringPulse 0.8s ease infinite;
}

.timer-wrap.warning #timer-val {
    color: #e74c3c;
    animation: textPulse 0.8s ease infinite;
}

.timer-wrap.danger .timer-ring-fill {
    stroke: #ff3333;
    animation: ringPulse 0.4s ease infinite;
}

.timer-wrap.danger #timer-val {
    color: #ff3333;
    animation: textPulse 0.4s ease infinite;
}

@keyframes ringPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes textPulse {
    0%, 100% { transform: translateY(-2px) scale(1); }
    50% { transform: translateY(-2px) scale(1.12); }
}

/* Score */
.score-block {
    text-align: right;
    min-width: 72px;
    padding-left: 8px;
    border-left: 1px solid rgba(215,170,64,.16);
}

.score-wrap {
    display: flex;
    align-items: baseline;
    gap: 0.2rem;
    justify-content: flex-end;
}

#score-val {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.55rem;
    color: #e8bd3d;
    line-height: 1;
    text-shadow: 0 2px 10px rgba(212,165,39,.22);
}

.score-label {
    font-size: 0.55rem;
    color: rgba(238,220,178,.54);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.highscore-wrap {
    font-size: 0.54rem;
    color: rgba(236,219,181,.38);
    font-weight: 600;
    letter-spacing: 0.06em;
    margin-top: 0.05rem;
}

#highscore-val {
    color: #d9b13b;
}

.cue-badge {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(229,188,81,.28);
    background: linear-gradient(180deg, rgba(255,255,255,.055), rgba(255,255,255,.016));
    box-shadow: inset 0 1px 0 rgba(255,255,255,.09), 0 7px 16px rgba(0,0,0,.34);
    flex-shrink: 0;
}
.cue-badge span {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #fff 0 30%, #d8edf0 48%, #82b8bf 100%);
    box-shadow: inset -3px -4px 7px rgba(0,0,0,.22), inset 2px 2px 4px rgba(255,255,255,.75), 0 4px 8px rgba(0,0,0,.42);
    position: relative;
}
.cue-badge span::after {
    content: '';
    position: absolute;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: #e94855;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
}

/* Ball Rack Shell */
.rack-shell {
    position: relative;
    flex-shrink: 0;
    padding: 10px 8px 6px;
    background:
        radial-gradient(ellipse at 50% 0%, rgba(159,105,33,.10), transparent 60%),
        linear-gradient(180deg, #100705 0%, #0a0403 100%);
    border-bottom: 1px solid rgba(220,170,60,.12);
    box-shadow: inset 0 -12px 24px rgba(0,0,0,.28);
}
.rack-caption {
    position: absolute;
    top: 4px; left: 50%;
    transform: translateX(-50%);
    z-index: 2;
    padding: 0 8px;
    font: 700 6px/1 'Inter', sans-serif;
    letter-spacing: .24em;
    color: rgba(228,202,143,.42);
    background: #100705;
    white-space: nowrap;
}
.rack-shell::before {
    content: '';
    position: absolute;
    top: 6px; left: 50%;
    width: min(55%, 560px); height: 1px;
    transform: translateX(-50%);
    background: linear-gradient(90deg, transparent, rgba(220,172,62,.20), transparent);
}

/* Ball Rack */
.ball-rack {
    position: relative;
    width: min(60%, 520px);
    min-height: 32px;
    margin: 0 auto;
    padding: 6px 16px;
    display: flex;
    justify-content: center;
    gap: clamp(4px, .6vw, 8px);
    flex-wrap: nowrap;
    align-items: center;
    overflow: visible;
    border-radius: 14px;
    border: 1px solid rgba(222,179,75,.38);
    background:
        linear-gradient(180deg, rgba(24,48,29,.97), rgba(5,17,10,.99)),
        radial-gradient(ellipse at 50% 0%, rgba(120,171,89,.18), transparent 64%);
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,.09),
        inset 0 -12px 20px rgba(0,0,0,.38),
        0 0 0 3px rgba(54,27,12,.92),
        0 0 0 4px rgba(210,158,48,.30),
        0 10px 25px rgba(0,0,0,.42);
}

.ball-rack::before,
.ball-rack::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 6px;
    height: 6px;
    transform: translateY(-50%) rotate(45deg);
    border: 1px solid rgba(247,207,99,.76);
    background: linear-gradient(135deg, #5e3415, #c39335 50%, #42230e 51%);
    box-shadow: 0 0 0 2px rgba(32,15,6,.8), 0 2px 5px rgba(0,0,0,.5);
}
.ball-rack::before { left: 6px; }
.ball-rack::after { right: 6px; }

.rack-ball {
    --ball-color: #ddd;
    width: clamp(18px, 1.8vw, 24px);
    height: clamp(18px, 1.8vw, 24px);
    aspect-ratio: 1;
    border: 1px solid rgba(255, 226, 151, .68);
    border-radius: 50%;
    overflow: hidden;
    display: grid;
    place-items: center;
    background:
        radial-gradient(circle at 31% 24%, rgba(255,255,255,.92) 0 8%, rgba(255,255,255,.22) 9% 17%, transparent 18%),
        radial-gradient(circle at 38% 34%, color-mix(in srgb, var(--ball-color) 72%, white) 0 12%, var(--ball-color) 46%, color-mix(in srgb, var(--ball-color) 58%, black) 76%, #080808 110%);
    box-shadow:
        inset -3px -5px 7px rgba(0,0,0,.38),
        inset 2px 2px 4px rgba(255,255,255,.34),
        0 4px 8px rgba(0,0,0,.48),
        0 0 0 1px rgba(0,0,0,.35),
        0 0 8px rgba(255,225,151,.06);
    transition: opacity .3s ease, transform .3s cubic-bezier(.2,.8,.2,1), filter .3s ease;
    flex-shrink: 0;
}

.rack-ball.stripe {
    background:
        radial-gradient(circle at 31% 24%, rgba(255,255,255,.96) 0 7%, rgba(255,255,255,.25) 8% 16%, transparent 17%),
        linear-gradient(180deg,
            #f7f1df 0 27%,
            var(--ball-color) 27% 73%,
            #f7f1df 73% 100%);
}

.rack-ball-number {
    width: 42%;
    height: 42%;
    min-width: 8px;
    min-height: 8px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    color: #151515;
    background: #fffdf4;
    border: 1px solid rgba(0,0,0,.14);
    font: 800 clamp(5px, .65vw, 8px)/1 'Inter', sans-serif;
    box-shadow: 0 1px 2px rgba(0,0,0,.35);
}

.rack-ball.active:hover {
    transform: translateY(-2px) scale(1.06);
}

.rack-ball.sunk {
    opacity: .16;
    transform: scale(.68);
    filter: grayscale(1) brightness(.55);
}

/* ===== CANVAS — FIXED SIZING ===== */
.canvas-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: clamp(.2rem, .6vw, .5rem);
    position: relative;
    min-height: 0;
    overflow: hidden;
}

#gameCanvas {
    display: block;
    border-radius: 14px;
    box-shadow:
        0 16px 50px rgba(0,0,0,.55),
        0 4px 12px rgba(0,0,0,.4),
        0 0 0 1px rgba(255,211,114,.08),
        0 0 30px rgba(10,112,72,.05);
    max-width: 96%;
    max-height: 96%;
    touch-action: none;
    background: #0a0503;
    cursor: crosshair;
}

.canvas-hint {
    position: absolute;
    bottom: .7rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding: .4rem .7rem;
    border-radius: 999px;
    background: linear-gradient(180deg, rgba(17,12,7,.88), rgba(7,5,3,.80));
    border: 1px solid rgba(246,213,102,.30);
    box-shadow: 0 8px 22px rgba(0,0,0,.38), inset 0 1px 0 rgba(255,255,255,.08);
    color: rgba(255,247,220,.92);
    font-size: clamp(.5rem, 1.8vw, .65rem);
    line-height: 1.2;
    white-space: nowrap;
    pointer-events: none;
    transition: opacity 0.6s;
    animation: readyHintFloat 1.8s ease-in-out infinite;
}

.canvas-hint b { color: #f6d566; font-weight: 800; }
.hint-cue { color:#f6d566; font-size:.85rem; animation: cueNudge 1s ease-in-out infinite; }

.canvas-hint.hidden {
    opacity: 0;
}

@keyframes readyHintFloat {
    0%,100%{transform:translateX(-50%) translateY(0)}
    50%{transform:translateX(-50%) translateY(-3px)}
}
@keyframes cueNudge {
    0%,100%{transform:translateX(0)}
    50%{transform:translateX(3px)}
}

.canvas-wrap.ready-to-shoot { cursor: grab; }
.canvas-wrap.ready-to-shoot:active { cursor: grabbing; }
.canvas-wrap.ready-pulse::after {
    content:'';
    position:absolute;
    inset:.35rem;
    border-radius:12px;
    border:1px solid rgba(246,213,102,.32);
    pointer-events:none;
    animation: tableReadyPulse 1.1s ease-out forwards;
}
@keyframes tableReadyPulse {
    0%{opacity:0;transform:scale(.985)}
    30%{opacity:1}
    100%{opacity:0;transform:scale(1)}
}

/* Combo Bar */
.combo-bar {
    position: absolute;
    bottom: 0.5rem;
    left: 50%;
    transform: translateX(-50%) scale(0);
    width: min(140px, 36vw);
    height: 22px;
    background: rgba(0,0,0,0.55);
    border-radius: 11px;
    border: 1px solid rgba(255,140,0,0.15);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 10;
    pointer-events: none;
    backdrop-filter: blur(4px);
}

.combo-bar.active {
    transform: translateX(-50%) scale(1);
}

.combo-fill {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    background: linear-gradient(90deg, rgba(255,140,0,0.25), rgba(255,100,0,0.45));
    border-radius: 11px;
    transition: width 0.1s linear;
}

.combo-text {
    position: relative;
    z-index: 1;
    font-family: 'Bebas Neue', sans-serif;
    font-size: 0.75rem;
    color: #ff9a3c;
    letter-spacing: 0.1em;
    text-shadow: 0 0 8px rgba(255,140,0,0.3);
}

/* ===== GAME OVER ===== */
.over-box {
    max-width: 340px;
    padding: clamp(1.4rem, 4.5vw, 2rem);
}

.over-medal {
    font-size: 2.6rem;
    margin-bottom: 0.3rem;
    filter: drop-shadow(0 4px 10px rgba(0,0,0,0.4));
    animation: medalPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes medalPop {
    from { opacity: 0; transform: scale(0.5); }
    to { opacity: 1; transform: scale(1); }
}

.over-title {
    font-family: 'Bebas Neue', sans-serif;
    font-size: clamp(2rem, 7vw, 2.8rem);
    color: #d4af37;
    letter-spacing: 0.1em;
    margin-bottom: 1.3rem;
    text-shadow: 0 2px 12px rgba(212,175,55,0.15);
}

.over-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    margin-bottom: 1.1rem;
}

.stat {
    background: rgba(255,255,255,0.03);
    border-radius: 14px;
    padding: 0.75rem 0.35rem;
    text-align: center;
    border: 1px solid rgba(255,255,255,0.03);
    transition: all 0.2s;
}

.stat:hover {
    background: rgba(255,255,255,0.05);
    border-color: rgba(255,255,255,0.06);
}

.stat-label {
    display: block;
    font-size: 0.56rem;
    color: #777;
    letter-spacing: 0.12em;
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    font-weight: 600;
}

.stat-num {
    display: block;
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.4rem;
    color: #fff;
    line-height: 1;
}

.over-record {
    font-size: 0.9rem;
    color: #d4af37;
    font-weight: 800;
    margin-bottom: 1.1rem;
    animation: recordGlow 1.5s ease infinite;
    letter-spacing: 0.06em;
}

.over-record.hidden {
    display: none;
}

.record-star {
    color: #ffd700;
}

@keyframes recordGlow {
    0%, 100% { text-shadow: 0 0 5px rgba(212,175,55,0.2); }
    50% { text-shadow: 0 0 20px rgba(212,175,55,0.6), 0 0 40px rgba(212,175,55,0.2); }
}

/* ===== COMBO POPUP ===== */
.combo-popup {
    position: fixed;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: 'Bebas Neue', sans-serif;
    font-size: clamp(2rem, 8vw, 3.5rem);
    font-weight: 400;
    color: #ff9a3c;
    text-shadow:
        0 0 30px rgba(255,140,0,0.4),
        0 4px 12px rgba(0,0,0,0.7);
    pointer-events: none;
    opacity: 0;
    z-index: 40;
    white-space: nowrap;
    letter-spacing: 0.05em;
}

.combo-popup.show {
    animation: comboAnim 1.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes comboAnim {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.3); }
    18% { opacity: 1; transform: translate(-50%, -50%) scale(1.15); }
    35% { transform: translate(-50%, -50%) scale(1); }
    80% { opacity: 1; transform: translate(-50%, -58%) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -75%) scale(0.85); }
}

/* ===== PORTRAIT WARNING ===== */
.portrait-warning {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 999;
    background: #0a0503;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 2rem;
    text-align: center;
}
.portrait-warning .pw-icon {
    font-size: 3rem;
    animation: rotatePhone 2s ease-in-out infinite;
}
.portrait-warning .pw-text {
    color: #d4af37;
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.5rem;
    letter-spacing: 0.1em;
}
.portrait-warning .pw-sub {
    color: rgba(255,255,255,0.5);
    font-size: 0.8rem;
    max-width: 260px;
    line-height: 1.5;
}
@keyframes rotatePhone {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-90deg); }
    75% { transform: rotate(-90deg); }
}

/* ===== RESPONSIVE ===== */

/* Small phones */
@media (max-width: 600px) {
    #screen-home::before { inset: 6px; border-radius: 18px; }
    #screen-home .home-content {
        width: calc(100% - 20px);
        min-height: calc(100% - 20px);
        padding: max(.9rem, env(safe-area-inset-top)) .9rem max(.9rem, env(safe-area-inset-bottom));
        gap: clamp(.7rem, 1.8vh, 1rem);
        border-radius: 20px;
    }
    .premium-ball { width: clamp(56px, 16vw, 76px); }
    #screen-home .logo-title { font-size: clamp(3.2rem, 18vw, 5.5rem); }
    #screen-home .logo-sub { font-size: clamp(1.6rem, 8vw, 2.6rem); }
    #screen-home .home-buttons { width: min(88%, 320px); gap: .6rem; }
    #screen-home .btn { min-height: 48px; padding: .7rem 1rem; }
    .home-footnote { display: none; }

    .top-bar { min-height: 48px; padding: 5px 7px; }
    .hud-title { display: none; }
    .icon-btn { width: 34px; height: 34px; }
    .timer-wrap { width: 44px; height: 44px; }
    #timer-val { font-size: 1.25rem; }
    .timer-label { display: none; }
    .cue-badge { display: none; }
    .score-block { min-width: 64px; padding-left: 0; border-left: 0; }
    #score-val { font-size: 1.35rem; }
    .rack-shell { padding: 10px 5px 5px; }
    .rack-caption { top: 3px; font-size: 5px; }
    .ball-rack {
        width: min(72%, 460px); min-height: 32px;
        padding: 5px 8px; gap: 2px;
        border-radius: 10px;
    }
    .ball-rack::before,
    .ball-rack::after { display: none; }
    .rack-ball { width: clamp(14px, 3.8vw, 18px); height: clamp(14px, 3.8vw, 18px); }
    .rack-ball-number { font-size: 4px; min-width: 6px; min-height: 6px; }
    .canvas-wrap { padding: .2rem; }
    #gameCanvas { border-radius: 10px; }
    .canvas-hint { padding:.35rem .55rem; letter-spacing:.04em; bottom:.4rem; font-size: .5rem; }
    .combo-bar { width: min(120px, 32vw); height: 20px; bottom: .4rem; }
    .combo-text { font-size: .7rem; }
}

/* Very small phones */
@media (max-width: 380px) {
    #screen-home .logo-title { font-size: clamp(2.8rem, 16vw, 4.5rem); }
    #screen-home .logo-sub { font-size: clamp(1.4rem, 7vw, 2.2rem); }
    #screen-home .btn { min-height: 44px; font-size: .82rem; }
    .top-bar { padding-inline: 5px; }
    .score-block { min-width: 56px; }
    .ball-rack { gap: 2px; padding-inline: 6px; width: min(80%, 420px); }
    .rack-ball { width: 13px; height: 13px; }
    .rack-ball-number { font-size: 4px; }
}

/* Short heights */
@media (max-height: 720px) {
    #screen-home .home-content { gap: .65rem; padding-top: .7rem; padding-bottom: .7rem; }
    .premium-ball { width: 56px; }
    #screen-home .logo-title { font-size: clamp(3rem, 12vh, 5rem); }
    #screen-home .logo-sub { font-size: clamp(1.5rem, 5.8vh, 2.4rem); }
    #screen-home .logo-tag { margin-top: .2rem; }
    #screen-home .btn { min-height: 46px; }
    #screen-home .home-highscore { min-height: 38px; padding-block: .4rem; }
}

/* Landscape short */
@media (max-height: 520px) and (orientation: landscape) {
    #screen-home .home-content {
        width: min(92vw, 780px);
        min-height: calc(100% - 14px);
        grid-template-columns: .7fr 1.3fr;
        grid-template-areas: 'mark logo' 'buttons buttons' 'score score';
        gap: .45rem .8rem;
        padding: .55rem 1rem;
    }
    .home-top-mark { grid-area: mark; }
    #screen-home .logo-wrap { grid-area: logo; }
    #screen-home .home-buttons { grid-area: buttons; flex-direction: row; width: 100%; max-width: 420px; }
    #screen-home .home-highscore { grid-area: score; justify-self: center; }
    .home-footnote { display: none; }
    #screen-home .logo-title { font-size: clamp(2.8rem, 11vh, 4.5rem); }
    #screen-home .logo-sub { font-size: clamp(1.4rem, 5.5vh, 2.2rem); }
    .premium-ball { width: 52px; }
}

/* Very short landscape */
@media (max-height: 420px) and (orientation: landscape) {
    #screen-home .home-content {
        gap: .35rem;
        padding: .4rem .8rem;
    }
    #screen-home .logo-title { font-size: clamp(2.4rem, 10vh, 3.8rem); }
    #screen-home .btn { min-height: 40px; font-size: .78rem; }
}

/* Ultra short game HUD */
@media (max-height: 480px) {
    .top-bar { padding: 0.2rem 0.3rem; min-height: 38px; }
    .ball-rack { padding: 0.1rem 0.2rem; gap: 2px; min-height: 28px; }
    .rack-ball { width: 11px; height: 11px; }
    .rack-ball-number { font-size: 4px; min-width: 5px; min-height: 5px; }
    .timer-wrap { width: 34px; height: 34px; }
    #timer-val { font-size: 1rem; }
    .canvas-wrap { padding: 0.1rem; }
    .canvas-hint { display: none; }
    .rack-shell { padding: 8px 3px 4px; }
    .rack-caption { display: none; }
}

/* Portrait mobile warning */
@media (max-width: 600px) and (orientation: portrait) {
    .portrait-warning { display: flex; }
}

/* ===== SAFE AREA SUPPORT ===== */
@supports (padding: max(0px)) {
    .top-bar {
        padding-top: max(6px, env(safe-area-inset-top));
        padding-left: max(clamp(8px, 1.5vw, 16px), env(safe-area-inset-left));
        padding-right: max(clamp(8px, 1.5vw, 16px), env(safe-area-inset-right));
    }
    #screen-home .home-content {
        padding-top: max(clamp(1.2rem, 3vh, 2rem), env(safe-area-inset-top));
        padding-bottom: max(clamp(1.2rem, 3vh, 2rem), env(safe-area-inset-bottom));
        padding-left: max(clamp(1rem, 4vw, 2rem), env(safe-area-inset-left));
        padding-right: max(clamp(1rem, 4vw, 2rem), env(safe-area-inset-right));
    }
}

/* ===== ANIMATIONS ===== */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(24px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   DESKTOP STAGE LOCK — 1600 × 900
   Keeps large PC/2K/4K monitors from enlarging the game UI.
   Mobile and touch layouts remain controlled by the rules above.
   ============================================================ */
@media (min-width: 1200px) and (min-height: 600px) and (hover: hover) and (pointer: fine) {
    html,
    body {
        width: 100%;
        height: 100%;
        min-width: 0;
        min-height: 0;
        background:
            radial-gradient(ellipse at 50% 45%, #18100b 0%, #0b0604 48%, #030201 100%);
    }

    body {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    #app {
        position: relative;
        flex: 0 0 auto;
        width: min(100vw, 1600px);
        height: min(100vh, 900px);
        max-width: 1600px;
        max-height: 900px;
        overflow: hidden;
        isolation: isolate;
        background: #0a0503;
        box-shadow:
            0 0 0 1px rgba(218, 173, 60, .08),
            0 30px 100px rgba(0, 0, 0, .72);
    }

    /* Stop desktop typography/components growing with the monitor. */
    #screen-home .home-content {
        width: 520px;
        max-width: 520px;
        padding: 28px 32px;
        gap: 18px;
    }

    .premium-ball {
        width: 92px;
    }

    #screen-home .logo-title {
        font-size: 112px;
    }

    #screen-home .logo-sub {
        font-size: 48px;
    }

    #screen-home .logo-tag {
        font-size: 12px;
    }

    #screen-home .home-buttons {
        width: 260px;
    }

    #screen-home .btn {
        min-height: 62px;
        font-size: 16px;
        padding: 14px 20px;
    }

    /* Stable PC HUD proportions. */
    .top-bar {
        min-height: 52px;
        padding: 6px 16px;
    }

    .hud-title span {
        font-size: 20px;
    }

    .icon-btn,
    .cue-badge {
        width: 36px;
        height: 36px;
    }

    .timer-wrap {
        width: 48px;
        height: 48px;
    }

    #timer-val {
        font-size: 23px;
    }

    #score-val {
        font-size: 25px;
    }

    .ball-rack {
        width: 520px;
        min-height: 32px;
        padding: 6px 16px;
        gap: 8px;
    }

    .rack-ball {
        width: 24px;
        height: 24px;
    }

    .canvas-wrap {
        padding: 8px;
    }

    #gameCanvas {
        max-width: calc(100% - 16px);
        max-height: calc(100% - 16px);
    }
}
.btn-gold {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;

    min-width: 140px;
    height: 52px;
    padding: 0 26px;

    font-size: 20px;
    font-weight: 800;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: #3d2500;
    text-shadow:
        0 1px 0 rgba(255,255,255,.55),
        0 -1px 0 rgba(120,70,0,.2);

    cursor: pointer;
    user-select: none;

    border-radius: 14px;
    border: 2px solid #ffe48a;

    background:
        linear-gradient(
            180deg,
            #fff7c8 0%,
            #ffe36f 12%,
            #f6ca34 45%,
            #d69d18 72%,
            #b97908 100%
        );

    box-shadow:
        inset 0 2px 0 rgba(255,255,255,.75),
        inset 0 -4px 0 rgba(115,67,0,.35),
        0 4px 0 #8f5d00,
        0 10px 24px rgba(255,180,0,.45);
        
    transition: all .18s ease;
}

.btn-gold::before{
    content:"";
    position:absolute;
    left:4px;
    right:4px;
    top:4px;
    height:40%;
    border-radius:10px;
    background:linear-gradient(
        rgba(255,255,255,.85),
        rgba(255,255,255,0)
    );
    pointer-events:none;
}

.btn-gold:hover{
    transform:translateY(-2px) scale(1.03);

    box-shadow:
        inset 0 2px 0 rgba(255,255,255,.8),
        inset 0 -4px 0 rgba(115,67,0,.35),
        0 6px 0 #8f5d00,
        0 18px 34px rgba(255,200,50,.6);
}

.btn-gold:active{
    transform:translateY(4px);

    box-shadow:
        inset 0 2px 0 rgba(255,255,255,.6),
        inset 0 -2px 0 rgba(115,67,0,.35),
        0 1px 0 #8f5d00;
}