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

html, body {
    background: #000;
    font-family: "Press Start 2P", "Courier New", "Microsoft JhengHei", "PingFang TC", monospace, sans-serif;
    color: #fff;
}

body {
    display: flex;
    flex-direction: column;
    align-items: center;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    min-height: 100vh;
    overflow-x: hidden;
}

#stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 560px;
    padding: 6px 4px 2px;
}

#hud {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 8px;
    font-size: 14px;
}

.hudCol {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.hudLabel {
    color: #fff;
    font-size: 12px;
    letter-spacing: 1px;
}

.hudLabel.blink {
    animation: hudBlink 1s steps(2) infinite;
}

@keyframes hudBlink {
    50% {
        opacity: 0.25;
    }
}

.hudVal {
    color: #ffe600;
    font-weight: bold;
    font-size: 16px;
}

.hudBtns {
    flex-direction: row;
    gap: 8px;
}

.iconBtn {
    background: #111;
    color: #ffe600;
    border: 2px solid #2121de;
    border-radius: 6px;
    font-size: 16px;
    width: 38px;
    height: 38px;
    cursor: pointer;
}

.iconBtn:active {
    background: #2121de;
}

#canvasWrap {
    position: relative;
    width: 100%;
    touch-action: none;
}

#gameCanvas {
    display: block;
    width: 100%;
    height: auto;
    image-rendering: pixelated;
}

#msgLayer {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

#statusBar {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 10px;
    min-height: 36px;
}

#livesBox {
    display: flex;
    gap: 6px;
}

.lifeIcon {
    width: 20px;
    height: 20px;
    background: #ffe600;
    border-radius: 50%;
    clip-path: polygon(100% 18%, 50% 50%, 100% 82%, 100% 100%, 0 100%, 0 0, 100% 0);
}

#levelBox {
    color: #00ffff;
    font-size: 13px;
}

#fruitBox {
    display: flex;
    gap: 4px;
    font-size: 18px;
}

