/* Font Awesome icon sizing for control buttons */
.icon-btn i.fa-solid {
    font-size: 1.6em;
    width: 1em;
    height: 1em;
    display: flex;
    align-items: center;
    justify-content: center;
}
.icon-btn span {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}
/* Game screen horizontal button row */
.game-btn-row {
    position: fixed;
    bottom: 14px;
    right: 14px;
    z-index: 2000; /* sit above HUD and start overlays so buttons are visible on home screen */
    display: flex;
    flex-direction: row;
    gap: 18px;
    justify-content: center;
}
.game-btn-row .icon-btn {
    background: #182232;
    border-radius: 50%;
    width: 54px;
    height: 54px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 12px #0006;
    border: none;
    cursor: pointer;
    transition: background 0.2s, box-shadow 0.2s;
    opacity: 1; /* ensure visible even if parent inherits dim */
    pointer-events: auto;
    position: relative;
    z-index: 2005; /* ensure each button sits above overlays */
    border: 1px solid rgba(255,255,255,0.06);
    background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(0,0,0,0.12));
}
.game-btn-row .icon-btn:hover {
    box-shadow: 0 10px 30px rgba(63,208,255,0.12);
    transform: translateY(-2px);
}
.game-btn-row .icon-btn:hover {
    background: #22304a;
    box-shadow: 0 4px 18px #3fd0ff88;
}
/* Overlay horizontal button row */
.overlay-btn-row {
    display: flex;
    flex-direction: row;
    gap: 18px;
    justify-content: center;
    margin-top: 18px;
}
.overlay-btn-row .icon-btn {
    background: #182232;
    border-radius: 50%;
    width: 54px;
    height: 54px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 12px #0006;
    border: none;
    cursor: pointer;
    transition: background 0.2s, box-shadow 0.2s;
}
.overlay-btn-row .icon-btn:hover {
    background: #22304a;
    box-shadow: 0 4px 18px #3fd0ff88;
}
.start-overlay {
    cursor: pointer;
    pointer-events: auto;
    background: #0e1a24;
    overflow: hidden;
    z-index: 1000;
}
.start-bg-canvas {
    position: absolute;
    inset: 0;
    width: 100vw;
    height: 100vh;
    z-index: 0;
    display: block;
    pointer-events: none;
}
.start-content {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 600px;
}
.hud-left {
    position: absolute;
    left: 14px;
    top: 14px;
    display: grid;
    grid-template-columns: 1fr; /* single column so all items align to same left margin */
    grid-auto-rows: auto;
    gap: 14px; /* uniform vertical spacing */
    pointer-events: auto;
    filter: drop-shadow(0 6px 18px rgba(0,0,0,0.35));
}

#score-chip {
    grid-column: 1 / 2;
}

#lives-chip {
    grid-column: 1 / 2;
}

#powerupBar {
    grid-column: 1 / 2;
    margin-left: 28px;
}

#manaBar {
    grid-column: 1 / 2;
    width: 250px; /* compact width but full alignment */
    min-width: 160px;
    margin-top: 88px; /* ensure at least 15px gap under powerups */
}

