/* Sweetoria Land — pastel candy UI + mobile touch */

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #fee5ee;
    font-family: 'Trebuchet MS', 'Comic Sans MS', sans-serif;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    color: #4a2050;
    touch-action: none;
}

#gameRoot {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
}

#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, #ffd1e8 0%, #d8e8ff 100%);
    touch-action: none;
}

.hidden { display: none !important; }

/* ============ LOADING ============ */
#loadingScreen {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, #ffe5f0 0%, #e8d5ff 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    color: #4a2050;
}

.loader-spinner {
    width: 80px;
    height: 80px;
    border: 8px solid #ffd1e8;
    border-top-color: #e85091;
    border-right-color: #ffb84d;
    border-bottom-color: #6da8ff;
    border-radius: 50%;
    animation: spin 1.2s linear infinite;
    margin-bottom: 24px;
}

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

.loader-text {
    font-size: 28px;
    color: #e85091;
    text-shadow: 2px 2px 0 #fff;
    letter-spacing: 4px;
    margin-bottom: 16px;
    font-weight: bold;
}

.loader-progress {
    width: 320px;
    max-width: 80vw;
    height: 14px;
    background: rgba(255,255,255,0.6);
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid #ffb6d5;
}

#loaderBar {
    height: 100%;
    background: linear-gradient(90deg, #e85091, #ffb84d, #b3d9ff);
    width: 0%;
    transition: width 0.2s;
}

.loader-tip {
    margin-top: 16px;
    font-size: 14px;
    color: #8855aa;
    font-style: italic;
    padding: 0 16px;
    text-align: center;
}

/* ============ OVERLAYS ============ */
.overlay {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
    background: linear-gradient(135deg, rgba(255, 209, 232, 0.92) 0%, rgba(216, 232, 255, 0.92) 100%);
    backdrop-filter: blur(8px);
    overflow-y: auto;
    padding: 30px 20px;
}

#titleScreen {
    background: radial-gradient(ellipse at center, #ffd9ec 0%, #c8b0ff 100%);
}

#titleLogo {
    max-width: min(700px, 85vw);
    width: 100%;
    height: auto;
    filter: drop-shadow(0 8px 16px rgba(232, 80, 145, 0.4));
    animation: bobble 3s ease-in-out infinite;
}

@keyframes bobble {
    0%, 100% { transform: translateY(0) rotate(-2deg); }
    50% { transform: translateY(-12px) rotate(2deg); }
}

.title-subtitle {
    font-size: 22px;
    color: #fff;
    text-shadow: 2px 2px 0 #e85091, 4px 4px 0 #4a2050;
    margin-top: 8px;
    margin-bottom: 24px;
    letter-spacing: 4px;
}

/* Character preview */
.character-preview {
    display: flex;
    gap: 24px;
    margin: 16px 0;
    flex-wrap: wrap;
    justify-content: center;
}

.char-card {
    background: rgba(255, 255, 255, 0.85);
    padding: 16px 24px;
    border-radius: 16px;
    border: 4px solid #e85091;
    text-align: center;
    box-shadow: 0 6px 0 #b03070, 0 12px 24px rgba(0,0,0,0.2);
    min-width: 140px;
}

#charCardLila {
    border-color: #c050ff;
    box-shadow: 0 6px 0 #8030c0, 0 12px 24px rgba(0,0,0,0.2);
}

.char-icon {
    font-size: 64px;
    line-height: 1;
    margin-bottom: 8px;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.2));
}

.char-name {
    font-size: 24px;
    font-weight: bold;
    color: #e85091;
    text-shadow: 1px 1px 0 #fff;
    margin-bottom: 4px;
}

#charCardLila .char-name { color: #c050ff; }

.char-info {
    font-size: 12px;
    color: #4a2050;
    line-height: 1.4;
}