.overlay {
    position: fixed;
    inset: 0;
    background: radial-gradient(circle at 50% 30%, #0a0a3c 0%, #000 70%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
    gap: 14px;
    padding: 20px;
}

.overlay.hidden {
    display: none;
}

.titleWrap {
    text-align: center;
}

.gameTitle {
    font-size: 56px;
    font-weight: bold;
    color: #ffe600;
    text-shadow: 0 0 12px #ffe600, 0 0 30px #ff8800, 4px 4px 0 #d40000;
    letter-spacing: 8px;
    animation: titleGlow 2s ease-in-out infinite alternate;
}

@keyframes titleGlow {
    from {
        text-shadow: 0 0 8px #ffe600, 0 0 18px #ff8800, 4px 4px 0 #d40000;
    }
    to {
        text-shadow: 0 0 18px #ffe600, 0 0 44px #ff8800, 4px 4px 0 #d40000;
    }
}

.gameSub {
    margin-top: 8px;
    color: #00ffff;
    font-size: 14px;
    letter-spacing: 3px;
}

.marquee {
    width: 100%;
    max-width: 420px;
    overflow: hidden;
    border-top: 3px solid #2121de;
    border-bottom: 3px solid #2121de;
    padding: 10px 0;
}

.marqueeInner {
    display: flex;
    align-items: center;
    gap: 14px;
    animation: marqueeMove 5s linear infinite;
    width: max-content;
}

@keyframes marqueeMove {
    from {
        transform: translateX(-40%);
    }
    to {
        transform: translateX(110%);
    }
}

.mPac {
    width: 30px;
    height: 30px;
    background: #ffe600;
    border-radius: 50%;
    clip-path: polygon(100% 22%, 55% 50%, 100% 78%, 100% 100%, 0 100%, 0 0, 100% 0);
    animation: pacChomp 0.3s steps(2) infinite;
}

@keyframes pacChomp {
    50% {
        clip-path: polygon(100% 46%, 55% 50%, 100% 54%, 100% 100%, 0 100%, 0 0, 100% 0);
    }
}

.mDots {
    color: #ffb8ae;
    font-size: 22px;
    letter-spacing: 6px;
}

.mGhost, .castGhost {
    width: 28px;
    height: 28px;
    display: inline-block;
    background: var(--gc, #ff0000);
    border-radius: 14px 14px 0 0;
    position: relative;
    clip-path: polygon(0 0, 100% 0, 100% 100%, 83% 86%, 66% 100%, 50% 86%, 33% 100%, 16% 86%, 0 100%);
}

.mGhost::before, .castGhost::before {
    content: "";
    position: absolute;
    top: 8px;
    left: 4px;
    width: 8px;
    height: 9px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 12px 0 0 #fff;
}

.mGhost::after, .castGhost::after {
    content: "";
    position: absolute;
    top: 11px;
    left: 7px;
    width: 4px;
    height: 4px;
    background: #2121de;
    border-radius: 50%;
    box-shadow: 12px 0 0 #2121de;
}

.g1 {
    --gc: #ff0000;
}

.g2 {
    --gc: #ffb8ff;
}

.g3 {
    --gc: #00ffff;
}

.g4 {
    --gc: #ffb851;
}

.castList {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.castRow {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
}

.castName {
    width: 150px;
    font-weight: bold;
}

.castDesc {
    color: #aaa;
    font-size: 13px;
}

.bigBtn {
    background: linear-gradient(180deg, #ffe600, #ffae00);
    color: #200;
    border: none;
    border-radius: 10px;
    font-size: 20px;
    font-weight: bold;
    font-family: inherit;
    padding: 14px 46px;
    cursor: pointer;
    box-shadow: 0 4px 0 #b86b00, 0 0 24px rgba(255, 230, 0, 0.35);
    letter-spacing: 4px;
}

.bigBtn:active {
    transform: translateY(3px);
    box-shadow: 0 1px 0 #b86b00;
}

.ghostBtn {
    background: #222;
    color: #ccc;
    box-shadow: 0 4px 0 #000;
}

.reviveBtn {
    background: linear-gradient(180deg, #4cff4c, #00b400);
    color: #002800;
    box-shadow: 0 4px 0 #006400, 0 0 24px rgba(0, 255, 0, 0.35);
}

.adTag {
    background: #002800;
    color: #4cff4c;
    border-radius: 4px;
    font-size: 12px;
    padding: 2px 6px;
    vertical-align: middle;
    margin-left: 4px;
}

.startHint {
    color: #888;
    font-size: 13px;
}

.startHigh {
    color: #ffe600;
    font-size: 14px;
}

.overTitle {
    font-size: 40px;
    font-weight: bold;
    color: #ff3030;
    text-shadow: 0 0 16px #ff0000;
    letter-spacing: 6px;
}

.overTitle.win {
    color: #4cff4c;
    text-shadow: 0 0 16px #00ff00;
}

.overScore {
    font-size: 22px;
    color: #ffe600;
}

.overScore.small {
    font-size: 15px;
    color: #00ffff;
}

.overNew {
    color: #ff8800;
    font-size: 18px;
    animation: hudBlink 0.6s steps(2) infinite;
}

.overNew.hidden {
    display: none;
}

.bigBtn.hidden {
    display: none;
}

.readyText {
    color: #ffe600;
    font-size: 26px;
    font-weight: bold;
    letter-spacing: 4px;
    text-shadow: 0 0 10px #ffe600;
}

.seo {
    background: #0a0a14;
    color: #bbb;
    max-width: 560px;
    width: 100%;
    margin: 28px auto 40px;
    padding: 20px 24px;
    border: 1px solid #2121de;
    font-size: 14px;
    line-height: 1.9;
    font-family: "Microsoft JhengHei", "PingFang TC", sans-serif;
}

.seo h1 {
    font-size: 20px;
    color: #ffe600;
    margin-bottom: 10px;
}

.seo h2 {
    font-size: 16px;
    color: #00ffff;
    margin: 16px 0 6px;
}

.seo p {
    margin-bottom: 8px;
}

.seo ul {
    padding-left: 22px;
    margin-bottom: 8px;
}

@media (max-width: 420px) {
    .gameTitle {
        font-size: 40px;
    }
    .castName {
        width: 130px;
    }
}