.start-content {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 600px;
}
.game-title {
    font-size: 3.2em;
    font-weight: 900;
    letter-spacing: 0.04em;
    margin-bottom: 0.2em;
    margin-top: 0.2em;
    color: #3fd0ff;
    text-shadow: 0 4px 32px #3fd0ff55, 0 1px 0 #fff, 0 0 8px #0ff8;
    text-align: center;
}
.start-cta {
    margin: 1.5em 0 0.5em 0;
    font-size: 1.3em;
    font-weight: bold;
    color: #fff;
    text-shadow: 0 2px 12px #3fd0ff88;
    letter-spacing: 0.03em;
    cursor: pointer;
    transition: color 0.2s;
}
.start-cta:hover {
    color: #3fd0ff;
}
/* Start overlay enhancements */
.start-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.start-card {
    padding: 22px;
    max-width: 560px;
}
.game-title {
    font-size: 3.6rem;
    letter-spacing: 0.04em;
    color: #7ef2ff;
    text-shadow: 0 8px 40px rgba(126,242,255,0.12), 0 2px 8px rgba(0,0,0,0.6);
}
.subtitle {
    color: rgba(255,255,255,0.75);
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: lowercase;
}
.howto { text-align:left; max-width:480px; margin: 0 auto 18px auto; }
.start-cta {
    display: inline-block;
    padding: 14px 28px;
    border-radius: 999px;
    background: linear-gradient(90deg,#00bfff,#7a43ff);
    color: #061621;
    font-weight: 900;
    box-shadow: 0 10px 40px rgba(122,67,255,0.18), 0 2px 8px rgba(0,0,0,0.4);
    cursor: pointer;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.start-cta:hover { transform: translateY(-4px); box-shadow: 0 18px 60px rgba(122,67,255,0.22); }

/* Decorative orbs in start header (subtle, animated) */
.start-orbs { position: relative; width: 220px; height: 44px; }
.orb { position: absolute; border-radius: 50%; opacity: 0.9; filter: blur(6px); }
.o1 { width: 30px; height: 30px; left: 10px; top: 8px; background: #ff7a7a; animation: orb-float 6s ease-in-out infinite; }
.o2 { width: 22px; height: 22px; left: 70px; top: 4px; background: #ffd36a; animation: orb-float 5.2s ease-in-out infinite; }
.o3 { width: 26px; height: 26px; left: 120px; top: 10px; background: #6ce0ff; animation: orb-float 5.8s ease-in-out infinite; }
.o4 { width: 18px; height: 18px; left: 180px; top: 6px; background: #c78bff; animation: orb-float 6.4s ease-in-out infinite; }

@keyframes orb-float {
    0% { transform: translateY(0) translateX(0) scale(1); }
    50% { transform: translateY(-8px) translateX(4px) scale(1.05); }
    100% { transform: translateY(0) translateX(0) scale(1); }
}

/* Falling decorative elements */
.fall-container { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 5; }
.fall { position: absolute; bottom: 120%; width: 18px; height: 18px; border-radius: 50%; opacity: 0.9; filter: blur(2px); }
.fall.c1 { background: #ff7a7a; left: 10%; animation: fall 8s linear infinite; }
.fall.c2 { background: #ffd36a; left: 28%; width: 12px; height: 12px; animation: fall 6.6s linear infinite; }
.fall.c3 { background: #6ce0ff; left: 46%; animation: fall 7.4s linear infinite; }
.fall.c4 { background: #c78bff; left: 64%; width: 14px; height: 14px; animation: fall 7.8s linear infinite; }
.fall.c5 { background: #7ef2ff; left: 82%; width: 10px; height: 10px; animation: fall 6.2s linear infinite; }

@keyframes fall {
    0% { transform: translateY(0) rotate(0deg); opacity: 0; }
    10% { opacity: 0.9; }
    100% { transform: translateY(130vh) rotate(360deg); opacity: 0.1; }
}
/* Additional falling shapes: stars and squares with slow rotation */
.fall.star {
    width: 20px; height: 20px; background: transparent; left: 18%;
    animation: fall-star 9.6s linear infinite; filter: drop-shadow(0 6px 16px rgba(255,255,255,0.08));
}
.fall.square {
    width: 16px; height: 16px; background: #ffd36a; left: 36%; border-radius:4px;
    animation: fall-square 8.8s linear infinite; filter: drop-shadow(0 6px 12px rgba(0,0,0,0.2));
}
.fall.star:before {
    content: '✦'; display: block; font-size: 18px; line-height: 18px; text-align: center; color: #fff8; text-shadow: 0 2px 8px rgba(126,242,255,0.12);
}

@keyframes fall-star {
    0% { transform: translateY(0) rotate(0deg) scale(0.9); opacity: 0; }
    12% { opacity: 0.95; }
    100% { transform: translateY(130vh) rotate(540deg) scale(1.05); opacity: 0.08; }
}
@keyframes fall-square {
    0% { transform: translateY(0) rotate(8deg) scale(0.95); opacity: 0; }
    10% { opacity: 0.9; }
    100% { transform: translateY(130vh) rotate(-360deg) scale(1); opacity: 0.06; }
}
/* Credit line on start overlay */
.credit {
    margin-top: 12px;
    font-size: 0.9em;
    color: rgba(255,255,255,0.75);
    text-align: center;
}
.credit a {
    color: #fff;
    text-decoration: underline;
    font-weight: 700;
}

/* Footer credit styling */
.footer-credit .credit {
    backdrop-filter: blur(6px);
    box-shadow: 0 6px 24px rgba(0,0,0,0.45);
}
@keyframes start-bg-anim {
    0% { background-position: 60% 40%; }
    100% { background-position: 40% 60%; }
}
:root {
    --bg: #081017;
    --panel: #0f1720;
    --ink: #e8f1ff;
    --muted: #9ab0c6;
    --red: #FF4B4B;
    --orange: #FFA33C;
    --yellow: #FFD93D;
    --green: #4ADE80;
    --blue: #60A5FA;
    --indigo: #6366F1;
    --violet: #A78BFA;
    --white: #ffffff;
    --heart: #ff5b6e;
}

html,
body {
    height: 100%;
    margin: 0;
    font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
    background: var(--bg);
    color: var(--ink);
}

.game-container {
    position: fixed;
    inset: 0;
    padding: 25px;
    display: flex;
    align-items: center;
    justify-content: center;
}

canvas {
    display: block;
    background: transparent;
    z-index: 0;
}

.hud-layer {
    position: fixed;
    left: 0;
    top: 0;
    right: 0;
    pointer-events: none;
    z-index: 2;
}

.hud-left,
.hud-right {
    pointer-events: auto;
    padding: 14px;
    display: flex;
    gap: 10px;
    align-items: center;
}

.hud-left {
    position: fixed;
    left: 14px;
    top: 14px;
}

.hud-right {
    position: fixed;
    right: 14px;
    top: 14px;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 12px;
    background: linear-gradient(180deg, rgba(10, 16, 24, 0.85), rgba(6,10,14,0.85));
    border: 1px solid rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(8px);
    font-weight: 700;
    z-index: 25; /* ensure chips float above mana */
}

.dot {
    width: 24px; /* ~1.3x */
    height: 24px;
    border-radius: 50%;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.6), inset 0 1px rgba(255,255,255,0.06);
    display: inline-block;
}

.small {
    font-size: 13px;
    color: var(--muted);
}

.hearts {
    display: inline-flex;
    gap: 6px;
    align-items: center;
}

.heart-ui {
    width: 24px; /* ~1.3x */
    height: 24px;
    background: linear-gradient(45deg, var(--heart), #ff8b9a);
    clip-path: polygon(50% 80%, 0 40%, 20% 0, 50% 20%, 80% 0, 100% 40%);
    opacity: 1;
    display: inline-block;
    margin-right: 4px;
    box-shadow: 0 3px 6px rgba(0,0,0,0.35);
}

.heart-ui.dim {
    opacity: 0.22;
}

.control-btn {
    appearance: none;
    border: 0;
    background: rgba(255, 255, 255, 0.04);
    color: var(--ink);
    padding: 10px;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 700;
    margin-left: 8px;
    margin-bottom: 2px;
    font-size: 18px; /* ~1.3x */
    display: flex;
    align-items: center;
    justify-content: center;
}
/* Font Awesome icon sizing for control buttons */
.icon-btn i.fa-solid {
    font-size: 1.7em;
    width: 1em;
    height: 1em;
    display: flex;
    align-items: center;
    justify-content: center;
}

.overlay {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.55);
    z-index: 10;
}

.overlay.show {
    display: flex;
}

.card {
    background: #0d151e;
    border: 1px solid #1e2a38;
    border-radius: 12px;
    padding: 18px;
    min-width: 300px;
    text-align: center;
    color: var(--ink);
    font-size: 18px;
}

#powerupBar span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 50px; /* ~1.3x */
    height: 44px;
    border-radius: 10px;
    background: rgba(255,255,255,0.03);
    color: var(--ink);
    font-size: 22px;
    transition: transform 0.18s, box-shadow 0.18s, opacity 0.18s;
    opacity: 0.65;
    border: 1px solid rgba(255,255,255,0.04);
    line-height: 1;
    margin: 0 4px;
}

#powerupBar span[style*="opacity: 1"] {
    opacity: 1 !important;
    filter: drop-shadow(0 0 7px #fffdaa);
}

@keyframes beat-pop {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.22);
    }

    100% {
        transform: scale(1);
    }
}

.bubble-special {
    box-shadow: 0 0 12px 4px #fff8;
    border-radius: 50%;
    position: absolute;
    pointer-events: none;
}

.beating-anim {
    animation: beat-pop 0.7s infinite;
}

/* Mana bar styling (overrides inline styles from JS where needed) */
#manaBar {
    position: absolute; /* JS may set exact coords */
    left: 18px;
    top: 54px;
    width: 140px;
    height: 18px;
    background: linear-gradient(180deg, rgba(12,18,24,0.6), rgba(6,10,14,0.6));
    border: 2px solid rgba(0,255,208,0.12);
    border-radius: 8px;
    padding: 2px;
    box-shadow: 0 4px 18px rgba(0,255,208,0.06), inset 0 0 10px rgba(0,255,208,0.03);
    z-index: 20;
    transition: opacity 0.2s, transform 0.15s;
    pointer-events: auto;
}

#manaBarFill {
    height: 100%;
    width: 100%; /* controlled by JS inline style */
    display: block;
    background: linear-gradient(90deg,#00ffd0 0%, #00bfff 70%, #7a43ff 100%);
    border-radius: 6px;
    box-shadow: 0 0 18px rgba(0,255,208,0.14), inset 0 0 12px rgba(255,255,255,0.03);
    transition: width 0.22s cubic-bezier(.2,.9,.2,1), filter 0.18s, transform 0.18s;
}

/* low mana subtle dim (JS can toggle body.low-mana to activate) */
body.low-mana #manaBarFill { filter: grayscale(0.6) brightness(0.75); }
body.full-mana #manaBarFill { box-shadow: 0 0 30px rgba(122,67,255,0.25), inset 0 0 18px rgba(255,255,255,0.06); }

/* Powerup tile polish */
#powerupBar {
    display: inline-flex;
    gap: 8px;
    align-items: center;
}

#powerupBar span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 34px;
    border-radius: 8px;
    background: rgba(255,255,255,0.03);
    color: var(--ink);
    font-size: 18px;
    transition: transform 0.18s, box-shadow 0.18s, opacity 0.18s;
    opacity: 0.55;
    border: 1px solid rgba(255,255,255,0.04);
}

#powerupBar span:hover { transform: translateY(-2px) scale(1.03); opacity: 0.9; }

/* Active powerup (JS already sets inline opacity to 1) */
#powerupBar span[style*="opacity: 1"] {
    opacity: 1 !important;
    transform: scale(1.06);
    box-shadow: 0 6px 24px rgba(255, 215, 90, 0.12), inset 0 0 8px rgba(255,255,255,0.02);
    background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.00));
}

/* make emoji icons crisper and centered */
#powerupBar span { line-height: 1; }

/* Control button tweaks for better hit area and hover glow */
.control-btn {
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(255,255,255,0.03);
    transition: background 0.18s, box-shadow 0.18s, transform 0.12s;
}
.control-btn:focus { outline: 2px solid rgba(63,208,255,0.16); outline-offset: 2px; }
.control-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(63,208,255,0.06); }


#game {
    cursor: none;
}