/* Buttons */
.big-btn {
    padding: 16px 48px;
    font-size: 22px;
    font-weight: bold;
    background: linear-gradient(180deg, #ff89bb 0%, #e85091 100%);
    color: #fff;
    border: 4px solid #fff;
    border-radius: 30px;
    cursor: pointer;
    box-shadow: 0 6px 0 #b03070, 0 8px 16px rgba(232, 80, 145, 0.4);
    text-shadow: 2px 2px 0 #b03070;
    letter-spacing: 2px;
    transition: all 0.1s;
    margin-top: 16px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.big-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 0 #b03070, 0 12px 20px rgba(232, 80, 145, 0.5);
}

.big-btn:active {
    transform: translateY(4px);
    box-shadow: 0 2px 0 #b03070;
}

/* Controls help */
.title-controls {
    margin-top: 28px;
    background: rgba(255, 255, 255, 0.85);
    padding: 18px 28px;
    border-radius: 16px;
    border: 3px solid #c050ff;
    max-width: 580px;
    box-shadow: 0 6px 16px rgba(0,0,0,0.15);
}

.title-controls h3 {
    text-align: center;
    color: #c050ff;
    margin-bottom: 12px;
    letter-spacing: 2px;
    font-size: 18px;
}

.controls-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 6px 16px;
    align-items: center;
    font-size: 14px;
    color: #4a2050;
}

.key {
    background: linear-gradient(180deg, #fff 0%, #ffe0ee 100%);
    color: #e85091;
    padding: 4px 10px;
    border-radius: 6px;
    font-family: monospace;
    font-weight: bold;
    text-align: center;
    border: 2px solid #e85091;
    box-shadow: 0 2px 0 #b03070;
    font-size: 12px;
}

.title-credit {
    margin-top: 20px;
    font-size: 12px;
    text-align: center;
    color: #6a4080;
    line-height: 1.6;
    max-width: 600px;
    padding: 0 16px;
}

/* Pause */
#pauseScreen h2 {
    font-size: 64px;
    color: #fff;
    text-shadow: 4px 4px 0 #e85091, 8px 8px 0 #4a2050;
    margin-bottom: 32px;
    letter-spacing: 8px;
}

#pauseScreen .big-btn {
    width: 280px;
    margin-top: 8px;
}

/* HUD */
#hud {
    position: fixed;
    top: env(safe-area-inset-top, 0);
    left: env(safe-area-inset-left, 0);
    right: env(safe-area-inset-right, 0);
    padding: 14px 22px;
    display: flex;
    align-items: flex-start;
    z-index: 50;
    pointer-events: none;
    justify-content: space-between;
    color: #fff;
    text-shadow: 2px 2px 0 #4a2050, 0 0 4px rgba(0,0,0,0.6);
    gap: 8px;
}

.hud-left, .hud-right {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-shrink: 0;
}

.hud-left { align-items: flex-start; }
.hud-right { align-items: flex-end; }

.hud-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    flex-shrink: 1;
}

.hud-item {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(232, 80, 145, 0.7);
    padding: 5px 14px;
    border-radius: 16px;
    border: 2px solid rgba(255,255,255,0.7);
    font-size: 22px;
    font-weight: bold;
}

.hud-item img {
    width: 28px;
    height: 28px;
    filter: drop-shadow(0 2px 0 rgba(0,0,0,0.5));
}

.hud-keys {
    background: rgba(150, 80, 200, 0.7);
}

.hud-keys img {
    width: 24px;
    height: 24px;
    margin-right: 2px;
}

