/* ========== RESET & BASE ========== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

/* ========== FORCE LANDSCAPE ON MOBILE ========== */
#rotate-prompt {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: #1a1a2e;
    color: #FFD700;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 24px;
    font-family: 'GameFont', Arial, sans-serif;
}
.rotate-icon {
    font-size: 72px;
    animation: rotateHint 2s ease-in-out infinite;
}
.rotate-text {
    font-size: 22px;
    text-align: center;
    line-height: 1.6;
    color: #fff;
}
@keyframes rotateHint {
    0%, 100% { transform: rotate(0deg); }
    50% { transform: rotate(90deg); }
}
@media (max-width: 900px) and (orientation: portrait) {
    #rotate-prompt { display: flex; }
    #game-container { display: none; }
}

@font-face {
    font-family: 'GameFont';
    src: local('Arial'), local('Segoe UI');
}

:root {
    --sky-day: #87CEEB;
    --sky-night: #2C3E6B;
    --sand: #F5DEB3;
    --nile: #5BA3B5;
    --egypt-brown: #D4A574;
    --vegetation: #7DB87D;
    --gold: #DAA520;
    --ui-primary: #E8843C;
    --ui-success: #6BBF6B;
    --ui-bg: #FFF8E7;
    --text-primary: #4A3728;
    --ui-danger: #E85D5D;
    --ui-info: #5B9BD5;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
}

html, body {
    width: 100%; height: 100%;
    overflow: hidden;
    background: #2a1f14;
    font-family: 'Segoe UI', Arial, sans-serif;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-text-size-adjust: 100%;
}

[dir="rtl"], [dir="rtl"] * {
    font-family: 'Segoe UI', 'Arial', 'Helvetica Neue', sans-serif !important;
}

/* ========== GAME CONTAINER ========== */
#game-container {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: #2a1f14;
}

#game-canvas {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    image-rendering: auto;
}

#ui-layer {
    position: absolute;
    top: 0; left: 0;
    transform-origin: top left;
    /* width, height, transform set by Renderer.resize() */
    pointer-events: none;
}

#ui-layer > * {
    pointer-events: auto;
}

/* Sprite images within scene elements */
.sprite-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
    image-rendering: auto;
}

.scene-item .sprite-img {
    pointer-events: none;
}