.hud-scene {
    background: rgba(0, 0, 0, 0.5);
    padding: 6px 24px;
    border-radius: 20px;
    border: 2px solid #e85091;
    font-size: 18px;
    letter-spacing: 2px;
    color: #fff;
    text-align: center;
    max-width: 60vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.char-active {
    background: rgba(255, 255, 255, 0.85);
    color: #e85091;
    padding: 4px 16px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: bold;
    text-shadow: none;
    border: 2px solid #e85091;
}

.char-active.lila {
    color: #c050ff;
    border-color: #c050ff;
}

.hud-health {
    font-size: 32px;
    display: flex;
    gap: 4px;
    background: rgba(0, 0, 0, 0.4);
    padding: 4px 12px;
    border-radius: 16px;
    border: 2px solid rgba(255, 100, 100, 0.5);
}

.heart {
    color: #ff3366;
    text-shadow: 2px 2px 0 #4a2050;
    transition: opacity 0.3s, transform 0.3s;
}

.heart.empty {
    color: #444;
    text-shadow: 1px 1px 0 #000;
}

.hud-ammo {
    background: rgba(232, 80, 145, 0.7);
    padding: 5px 14px;
    border-radius: 16px;
    border: 2px solid rgba(255,255,255,0.7);
    font-size: 18px;
    font-weight: bold;
}

.ammo-label {
    font-size: 24px;
    margin-right: 4px;
}

.ammo-max {
    opacity: 0.7;
    font-size: 14px;
}

.sweet-burst-meter {
    background: rgba(255, 100, 50, 0.5);
    padding: 4px 8px 6px;
    border-radius: 12px;
    border: 2px solid rgba(255,255,255,0.7);
    min-width: 140px;
}

.burst-label {
    font-size: 11px;
    text-align: center;
    margin-bottom: 2px;
    text-shadow: 1px 1px 0 #4a2050;
}

.burst-bar {
    height: 8px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 4px;
    overflow: hidden;
}

#burstFill {
    height: 100%;
    background: linear-gradient(90deg, #ffea50 0%, #ff8050 50%, #e85091 100%);
    width: 0%;
    transition: width 0.3s;
    box-shadow: 0 0 8px rgba(255, 200, 100, 0.8);
}

#burstFill.full {
    animation: burstReady 1s ease-in-out infinite;
}

@keyframes burstReady {
    0%, 100% { box-shadow: 0 0 8px #ff8050; }
    50% { box-shadow: 0 0 16px #ffea50, 0 0 24px #fff; }
}

/* Pause button (mobile-friendly) */
.hud-pause-btn {
    position: fixed;
    top: calc(env(safe-area-inset-top, 0) + 12px);
    right: calc(env(safe-area-inset-right, 0) + 16px);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    border: 2px solid rgba(255,255,255,0.5);
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    pointer-events: auto;
    z-index: 51;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.hud-pause-btn:active {
    background: rgba(232, 80, 145, 0.8);
}

/* Reticle */
#reticle {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: rgba(255, 255, 255, 0.8);
    font-size: 24px;
    font-family: monospace;
    text-shadow: 0 0 4px #000, 1px 1px 0 #000;
    pointer-events: none;
    z-index: 40;
    font-weight: bold;
}

/* Prize Get (key/star) */
#prizeGet {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle, rgba(255,200,230,0.6) 0%, rgba(50,20,80,0.85) 100%);
    z-index: 200;
    pointer-events: none;
    animation: prizeFadeIn 0.6s ease-out;
    padding: 20px;
}

#prizeGet img {
    width: 160px;
    height: 160px;
    filter: drop-shadow(0 0 32px #ffea50) drop-shadow(0 0 64px #fff);
    animation: prizeSpin 1.5s linear infinite, prizeGrow 0.8s ease-out;
}

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

@keyframes prizeGrow {
    from { transform: scale(0); }
    to { transform: scale(1); }
}

@keyframes prizeFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.prizeText {
    font-size: 48px;
    font-weight: bold;
    color: #ffea50;
    text-shadow: 4px 4px 0 #e85091, 0 0 16px #fff;
    letter-spacing: 4px;
    margin-top: 24px;
    text-align: center;
}

.prizeSub {
    font-size: 18px;
    color: #fff;
    margin-top: 12px;
    text-shadow: 2px 2px 0 #4a2050;
    text-align: center;
    line-height: 1.6;
    max-width: 90vw;
}

/* Fade overlay */
#fadeOverlay {
    position: fixed;
    inset: 0;
    background: radial-gradient(circle, #ffd1e8, #4a2050);
    z-index: 90;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.6s;
}

#fadeOverlay.fade-in { opacity: 1; }

/* Tooltip */
#tooltip {
    position: fixed;
    bottom: calc(env(safe-area-inset-bottom, 0) + 80px);
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(180deg, rgba(255, 240, 250, 0.95), rgba(255, 200, 230, 0.95));
    color: #4a2050;
    padding: 14px 28px;
    border-radius: 12px;
    border: 3px solid #e85091;
    font-size: 16px;
    z-index: 60;
    pointer-events: none;
    box-shadow: 0 6px 16px rgba(0,0,0,0.3);
    animation: pulseBob 1.5s ease-in-out infinite;
    max-width: 88%;
    text-align: center;
    line-height: 1.4;
}

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

/* Boss bar */
#bossBar {
    position: fixed;
    bottom: calc(env(safe-area-inset-bottom, 0) + 28px);
    left: 50%;
    transform: translateX(-50%);
    width: 60%;
    max-width: 700px;
    min-width: 280px;
    background: rgba(0, 0, 0, 0.7);
    padding: 10px 16px;
    border-radius: 12px;
    border: 3px solid #ffea50;
    z-index: 55;
    color: #fff;
    box-shadow: 0 0 32px rgba(255, 100, 200, 0.5);
}

.boss-name {
    font-size: 20px;
    font-weight: bold;
    text-align: center;
    color: #ffea50;
    text-shadow: 2px 2px 0 #4a2050;
    letter-spacing: 2px;
}

.boss-phase {
    font-size: 12px;
    text-align: center;
    color: #ffd0e0;
    margin-bottom: 4px;
}

.boss-bar {
    height: 18px;
    background: rgba(40, 0, 30, 0.7);
    border-radius: 10px;
    overflow: hidden;
    border: 2px solid #fff;
}

#bossFill {
    height: 100%;
    background: linear-gradient(90deg, #c00060 0%, #e85091 50%, #ff8050 100%);
    width: 100%;
    transition: width 0.4s;
    box-shadow: inset 0 0 8px rgba(0,0,0,0.5);
}

/* ============ MOBILE TOUCH CONTROLS ============ */
#mobileControls {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 60;
}

/* Joystick container — bottom-left, captures touches in a wider area */
#joystickArea {
    position: fixed;
    bottom: env(safe-area-inset-bottom, 0);
    left: env(safe-area-inset-left, 0);
    width: 200px;
    height: 200px;
    pointer-events: auto;
    touch-action: none;
}

#joystickBase {
    position: absolute;
    bottom: 24px;
    left: 24px;
    width: 130px;
    height: 130px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.25);
    border: 3px solid rgba(255, 255, 255, 0.55);
    backdrop-filter: blur(4px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    transition: opacity 0.2s;
}

#joystickKnob {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(180deg, #ff89bb, #e85091);
    border: 3px solid #fff;
    box-shadow: 0 4px 8px rgba(0,0,0,0.4);
    pointer-events: none;
    transition: top 0.05s, left 0.05s;
}

/* Action buttons — bottom-right */
#actionButtons {
    position: fixed;
    bottom: calc(env(safe-area-inset-bottom, 0) + 16px);
    right: calc(env(safe-area-inset-right, 0) + 16px);
    display: grid;
    grid-template-columns: repeat(2, auto);
    grid-template-rows: repeat(2, auto);
    gap: 10px;
    pointer-events: auto;
    touch-action: none;
}

.mob-btn {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(180deg, rgba(255, 137, 187, 0.85), rgba(232, 80, 145, 0.85));
    color: #fff;
    border: 3px solid rgba(255,255,255,0.8);
    font-size: 32px;
    font-weight: bold;
    box-shadow: 0 6px 0 rgba(176, 48, 112, 0.7), 0 8px 16px rgba(0,0,0,0.3);
    text-shadow: 2px 2px 0 #b03070;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    transition: transform 0.05s;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mob-btn span {
    line-height: 1;
    pointer-events: none;
}