/* ========== BUTTONS ========== */
.game-btn {
    border: none;
    border-radius: 20px;
    padding: 16px 36px;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    font-family: inherit;
    direction: inherit;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

.game-btn:hover, .game-btn:focus {
    transform: scale(1.06);
}

.game-btn:active {
    transform: scale(0.96);
}

.btn-primary {
    background: var(--ui-primary);
    color: white;
    box-shadow: 0 4px 0 #c0672a, 0 6px 12px rgba(0,0,0,0.2);
    min-width: 200px;
    text-align: center;
}

.btn-primary:active {
    box-shadow: 0 2px 0 #c0672a, 0 3px 6px rgba(0,0,0,0.2);
}

.btn-success {
    background: var(--ui-success);
    color: white;
    box-shadow: 0 4px 0 #4a9a4a, 0 6px 12px rgba(0,0,0,0.2);
}

.btn-small {
    padding: 10px 20px;
    font-size: 18px;
    border-radius: 14px;
}

.btn-round {
    width: 56px; height: 56px;
    border-radius: 50%;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

/* ========== HOME SCREEN ========== */
.home-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%; height: 100%;
    position: relative;
}

/* Dark overlay on the canvas background for text contrast */
.home-overlay {
    display: none;
}

.home-content {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: space-between;
    height: 100%;
    padding-top: 0;
    padding-bottom: 30px;
    padding-left: 0;
    padding-right: 10%;
    box-sizing: border-box;
}

.home-top {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-top: -20px;
    width: 100%;
}

.home-bottom {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    width: 100%;
}

.game-title-img {
    max-width: 650px;
    width: 95%;
    height: auto;
    filter: drop-shadow(0 0 12px rgba(0,0,0,0.6));
    animation: titlePulse 4s ease-in-out infinite;
}

.title-sparkle-wrap {
    position: relative;
    display: inline-block;
    overflow: visible;
}

.title-sparkle {
    position: absolute;
    width: 8px;
    height: 8px;
    background: radial-gradient(circle, #fff 0%, #FFD700 40%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
    animation: sparkleAnim 1.2s ease-out forwards;
    z-index: 10;
}

@keyframes sparkleAnim {
    0% { transform: scale(0) rotate(0deg); opacity: 1; }
    50% { transform: scale(1.5) rotate(180deg); opacity: 1; }
    100% { transform: scale(0) rotate(360deg); opacity: 0; }
}

.game-title {
    font-size: 54px;
    font-weight: 800;
    color: #FFD700;
    text-shadow:
        0 0 8px rgba(0,0,0,0.9),
        2px 2px 0 #3a2000,
        -2px -2px 0 #3a2000,
        2px -2px 0 #3a2000,
        -2px 2px 0 #3a2000,
        0 0 30px rgba(218,165,32,0.5),
        0 0 60px rgba(218,165,32,0.2);
    text-align: center;
    line-height: 1.25;
    letter-spacing: 1px;
    animation: titlePulse 4s ease-in-out infinite;
}

[dir="rtl"] .game-title { text-align: right; font-family: inherit !important; }
[dir="ltr"] .game-title { text-align: left; }

[dir="rtl"] .game-subtitle { text-align: right; font-family: 'Segoe UI', 'Arial', 'Helvetica', sans-serif; }
[dir="ltr"] .game-subtitle { text-align: left; }
.game-subtitle {
    font-size: 24px;
    font-weight: 600;
    color: #fff;
    text-shadow:
        0 0 6px rgba(0,0,0,0.9),
        1px 1px 0 #2a1500,
        -1px -1px 0 #2a1500,
        1px -1px 0 #2a1500,
        -1px 1px 0 #2a1500,
        0 0 20px rgba(0,0,0,0.5);
    text-align: center;
    animation: subtitleFade 1.5s ease-out 0.5s both;
}

@keyframes subtitleFade {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes titleFadeIn {
    from { opacity: 0; transform: translateY(-12px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes titlePulse {
    0%, 100% { text-shadow: 2px 2px 0 var(--text-primary), 0 0 20px rgba(218,165,32,0.3); }
    50% { text-shadow: 2px 2px 0 var(--text-primary), 0 0 35px rgba(218,165,32,0.5), 0 0 60px rgba(218,165,32,0.2); }
}

.btn-glow {
    animation: btnGlow 2s ease-in-out infinite;
    transition: transform 0.15s ease;
}
.btn-glow:hover {
    transform: scale(1.05);
}
.btn-glow:active {
    transform: scale(0.95);
}

@keyframes btnGlow {
    0%, 100% { box-shadow: 0 4px 0 #c0672a, 0 6px 12px rgba(0,0,0,0.2), 0 0 15px rgba(232,132,60,0.2); }
    50% { box-shadow: 0 4px 0 #c0672a, 0 6px 12px rgba(0,0,0,0.2), 0 0 35px rgba(232,132,60,0.6), 0 0 60px rgba(218,165,32,0.2); }
}

.lang-selector {
    display: flex;
    gap: 12px;
}

.lang-btn {
    padding: 8px 20px;
    border-radius: 12px;
    border: 2px solid rgba(255,255,255,0.5);
    background: rgba(0,0,0,0.4);
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    min-width: 120px;
    text-align: center;
    backdrop-filter: blur(4px);
}

.lang-btn.selected {
    background: rgba(218,165,32,0.35);
    border-color: var(--gold);
    color: var(--gold);
    font-weight: bold;
}

.lang-btn:hover {
    background: rgba(255,255,255,0.25);
}


.home-buttons {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

/* ========== PROGRESS BAR ========== */
.progress-bar {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 12px;
    padding: 8px 16px;
    background: rgba(0,0,0,0.25);
    border-radius: 20px;
    backdrop-filter: blur(4px);
    z-index: 100;
}

.progress-dot {
    width: 24px; height: 24px;
    border-radius: 50%;
    background: rgba(255,255,255,0.25);
    border: 2px solid rgba(255,255,255,0.4);
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

.progress-dot.completed {
    background: var(--ui-success);
    border-color: #4a9a4a;
    animation: dotComplete 0.5s ease-out;
}

.progress-dot.current {
    background: var(--ui-primary);
    border-color: #c0672a;
    transform: scale(1.2);
    box-shadow: 0 0 8px rgba(232,132,60,0.5);
    animation: dotPulse 2s ease-in-out infinite;
}

@keyframes dotComplete {
    0% { transform: scale(1); }
    50% { transform: scale(1.4); }
    100% { transform: scale(1); }
}

@keyframes dotPulse {
    0%, 100% { box-shadow: 0 0 8px rgba(232,132,60,0.5); transform: scale(1.2); }
    50% { box-shadow: 0 0 16px rgba(232,132,60,0.8); transform: scale(1.3); }
}

/* ========== HUD BUTTONS ========== */
.hud-buttons {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    gap: 8px;
    z-index: 100;
}

.hud-left {
    position: absolute;
    top: 12px;
    left: 12px;
    display: flex;
    gap: 8px;
    z-index: 100;
}

/* ========== NARRATIVE PANEL ========== */
.narrative-panel {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255,248,231,0.95);
    border-radius: 20px;
    padding: 20px 30px;
    max-width: 600px;
    width: 85%;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    z-index: 50;
    animation: slideUp 0.4s ease-out;
}

.narrative-title {
    font-size: 18px;
    font-weight: bold;
    color: var(--gold);
    margin-bottom: 6px;
    letter-spacing: 0.5px;
    text-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.narrative-text {
    font-size: 22px;
    color: var(--text-primary);
    line-height: 1.6;
    margin-bottom: 12px;
}

@keyframes slideUp {
    from { transform: translateX(-50%) translateY(40px); opacity: 0; filter: blur(2px); }
    to { transform: translateX(-50%) translateY(0); opacity: 1; filter: blur(0); }
}

/* ========== SCENE ELEMENTS ========== */
.scene-item {
    position: absolute;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.scene-item.found {
    animation: itemFound 0.7s ease-out forwards;
}

@keyframes itemFound {
    0% { transform: scale(1); opacity: 1; }
    25% { transform: scale(1.4) rotate(5deg); opacity: 1; }
    50% { transform: scale(1.2) rotate(-3deg); opacity: 0.8; }
    100% { transform: scale(0) rotate(15deg); opacity: 0; }
}

.draggable {
    cursor: grab;
    touch-action: none;
}

.draggable:active, .draggable.dragging {
    cursor: grabbing;
    z-index: 1000;
}

/* ========== DIALOG CARDS ========== */
.dialog-choices {
    display: flex;
    gap: 20px;
    justify-content: center;
    flex-wrap: wrap;
}

.dialog-card {
    background: white;
    border: 3px solid var(--gold);
    border-radius: 16px;
    padding: 20px;
    width: 200px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.dialog-card:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 16px rgba(218,165,32,0.4);
}

.dialog-card .card-icon {
    font-size: 48px;
    margin-bottom: 8px;
}

.dialog-card .card-text {
    font-size: 18px;
    color: var(--text-primary);
}

/* ========== INVENTORY / COLLECTION BAR ========== */
.inventory-bar {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 12px;
    padding: 10px 16px;
    background: rgba(0,0,0,0.2);
    border-radius: 16px;
    backdrop-filter: blur(4px);
    z-index: 50;
}

.inventory-slot {
    width: 56px; height: 56px;
    border-radius: 12px;
    border: 2px dashed rgba(255,255,255,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    background: rgba(255,255,255,0.1);
    transition: all 0.3s;
}

.inventory-slot.filled {
    border-style: solid;
    border-color: var(--ui-success);
    background: rgba(107,191,107,0.2);
    animation: slotFill 0.4s ease-out;
}

@keyframes slotFill {
    0% { transform: scale(0.5); }
    60% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* ========== SORT/ORDER SLOTS ========== */
.order-slots {
    display: flex;
    gap: 16px;
    justify-content: center;
    padding: 16px;
}

.order-slot {
    width: 80px; height: 100px;
    border: 3px dashed rgba(255,255,255,0.7);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.35);
    transition: all 0.2s;
}

.order-slot.highlight {
    border-color: var(--ui-primary);
    background: rgba(232,132,60,0.2);
}

.order-slot.filled {
    border-style: solid;
    border-color: var(--ui-success);
}

/* ========== STICKER ALBUM ========== */
.sticker-album {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    padding: 20px;
    max-width: 500px;
    margin: 0 auto;
}

.sticker-holder {
    aspect-ratio: 1;
    border-radius: 16px;
    border: 3px dashed rgba(218,165,32,0.4);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: rgba(255,248,231,0.3);
    transition: all 0.3s;
}

.sticker-holder.earned {
    border-style: solid;
    border-color: var(--gold);
    background: rgba(218,165,32,0.15);
}

.sticker-icon {
    font-size: 40px;
}

.sticker-label {
    font-size: 14px;
    color: var(--sand);
}

/* ========== SUCCESS OVERLAY ========== */
.success-overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.4);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    z-index: 200;
    animation: fadeIn 0.3s;
}

.success-message {
    background: var(--ui-bg);
    border-radius: 24px;
    padding: 30px 40px;
    text-align: center;
    max-width: 500px;
    animation: popIn 0.4s ease-out;
}

.success-message h2 {
    font-size: 32px;
    color: var(--ui-success);
    margin-bottom: 12px;
}

.success-message p {
    font-size: 20px;
    color: var(--text-primary);
    line-height: 1.5;
    margin-bottom: 8px;
}

.sticker-earned {
    font-size: 64px;
    animation: stickerBounce 0.8s ease-out;
    display: flex;
    align-items: center;
    justify-content: center;
}

@keyframes popIn {
    0% { transform: scale(0.5) translateY(20px); opacity: 0; }
    60% { transform: scale(1.08) translateY(-5px); }
    80% { transform: scale(0.97) translateY(2px); }
    100% { transform: scale(1) translateY(0); opacity: 1; }
}

@keyframes stickerBounce {
    0% { transform: scale(0) rotate(-20deg); }
    40% { transform: scale(1.4) rotate(10deg); }
    60% { transform: scale(0.9) rotate(-3deg); }
    80% { transform: scale(1.1) rotate(2deg); }
    100% { transform: scale(1) rotate(0); }
}

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

@keyframes flashPulse {
    0% { opacity: 1; }
    100% { opacity: 0; }
}

@keyframes gentlePulse {
    0%, 100% { box-shadow: 0 0 10px rgba(218,165,32,0.3); }
    50% { box-shadow: 0 0 25px rgba(218,165,32,0.6), 0 0 50px rgba(218,165,32,0.2); }
}

/* ========== SCENE ITEMS — floating idle ========== */
.scene-item {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.scene-item:not(.dragging) {
    animation: itemFloat 3s ease-in-out infinite;
}
.scene-item:hover, .scene-item:active {
    transform: scale(1.1);
    box-shadow: 0 0 20px rgba(218,165,32,0.5), 0 6px 16px rgba(0,0,0,0.25) !important;
    z-index: 100;
}
.scene-item.dragging {
    animation: none;
    transform: scale(1.12) rotate(2deg);
    box-shadow: 0 0 25px rgba(218,165,32,0.6), 0 10px 30px rgba(0,0,0,0.3) !important;
}

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

/* Staggered float for variety */
.scene-item:nth-child(odd) { animation-delay: -1.5s; }
.scene-item:nth-child(3n) { animation-duration: 3.5s; }
.scene-item:nth-child(4n) { animation-duration: 2.5s; }

/* Reed sway animation — side-to-side with transform-origin at bottom */
.reed-group {
    transform-origin: bottom center;
    animation: reedSway 3s ease-in-out infinite !important;
}
.reed-group:nth-child(odd) { animation-delay: -1s !important; animation-duration: 3.5s !important; }
.reed-group:nth-child(3n) { animation-delay: -2s !important; animation-duration: 2.8s !important; }

@keyframes reedSway {
    0%, 100% { transform: rotate(-2deg); }
    50% { transform: rotate(2deg); }
}

@keyframes smokeRise {
    0% { opacity: 0.3; transform: translateX(-50%) translateY(0); }
    50% { opacity: 0.15; transform: translateX(-40%) translateY(-12px); }
    100% { opacity: 0; transform: translateX(-60%) translateY(-25px); }
}

@keyframes flicker {
    0% { opacity: 0.8; transform: translateX(-50%) scaleY(1); }
    50% { opacity: 1; transform: translateX(-50%) scaleY(1.1); }
    100% { opacity: 0.7; transform: translateX(-50%) scaleY(0.9); }
}

@keyframes idleGhostFade {
    0%   { opacity: 0; transform: scale(0.8); }
    15%  { opacity: 0.7; transform: scale(1.05); }
    25%  { opacity: 0.6; transform: scale(1); }
    50%  { opacity: 0.75; transform: scale(1.05); }
    75%  { opacity: 0.6; transform: scale(1); }
    85%  { opacity: 0.7; transform: scale(1.05); }
    100% { opacity: 0; transform: scale(0.8); }
}

/* ========== CONFETTI ========== */
.confetti-piece {
    position: absolute;
    border-radius: 2px;
    animation: confettiFall linear forwards;
    z-index: 300;
}
.confetti-piece:nth-child(odd) {
    border-radius: 50%;
    animation-name: confettiSpin;
}

@keyframes confettiFall {
    0% { transform: translateY(-20px) rotate(0deg) scale(1); opacity: 1; }
    75% { opacity: 1; }
    100% { transform: translateY(700px) rotate(1080deg) scale(0.5); opacity: 0; }
}

@keyframes confettiSpin {
    0% { transform: translateY(-20px) rotateX(0) rotateZ(0) scale(1); opacity: 1; }
    75% { opacity: 0.8; }
    100% { transform: translateY(700px) rotateX(720deg) rotateZ(360deg) scale(0.3); opacity: 0; }
}

/* ========== JUMP GAME ========== */
.jump-character {
    position: absolute;
    transition: left 0.5s ease-in-out;
    z-index: 50;
}

/* ========== INSTRUMENT BUTTONS ========== */
.instrument-grid {
    display: flex;
    gap: 20px;
    justify-content: center;
    flex-wrap: wrap;
}

.instrument-btn {
    width: 90px; height: 95px;
    border-radius: 18px;
    border: 3px solid var(--gold);
    background: rgba(255,248,231,0.92);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: inherit;
    animation: gentlePulse 3s ease-in-out infinite;
    box-shadow: 0 3px 12px rgba(0,0,0,0.2);
}

.instrument-btn:hover {
    transform: scale(1.08);
    border-color: #FFD700;
    background: rgba(255,248,231,1);
}

.instrument-btn:active {
    transform: scale(0.88);
    background: var(--gold);
    animation: instrumentHit 0.3s ease-out;
}

.instrument-btn.highlight {
    animation: instrumentFlash 0.5s ease-out;
    border-color: #FFD700;
    box-shadow: 0 0 30px rgba(255,215,0,0.6);
}

@keyframes instrumentHit {
    0% { transform: scale(0.88); }
    50% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

@keyframes instrumentFlash {
    0% { box-shadow: 0 0 0 rgba(255,215,0,0); }
    50% { box-shadow: 0 0 40px rgba(255,215,0,0.8); }
    100% { box-shadow: 0 0 10px rgba(255,215,0,0.3); }
}

/* ========== SEA WALL EFFECTS ========== */
@keyframes seaBubbleFloat {
    0%, 100% { transform: translateY(0); opacity: 0.5; }
    50% { transform: translateY(-18px); opacity: 1; }
}

@keyframes seaCausticsShift {
    0% { background-position: 0 0; }
    100% { background-position: 40px 40px; }
}

@keyframes tapPulse {
    0%, 100% { transform: translateX(-50%) scale(1); opacity: 0.9; }
    50% { transform: translateX(-50%) scale(1.15); opacity: 1; }
}

@keyframes angelWiggle {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    25% { transform: translateY(-4px) rotate(2deg); }
    50% { transform: translateY(-7px) rotate(0deg); }
    75% { transform: translateY(-4px) rotate(-2deg); }
}

.instrument-btn .inst-icon {
    font-size: 44px;
}

.instrument-btn .inst-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.instrument-btn.playing {
    background: var(--gold);
    transform: scale(1.08);
}

/* ========== PATTERN DISPLAY ========== */
.pattern-display {
    display: flex;
    gap: 10px;
    justify-content: center;
    padding: 10px 18px;
    background: rgba(0,0,0,0.55);
    border-radius: 14px;
    border: 2px solid rgba(255,215,0,0.35);
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
    backdrop-filter: blur(4px);
}

.pattern-note {
    width: 42px; height: 42px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    background: rgba(255,255,255,0.18);
    border: 2px solid rgba(255,255,255,0.15);
    transition: all 0.2s;
}

.pattern-note.active {
    background: var(--gold);
    transform: scale(1.15);
    box-shadow: 0 0 18px rgba(255,215,0,0.6);
}

.pattern-note.matched {
    background: var(--ui-success);
    box-shadow: 0 0 12px rgba(76,175,80,0.5);
}

/* ========== BAG (Level 5) ========== */
.bag-area {
    position: absolute;
    border: 3px dashed rgba(255,255,255,0.5);
    border-radius: 20px;
    background: rgba(139,90,43,0.3);
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
    gap: 8px;
    padding: 12px;
}

.bag-area.highlight {
    border-color: var(--ui-success);
    background: rgba(107,191,107,0.15);
}

/* ========== WATER DRAG (Level 8) ========== */
.water-wall {
    position: absolute;
    top: 0;
    height: 100%;
    background: linear-gradient(to bottom, #3a7bd5, #5BA3B5);
    transition: width 0.3s ease-out;
    z-index: 10;
}

.water-wall.left { left: 0; border-radius: 0 20px 20px 0; }
.water-wall.right { right: 0; border-radius: 20px 0 0 20px; }

.path-center {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
}

/* ========== MODAL ========== */
.modal-overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 300;
    animation: fadeIn 0.2s;
}

.modal-content {
    background: var(--ui-bg);
    border-radius: 24px;
    padding: 30px;
    max-width: 450px;
    width: 85%;
    text-align: center;
}

.modal-content h2 {
    color: var(--text-primary);
    margin-bottom: 16px;
    font-size: 28px;
}

/* ========== CERTIFICATE ========== */
.certificate {
    background: linear-gradient(135deg, #FFF8E7, #F5DEB3);
    border: 4px solid var(--gold);
    border-radius: 20px;
    padding: 40px;
    text-align: center;
    max-width: 500px;
    margin: 0 auto;
}

.certificate h1 {
    color: var(--gold);
    font-size: 32px;
    margin-bottom: 16px;
}

.certificate .cert-name {
    font-size: 28px;
    color: var(--text-primary);
    border-bottom: 2px solid var(--gold);
    padding: 8px 20px;
    display: inline-block;
    margin: 12px 0;
}

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

/* Tablets in portrait */
@media (max-width: 900px) {
    .game-title { font-size: 38px; }
    .game-subtitle { font-size: 18px; }
    .home-content { gap: 14px; }
    .narrative-panel { padding: 16px 20px; width: 90%; }
    .narrative-text { font-size: 20px; }
    .narrative-title { font-size: 16px; }
    .dialog-card { width: 180px; padding: 16px; }
    .instrument-btn { width: 100px; height: 105px; }
}

/* Large phones */
@media (max-width: 600px) {
    .game-title { font-size: 30px; }
    .game-subtitle { font-size: 15px; }
    .narrative-panel { padding: 12px 16px; width: 92%; }
    .narrative-text { font-size: 17px; line-height: 1.5; }
    .narrative-title { font-size: 14px; }
    .game-btn { padding: 10px 20px; font-size: 18px; border-radius: 14px; }
    .btn-small { padding: 8px 14px; font-size: 15px; }
    .btn-round { width: 44px; height: 44px; font-size: 20px; }
    .dialog-card { width: 140px; padding: 12px; }
    .dialog-card .card-icon { font-size: 36px; }
    .dialog-card .card-text { font-size: 15px; }
    .instrument-btn { width: 85px; height: 90px; }
    .instrument-btn .inst-icon { font-size: 36px; }
    .instrument-btn .inst-name { font-size: 13px; }
    .inventory-slot { width: 44px; height: 44px; font-size: 22px; }
    .progress-dot { width: 20px; height: 20px; font-size: 10px; }
    .progress-bar { gap: 8px; padding: 6px 12px; }
    .success-message { padding: 20px 24px; }
    .success-message h2 { font-size: 26px; }
    .success-message p { font-size: 17px; }
    .sticker-earned { font-size: 50px; }
    .certificate { padding: 24px; }
    .certificate h1 { font-size: 26px; }
    .certificate .cert-name { font-size: 22px; }
    .home-screen { gap: 16px; }
    .lang-selector { gap: 8px; }
    .lang-btn { padding: 6px 14px; font-size: 14px; }
    .order-slot { width: 60px; height: 80px; }
    .bag-area { width: 140px !important; height: 180px !important; }
    .pattern-note { width: 34px; height: 34px; font-size: 20px; }
}

/* Small phones */
@media (max-width: 380px) {
    .game-title { font-size: 26px; }
    .game-subtitle { font-size: 13px; }
    .narrative-text { font-size: 15px; }
    .game-btn { padding: 8px 16px; font-size: 16px; }
    .instrument-btn { width: 70px; height: 75px; }
    .dialog-card { width: 120px; padding: 10px; }
    .order-slot { width: 50px; height: 70px; }
}

/* Landscape phones */
@media (max-height: 450px) {
    .narrative-panel { bottom: 5px; padding: 10px 16px; }
    .narrative-text { font-size: 15px; line-height: 1.4; }
    .game-title { font-size: 24px; }
    .game-subtitle { font-size: 13px; }
    .home-screen { gap: 6px; }
    .home-content { gap: 10px; }
    .game-btn { padding: 8px 18px; font-size: 16px; }
    .success-message { padding: 16px 20px; }
    .success-message h2 { font-size: 24px; }
    .sticker-earned { font-size: 40px; }
    .progress-bar { top: 6px; padding: 4px 10px; }
    .hud-buttons { top: 6px; right: 6px; }
}

/* Ensure touch targets are minimum 44x44 */
@media (pointer: coarse) {
    .scene-item { min-width: 44px; min-height: 44px; }
    .game-btn { min-height: 44px; }
    .progress-dot { min-width: 24px; min-height: 24px; }
    .dialog-card { min-height: 80px; }
}

/* ========== COPYRIGHT NOTICE ========== */
#copyright-notice {
    position: absolute;
    bottom: 5px;
    left: 10px;
    color: #000;
    font-size: 10px;
    font-family: Arial, sans-serif;
    z-index: 1000;
    pointer-events: none;
    opacity: 0.7;
}