.mob-btn.primary {
    width: 96px;
    height: 96px;
    background: linear-gradient(180deg, #ffe060, #ff8030);
    box-shadow: 0 6px 0 #b06010, 0 8px 16px rgba(0,0,0,0.4);
    text-shadow: 2px 2px 0 #b06010;
}

.mob-btn.small {
    width: 60px;
    height: 60px;
    font-size: 24px;
    background: linear-gradient(180deg, rgba(192, 80, 255, 0.85), rgba(128, 48, 192, 0.85));
    box-shadow: 0 4px 0 rgba(80, 30, 130, 0.7), 0 6px 12px rgba(0,0,0,0.3);
    text-shadow: 2px 2px 0 #4030a0;
}

.mob-btn.pressed,
.mob-btn:active {
    transform: translateY(4px);
    box-shadow: 0 2px 0 rgba(176, 48, 112, 0.7);
}
.mob-btn.primary.pressed,
.mob-btn.primary:active {
    box-shadow: 0 2px 0 #b06010;
}
.mob-btn.small.pressed,
.mob-btn.small:active {
    box-shadow: 0 2px 0 rgba(80, 30, 130, 0.7);
}

.mob-btn.disabled {
    opacity: 0.4;
    filter: grayscale(0.5);
}

/* Show mobile controls only when body has .mobile class */
body.mobile #mobileControls.shown {
    display: block;
}

body.mobile #titleControlsDesktop {
    display: none !important;
}
body.mobile #titleControlsMobile {
    display: block !important;
}
body.mobile #reticle {
    display: none !important;
}

/* Compact HUD on small screens */
@media (max-width: 720px) {
    #hud {
        padding: 8px 12px;
        font-size: 14px;
    }
    .hud-item {
        padding: 4px 10px;
        font-size: 16px;
    }
    .hud-item img {
        width: 22px;
        height: 22px;
    }
    .hud-scene {
        font-size: 14px;
        padding: 4px 14px;
        max-width: 50vw;
    }
    .char-active {
        font-size: 11px;
        padding: 3px 10px;
    }
    .hud-health {
        font-size: 22px;
        padding: 3px 8px;
    }
    .hud-ammo {
        font-size: 14px;
        padding: 4px 10px;
    }
    .ammo-label {
        font-size: 18px;
    }
    .sweet-burst-meter {
        min-width: 100px;
        padding: 3px 6px 4px;
    }
    .burst-label {
        font-size: 9px;
    }
    .burst-bar {
        height: 6px;
    }

    .big-btn {
        padding: 14px 32px;
        font-size: 18px;
    }
    #pauseScreen h2 {
        font-size: 48px;
    }
    .title-subtitle {
        font-size: 18px;
        letter-spacing: 2px;
    }
    .char-card {
        padding: 12px 16px;
        min-width: 110px;
    }
    .char-icon {
        font-size: 48px;
    }
    .char-name {
        font-size: 18px;
    }
    .character-preview {
        gap: 12px;
    }
    .controls-grid {
        font-size: 12px;
    }
}

/* Smaller joystick on very small phones */
@media (max-width: 380px) {
    #joystickBase {
        width: 110px;
        height: 110px;
    }
    #joystickKnob {
        width: 50px;
        height: 50px;
    }
    .mob-btn {
        width: 64px;
        height: 64px;
        font-size: 26px;
    }
    .mob-btn.primary {
        width: 80px;
        height: 80px;
    }
    .mob-btn.small {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }
}

/* Landscape orientation tweaks */
@media (orientation: landscape) and (max-height: 500px) {
    .character-preview {
        margin: 8px 0;
    }
    .title-controls {
        margin-top: 12px;
        padding: 10px 16px;
    }
    .title-controls h3 {
        font-size: 14px;
        margin-bottom: 6px;
    }
    .title-credit {
        margin-top: 8px;
        font-size: 10px;
    }
    #titleLogo {
        max-width: 320px;
    }
    .title-subtitle {
        font-size: 14px;
        margin-bottom: 8px;
    }
}

/* ============ CHAPTER CARD (storybook intro) ============ */
#chapterCard {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 180;
    pointer-events: none;
    background: radial-gradient(circle at center, rgba(80, 30, 100, 0.45) 0%, rgba(30, 10, 50, 0.75) 100%);
    animation: chapterFadeIn 0.7s ease-out;
    padding: 30px 20px;
}

#chapterCard.fading-out {
    animation: chapterFadeOut 0.8s ease-in forwards;
}

@keyframes chapterFadeIn {
    from { opacity: 0; transform: scale(1.15); }
    to   { opacity: 1; transform: scale(1); }
}

@keyframes chapterFadeOut {
    from { opacity: 1; transform: scale(1); }
    to   { opacity: 0; transform: scale(0.92); }
}

.chapter-frame {
    background: linear-gradient(160deg, #fff5e6 0%, #ffe5cc 50%, #ffd0a0 100%);
    border: 6px double #b03070;
    border-radius: 12px;
    padding: 36px 56px;
    text-align: center;
    color: #4a2050;
    box-shadow: 0 12px 28px rgba(0,0,0,0.45),
                0 0 60px rgba(255, 200, 240, 0.6),
                inset 0 0 30px rgba(232, 80, 145, 0.15);
    max-width: 90vw;
    font-family: 'Georgia', 'Times New Roman', serif;
    position: relative;
}

.chapter-frame::before,
.chapter-frame::after {
    content: '';
    position: absolute;
    width: 30px;
    height: 30px;
    border: 3px solid #b03070;
}
.chapter-frame::before { top: 8px; left: 8px; border-right: none; border-bottom: none; }
.chapter-frame::after  { bottom: 8px; right: 8px; border-left: none; border-top: none; }

.chapter-deco-top, .chapter-deco-bottom {
    color: #c050ff;
    font-size: 14px;
    letter-spacing: 12px;
    opacity: 0.7;
    margin: 4px 0 10px;
}
.chapter-deco-bottom { margin: 14px 0 0; }

.chapter-num {
    font-size: 16px;
    color: #b03070;
    letter-spacing: 6px;
    margin-bottom: 8px;
    font-weight: bold;
    text-transform: uppercase;
}

.chapter-title {
    font-size: 38px;
    color: #4a2050;
    font-weight: bold;
    margin-bottom: 14px;
    text-shadow: 2px 2px 0 rgba(255, 200, 230, 0.6);
    line-height: 1.2;
}

.chapter-quote {
    font-size: 18px;
    color: #6a3070;
    font-style: italic;
    line-height: 1.4;
    max-width: 480px;
    margin: 0 auto;
    opacity: 0.9;
}

@media (max-width: 720px) {
    .chapter-frame { padding: 24px 28px; }
    .chapter-title { font-size: 26px; }
    .chapter-quote { font-size: 14px; }
    .chapter-num { font-size: 13px; letter-spacing: 4px; }
    .chapter-deco-top, .chapter-deco-bottom { letter-spacing: 8px; font-size: 12px; }
}

/* ============ OBJECTIVE TRACKER ============ */
.hud-objective {
    background: linear-gradient(180deg, #ffea50, #ffb830);
    color: #4a2050;
    padding: 5px 16px;
    border-radius: 14px;
    border: 2px solid #fff;
    font-size: 14px;
    font-weight: bold;
    text-shadow: 1px 1px 0 rgba(255,255,255,0.5);
    max-width: 80vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    box-shadow: 0 0 14px rgba(255, 200, 80, 0.7), 0 4px 8px rgba(0,0,0,0.3);
    animation: objectivePulse 2s ease-in-out infinite;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}

.objective-arrow {
    color: #b03070;
    font-size: 12px;
    animation: arrowBlink 1s ease-in-out infinite;
}

@keyframes arrowBlink {
    0%, 100% { opacity: 1; transform: translateX(0); }
    50% { opacity: 0.5; transform: translateX(3px); }
}

@keyframes objectivePulse {
    0%, 100% { box-shadow: 0 0 14px rgba(255, 200, 80, 0.7), 0 4px 8px rgba(0,0,0,0.3); }
    50%      { box-shadow: 0 0 28px rgba(255, 234, 80, 1), 0 4px 8px rgba(0,0,0,0.3); }
}

@media (max-width: 720px) {
    .hud-objective {
        font-size: 11px;
        padding: 3px 10px;
        max-width: 60vw;
    }
}

/* ============ HELP BUTTON + TUTORIAL OVERLAY ============ */
.hud-help-btn {
    position: fixed;
    top: calc(env(safe-area-inset-top, 0) + 12px);
    right: calc(env(safe-area-inset-right, 0) + 70px);   /* left of pause button */
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(80, 50, 130, 0.65);
    color: #fff;
    border: 2px solid rgba(255,255,255,0.5);
    font-size: 22px;
    font-weight: bold;
    cursor: pointer;
    pointer-events: auto;
    z-index: 51;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    display: none;        /* hidden by default; shown when HUD is visible */
}
.hud-help-btn:active {
    background: rgba(192, 80, 255, 0.9);
}
#hud:not(.hidden) ~ .hud-help-btn {
    display: block;
}

#tutorialOverlay {
    z-index: 220;
    background: linear-gradient(135deg, rgba(80, 30, 100, 0.92), rgba(40, 10, 60, 0.92));
    backdrop-filter: blur(8px);
}

.tutorial-card {
    background: linear-gradient(160deg, #fff5e6 0%, #ffe5cc 50%, #ffd5b0 100%);
    border: 6px double #b03070;
    border-radius: 16px;
    padding: 32px 40px;
    max-width: 560px;
    width: 90%;
    box-shadow: 0 12px 30px rgba(0,0,0,0.5),
                0 0 60px rgba(255, 200, 240, 0.4),
                inset 0 0 30px rgba(232, 80, 145, 0.12);
    color: #4a2050;
    font-family: 'Georgia', 'Times New Roman', serif;
}

.tutorial-card h2 {
    font-size: 32px;
    color: #b03070;
    text-align: center;
    margin-bottom: 18px;
    text-shadow: 2px 2px 0 rgba(255, 200, 230, 0.6);
    letter-spacing: 2px;
}

.tutorial-steps {
    list-style: none;
    padding: 0;
    margin: 16px 0;
}
.tutorial-steps li {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 12px;
    padding: 10px 14px;
    background: rgba(255,255,255,0.55);
    border-radius: 10px;
    font-size: 15px;
    line-height: 1.5;
    color: #4a2050;
    border-left: 4px solid #b03070;
}
.tutorial-steps li b {
    color: #b03070;
}
.step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: linear-gradient(180deg, #ff89bb, #e85091);
    color: #fff;
    font-weight: bold;
    font-size: 16px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    text-shadow: 1px 1px 0 #b03070;
    font-family: monospace;
}

.tutorial-tip {
    background: rgba(255, 234, 80, 0.65);
    border: 2px solid #ffb830;
    border-radius: 10px;
    padding: 12px 16px;
    margin: 16px 0;
    font-size: 14px;
    color: #4a2050;
    line-height: 1.5;
}

#tutorialDismiss {
    margin: 16px auto 0;
    display: block;
}

@media (max-width: 720px) {
    .tutorial-card { padding: 22px 18px; }
    .tutorial-card h2 { font-size: 22px; }
    .tutorial-steps li { font-size: 13px; padding: 8px 10px; gap: 10px; }
    .step-num { width: 26px; height: 26px; font-size: 13px; }
    .tutorial-tip { font-size: 12px; padding: 10px; }
}
