body {
    font-family: 'Comic Neue', 'Patrick Hand', cursive;
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    overflow: hidden;
    touch-action: none;
    user-select: none;
    background: linear-gradient(to bottom, #000000 0%, #1a1a40 100%);
	transition: background 10s ease;
}

/* Add this for the overlay transition effect */
.background-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -2;
    opacity: 0;
    transition: opacity 10s ease-in-out;
    pointer-events: none;
}

/* Add this at the top of your CSS */
.cell-face {
    background-repeat: no-repeat;
    background-position: center;
    background-size: cover;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    image-rendering: pixelated;
	transform: translateZ(0);
}

/* Reduce the number of sparkles */
.sparkle, .blue-sparkle, .red-sparkle {
    display: none; /* Initially hidden */
}

/* Only show sparkles when animating */
.sparkle-container .sparkle,
.sparkle-container .blue-sparkle, 
.sparkle-container .red-sparkle {
    display: block;
}

/* Add will-change for elements that animate frequently */
.villager, .boar {
    will-change: transform, opacity;
}

.sunlight-effect {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at center, rgba(255,255,210,0.3) 0%, transparent 70%);
    pointer-events: none;
    opacity: 0;
    transition: opacity 5s ease-in-out;
}

.sunlight-effect.active {
    opacity: 0.7;
}

.cell.sunlit {
    filter: brightness(1.2) sepia(0.5);
    transition: filter 3s ease-in-out;
}

/* Update cloud styles in style.css */
.cloud {
    position: absolute;
    background: white;
    border-radius: 50%;
    opacity: 0;
    z-index: 1;
    animation-timing-function: linear;
    animation-fill-mode: forwards;
}

.cloud.visible {
    opacity: 0.7;
    transform: translateY(0);
}

.cloud::before, .cloud::after {
    content: '';
    position: absolute;
    background: white;
    border-radius: 50%;
    filter: blur(5px);
}

.cloud::before {
    width: 80%;
    height: 80%;
    top: -30%;
    left: 10%;
}

.cloud::after {
    content: '';
    position: absolute;
    background: inherit;
    border-radius: inherit;
}

@keyframes float-cloud {
    0% {
        transform: translateX(-200px);
    }
    100% {
        transform: translateX(calc(100vw + 200px));
    }
}

.highlight-blacksmith {
    border: 2px solid #f44336 !important;
    box-shadow: 0 0 15px #f44336 !important;
}

.highlight-river {
    border: 2px solid #00a8ff !important;
    box-shadow: 0 0 15px #00a8ff !important;
}

.highlight-farmer {
    border: 2px solid #4CAF50 !important;
    box-shadow: 0 0 15px #4CAF50 !important;
}

.stars {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
}

.star {
    position: absolute;
    background-color: white;
    border-radius: 50%;
    animation: twinkle 5s infinite steps(5);
    transition: opacity 10s ease-in-out;
}

@keyframes twinkle {
    0% { opacity: 0.2; }
    20% { opacity: 0.8; }
    40% { opacity: 0.3; }
    60% { opacity: 1; }
    80% { opacity: 0.5; }
    100% { opacity: 0.2; }
}

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

.energy-container, .tool-selection, .villager-counter {
    opacity: 0;
    transition: opacity 0.8s ease-out, transform 0.8s ease-out;
    transform: translateY(20px);
}

.energy-container.show, 
.tool-selection.show, 
.villager-counter.show {
    opacity: 1;
    transform: translateY(0);
}

@keyframes floatBounce {
    0%, 100% {
        transform: translateY(0) rotate(0deg);
    }
    25% {
        transform: translateY(-15px) rotate(5deg);
    }
    50% {
        transform: translateY(0) rotate(0deg);
    }
    75% {
        transform: translateY(-10px) rotate(-3deg);
    }
}

h1 span {
    display: inline-block;
    position: relative;
    animation: floatBounce 9s ease infinite;
    animation-delay: calc(var(--char-index) * 0.1s);
    transform-origin: center bottom;
}

@keyframes letterFloat {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-10px) rotate(5deg); }
}

h1 span:not(:last-child)::after {
    content: "•";
    position: absolute;
    right: -12px;
    color: rgba(255,255,255,0.5);
    animation: sparklePulse 1.5s infinite alternate;
    animation-delay: calc(var(--char-index) * 0.1s);
}

@keyframes sparklePulse {
    0% { opacity: 0.2; transform: scale(0.8); }
    100% { opacity: 0.8; transform: scale(1.2); }
}

h1 {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: #fff;
    margin-bottom: 20px;
    text-align: center;
    text-shadow: 
        0 0 10px rgba(255,255,255,0.3),
        0 0 20px #9c27b0,
        0 0 30px #00a8ff;
    z-index: 10;
    font-size: 3.5rem;
    font-weight: 700;
    font-family: 'Gloria Hallelujah', 'Comic Neue', cursive;
    background: linear-gradient(to right, #ff8a00, #e52e71);
    -webkit-background-clip: text;
    background-clip: text;
    color: #390075;
    padding: 0 30px;
    border-radius: 20px;
    white-space: nowrap;
}

.scene-container {
    position: relative;
    width: 600px;
    height: 600px;
    margin: 0 auto;
    transition: width 0.5s ease, height 0.5s ease;
}

.scene {
    width: 100%;
    height: 100%;
    perspective: 1500px;
}

.grid-3d {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transform: rotateX(50deg) rotateZ(45deg) translateZ(-950px) translateY(-30px) scale(3.6);
    transition: transform 0.1s linear;
}

.cell {
    position: absolute;
    width: 100px;
    height: 100px;
    transform-style: preserve-3d;
    cursor: pointer;
    transition: transform 0.3s ease;
    pointer-events: auto;
}

.cell-face {
    position: absolute;
    backface-visibility: visible;
    box-sizing: border-box;
    border: 2px solid transparent;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.4);
    pointer-events: none;
    width: 100%;
    height: 100%;
}

.cell-front {
    transform: translateZ(50px);
    pointer-events: auto;
    z-index: 2;
    background-size: 100% 100%;
    background-repeat: no-repeat;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    image-rendering: pixelated;
}

.cell-back {
    width: 100%;
    height: 100%;
    transform: rotateY(180deg) translateZ(50px);
    background: rgba(50, 50, 50, 0.7);
    z-index: 1;
}

.cell-right {
    width: 100px;
    height: 100px;
    transform: rotateY(90deg) translateZ(50px) rotateZ(-90deg);
    background-image: url('dirt_side.jpg');
    right: 0;
    display: none;
    z-index: 0;
}

.cell-bottom {
    width: 100px;
    height: 100px;
    transform: rotateX(-90deg) translateZ(50px);
    top: 0;
    background-image: url('dirt_side.jpg');
    display: none;
    z-index: 0;
}

.cell-top {
    width: 100px;
    height: 100px;
    transform: rotateX(90deg) translateZ(50px);
    bottom: 0;
    background: rgba(70, 70, 70, 0.6);
    z-index: 0;
}

.cell-left {
    width: 100px;
    height: 100px;
    transform: rotateY(-90deg) translateZ(50px);
    left: 0;
    background: rgba(60, 60, 60, 0.5);
    z-index: 0;
}

.cell:not(.empty) .cell-right,
.cell:not(.empty) .cell-bottom {
    display: block;
}

.cell.highlight .cell-front {
    border: 2px solid white;
    box-shadow: 0 0 15px white;
}

.highlight-river .cell-front {
    border: 2px solid #00a8ff;
    box-shadow: 0 0 15px #00a8ff;
}

.highlight-farmer .cell-front {
    border: 2px solid #4CAF50;
    box-shadow: 0 0 15px #4CAF50;
}

.highlight-blacksmith .cell-front {
    border: 2px solid #f44336;
    box-shadow: 0 0 15px #f44336;
}

.empty .cell-front {
    background-color: rgba(248, 249, 250, 0.2);
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><rect width="100" height="100" fill="none" stroke="%23ccc" stroke-width="1" stroke-dasharray="5,5"/></svg>');
}

.dirt .cell-front { 
    background-image: url('dirt.jpg') !important;
}
.grass .cell-front { 
    background-image: url('grass.jpg') !important;
}
.tree .cell-front { 
    background-image: url('tree.jpg') !important;
}
.windmill .cell-front { 
    background-image: url('windmill.jpg') !important;
}
.puddle .cell-front { 
    background-image: url('puddle.jpg') !important;
}
.river .cell-front { 
    background-image: url('river.jpg') !important;
}
.cascade .cell-front { 
    background-image: url('cascade.jpg') !important;
}
.stone .cell-front { 
    background-image: url('stone.jpg') !important;
}
.rock .cell-front { 
    background-image: url('rock.jpg') !important;
}
.mountain .cell-front { 
    background-image: url('mountain.jpg') !important;
}
.village .cell-front { 
    background-image: url('village.jpg') !important;
}
.river_house .cell-front { 
    background-image: url('river_house.jpg') !important;
}
.farmer_house .cell-front { 
    background-image: url('farmer_house.jpg') !important;
}
.blacksmith_house .cell-front { 
    background-image: url('blacksmith_house.jpg') !important;
}
.castle .cell-front { 
    background-image: url('castle.jpg') !important;
}
.forest .cell-front { 
    background-image: url('forest.jpg') !important;
}

.cell.highlight-farmer .cell-front {
    box-shadow: inset 0 0 0 2px #4CAF50;
}
.cell.highlight-river .cell-front {
    box-shadow: inset 0 0 0 2px #2196F3;
}
.cell.highlight-blacksmith .cell-front {
    box-shadow: inset 0 0 0 2px #F44336;
}



.sparkle-container {
    position: absolute;
    width: 100px;
    height: 100px;
    pointer-events: none;
    z-index: 10;
}

.sparkle {
    position: absolute;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background-color: gold;
    box-shadow: 0 0 8px 1px gold;
    animation: sparkle-fade 1s ease-out forwards;
}

.blue-sparkle {
    position: absolute;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background-color: #00a8ff;
    box-shadow: 0 0 8px 1px #00a8ff;
    animation: sparkle-fade 2s ease-out forwards;
}

.red-sparkle {
    position: absolute;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background-color: #ff3e3e;
    box-shadow: 0 0 8px 1px #ff3e3e;
    animation: sparkle-fade 2.5s ease-out forwards;
}

@keyframes sparkle-fade {
    0% { transform: translate(0, 0) scale(1); opacity: 1; }
    100% { transform: translate(var(--tx), var(--ty)) scale(0); opacity: 0; }
}

.villager, .boar {
    position: absolute;
    width: 60px;
    height: 60px;
    background-size: contain;
    background-repeat: no-repeat;
    z-index: 100;
    pointer-events: none;
    will-change: transform;
    transition: transform 0.4s ease-out;
}

.villager {
    background-image: url('villager.gif');
}

.energy-container {
    position: absolute;
    top: 40px;
    left: 60px;
    display: flex;
}

.energy {
    display: inline-block;
    width: 25px;
    height: 25px;
    background-color: #9c27b0;
    border-radius: 50%;
    margin-right: 5px;
    box-shadow: 0 0 10px #9c27b0;
    animation: pulse-energy 6s infinite ease-in-out;
    transform-origin: center;
}

.energy:nth-child(1) { animation-delay: 0s; }
.energy:nth-child(2) { animation-delay: 0.8s; }
.energy:nth-child(3) { animation-delay: 1.6s; }
.energy:nth-child(4) { animation-delay: 2.4s; }
.energy:nth-child(5) { animation-delay: 3.2s; }

@keyframes pulse-energy {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 10px #9c27b0;
    }
    50% {
        transform: scale(1.2);
        box-shadow: 0 0 10px #9c27b0;
    }
}

.energy-container .energy[style*="opacity: 0.3"] {
    animation: none;
    opacity: 0.3 !important;
    box-shadow: 0 0 5px rgba(156, 39, 176, 0.5);
}

.villager-counter {
    position: absolute;
    font-family: 'Gloria Hallelujah', cursive;
    top: 100px;
    left: 20px;
    display: flex;
    align-items: center;
    padding: 16px 30px;
    color: white;
    font-size: 36px;
    font-weight: bold;
    z-index: 100;
	pointer-events: none;
}

.villager-icon {
    width: 60px;
    height: 60px;
    margin-right: 20px;
    background-image: url('villager.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: 0 0 !important;
    animation: none !important;
    image-rendering: pixelated;
    filter: drop-shadow(0 0 4px rgba(0,0,0,0.5));
}

#villagerCount {
    min-width: 40px;
    text-align: center;
    text-shadow: 0 0 5px rgba(0,0,0,0.5);
}

.boar {
    background-image: url('boar.gif');
}

.moving-villager, .moving-boar {
    animation: walk-animation 0.5s infinite steps(2);
}

@keyframes walk-animation {
    0% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
    100% { transform: translateY(0); }
}

.victory-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(2.5px);
}

.victory-popup {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.9), rgba(255, 140, 0, 0.9));
    padding: 30px;
    border-radius: 60px;
    text-align: center;
    box-shadow: 0 0 30px gold, 0 0 60px rgba(255, 215, 0, 0.5);
    max-width: 80%;
    animation: pulse 2s infinite;
    border: 3px solid white;
    padding-bottom: 50px;
}

.victory-title {
    font-family: 'Gloria Hallelujah', 'Comic Neue', cursive;
    font-size: 3em;
    color: white;
    text-shadow: 3px 3px 0px rgba(0,0,0,0.2);
    margin-bottom: 20px;
}

.victory-message {
    font-family: 'Gloria Hallelujah', 'Comic Neue', cursive;
    font-size: 1.5em;
    color: white;
    margin-bottom: 30px;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
}

.confetti {
    position: absolute;
    width: 12px;
    height: 12px;
    opacity: 0.8;
    z-index: 1001;
    animation: confetti-fall 3s ease-out forwards;
    --tx: calc((0.5 - random()) * 200px);
    --ty: 100vh;
}

@keyframes confetti-fall {
    0% { 
        transform: 
            translateY(-100px) 
            translateX(calc(-50px + (var(--tx) * 0.1)))
            rotate(0deg) 
            scale(1);
        opacity: 1;
    }
    100% { 
        transform: 
            translateY(calc(100vh + 100px))
            translateX(var(--tx))
            rotate(720deg) 
            scale(0.5);
        opacity: 0;
    }
}

@keyframes pulse {
    0% { transform: scale(1); box-shadow: 0 0 30px gold; }
    50% { transform: scale(1.05); box-shadow: 0 0 50px gold; }
    100% { transform: scale(1); box-shadow: 0 0 30px gold; }
}

.controls {
    font-family: 'Gloria Hallelujah', 'Comic Neue', cursive;
    letter-spacing: 1px;
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: #fff;
    background-color: rgba(0,0,0,0.5);
    padding: 10px;
    border-radius: 5px;
    white-space: nowrap;
}

.tool-selection {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    z-index: 10;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.8s ease-out, transform 0.8s ease-out;
}

.tool-btn {
    width: 100px;
    height: 100px;
    border-radius: 15px;
    border: 3px solid transparent;
    cursor: pointer;
    margin-right: 10px;
    margin-top: 10px;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    transition: all 0.3s ease;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    transition: all 0.5s ease, opacity 0.8s ease 0.3s;
    opacity: 0;
}

.tool-cost {
    position: absolute;
    left: -80px;
    top: 50%;
    transform: translateY(-50%);
    display: none;
    align-items: center;
    justify-content: flex-end;
    width: 60px;
}

.tool-btn:hover .tool-cost {
    display: flex;
}

.energy-cost {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background-color: #9c27b0;
    margin-left: 3px;
    box-shadow: 0 0 5px #9c27b0;
    opacity: 0.8;
}

.tool-btn.show {
    opacity: 1;
}

.tool-btn:hover {
    transform: scale(1.2);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
    z-index: 20;
}

.tool-btn.active {
    border-color: #ffeb3b;
    box-shadow: 0 0 30px #ffeb3b;
}

.tool-btn[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
    transform: scale(1);
    filter: grayscale(50%);
}

#dirt-tool { 
    background-image: url('dirt.jpg');
    background-size: cover;
}

#puddle-tool { 
    background-image: url('puddle.jpg');
    background-size: cover;
}

#stone-tool { 
    background-image: url('stone.jpg');
    background-size: cover;
}

.tool-btn.house-tool {
    display: none;
}

#windmill-tool { 
    background-image: url('windmill.jpg');
    background-size: cover;
}

#river-house-tool { 
    background-image: url('river_house.jpg');
    background-size: cover;
}

#farmer-house-tool { 
    background-image: url('farmer_house.jpg');
    background-size: cover;
}

#blacksmith-house-tool { 
    background-image: url('blacksmith_house.jpg');
    background-size: cover;
}

.cell.boar-spawn-warning .cell-front {
    animation: spawn-warning-pulse 0.5s infinite alternate;
}

.cell.boar-spawning .cell-front {
    animation: boar-spawn-flash 0.2s 5;
}

@keyframes spawn-warning-pulse {
    0% { box-shadow: 0 0 5px orange; }
    100% { box-shadow: 0 0 20px red; }
}

@keyframes boar-spawn-flash {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.5); }
}

.house-tool {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.8s ease-out, transform 0.8s ease-out;
    display: block !important;
    visibility: hidden;
}

.house-tool.show {
    opacity: 1;
    transform: translateY(0);
    visibility: visible;
}

.house-tool:nth-child(1).show { transition-delay: 0.3s; }
.house-tool:nth-child(2).show { transition-delay: 0.6s; }
.house-tool:nth-child(3).show { transition-delay: 0.9s; }

.notification {
    position: fixed;
    top: 20%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.7);
    color: white;
    padding: 15px 30px;
    border-radius: 30px;
    z-index: 1000;
    animation: fadeIn 0.5s;
    font-family: 'Gloria Hallelujah', cursive;
}

.resource-container {
    position: fixed;
    bottom: 80px;
    left: 20px;
    display: flex;
    gap: 15px;
    z-index: 100;
}

.resource {
    background: rgba(0,0,0,0.5);
    padding: 10px 15px;
    border-radius: 20px;
    color: white;
    font-family: 'Gloria Hallelujah', cursive;
    display: flex;
    align-items: center;
    gap: 5px;
}

.upgrade-container {
    position: fixed;
    bottom: 20px;
    left: 20px;
    display: flex;
    gap: 10px;
    z-index: 100;
}

.upgrade-btn {
    background: linear-gradient(to bottom, #4CAF50, #2E7D32);
    border: none;
    padding: 10px 15px;
    border-radius: 20px;
    color: white;
    font-family: 'Gloria Hallelujah', cursive;
    cursor: pointer;
    transition: transform 0.2s;
}

.upgrade-btn:hover {
    transform: scale(1.05);
}

.upgrade-btn:active {
    transform: scale(0.95);
}

.settings-toggle {
  position: fixed;
  bottom: 1%;
  right: 1%;
  padding: 10px;
  border-radius: 5px;
  color: white;
  z-index: 100;
  opacity: 50%
}

.settings-toggle input {
  margin-right: 8px;
}

/* Instruction bubbles */
.instruction-container {
    position: absolute;
    right: 3%;
    top: 50%;
    transform: translateY(-50%);
    width: 350px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.instruction-bubble {
    background: rgba(255, 255, 255, 0.9);
    border-radius: 20px;
    padding: 5%;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    position: relative;
    opacity: 0;
    transform: translateX(20px);
	transition: opacity 0.5s ease, transform 0.5s ease, height 0.3s ease, padding 0.3s ease;
    font-family: 'Comic Neue', cursive;
    color: #333;
	font-size:20px;
	overflow: hidden;
}

.instruction-bubble.closing {
  opacity: 0 !important;
  transform: translateX(20px) !important;
  height: 0 !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  margin: 0 !important;
}

.disable-tooltips .instruction-bubble {
    display: none !important;
}

.instruction-bubble.show {
    opacity: 1;
    transform: translateX(0);
}

.instruction-bubble h3 {
    margin-top: 0;
    margin-bottom: 10px;
    color: #9c27b0;
    font-family: 'Gloria Hallelujah', cursive;
}

.instruction-bubble p {
    margin: 0;
    line-height: 1.4;
}

.close-bubble {
    position: absolute;
    top: 5px;
    right: 5px;
    background: none;
    border: none;
    font-size: 35px;
    cursor: pointer;
    color: #888;
    padding: 5px;
}

.close-bubble:hover {
    color: #333;
}

.instruction-bubble::after {
    content: '';
    position: absolute;
    left: -10px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-top: 10px solid transparent;
    border-bottom: 10px solid transparent;
    border-right: 10px solid rgba(255, 255, 255, 0.9);
}

#bulldozer-tool { 
    background-image: url('bulldozer.png');
    background-size: cover;
}

@media (max-width: 768px) {
    .scene-container {
        width: 100vw;
        height: 100vw;
        margin-top: 120px;
        margin-bottom: 180px;
        padding: 0;
        overflow: visible;
    }
    
    /* Update the grid layout */
    .grid-3d {
        display: grid;
        grid-template-columns: repeat(5, 1fr);
        grid-template-rows: repeat(5, 1fr);
        width: 100%;
        height: 100%;
        gap: 2px;
        transform: none !important;
        perspective: none;
        transition: all 0.5s ease;
    }
    
    /* For 6x6 grid */
    .grid-3d.expanded {
        grid-template-columns: repeat(6, 1fr);
        grid-template-rows: repeat(6, 1fr);
        gap: 1px;
    }
    
    .cell {
        position: relative;
        width: 100%;
        height: 100%;
        margin: 0;
        transform: none !important;
        transition: all 0.5s ease;
    }
    
    /* Ensure new cells are properly positioned */
    .grid-3d.expanded .cell {
        grid-column: attr(data-col);
        grid-row: attr(data-row);
    }
    
    .cell-face {
        display: none;
    }
    
    .cell-front {
        display: block;
        transform: none !important;
        position: relative;
        width: 100%;
        height: 100%;
        border: 1px solid rgba(255,255,255,0.2);
    }
    
    /* Adjust tool selection for mobile */
    .tool-selection {
        position: fixed;
		top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        display: flex;
		max-height: 20%;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px;
        padding: 10px;
        background: rgba(0,0,0,0.2);
    }
	
	.settings-toggle {
		position: fixed;
		top: 15%;
        bottom: auto;
        left: auto;
        right: 0;
        display: flex;
	}
	
	.energy-container {
		position: fixed;
		top: 15%;
        bottom: auto;
        left: 0;
        right: auto;
        display: flex;
	}
    
    .tool-btn {
        width: 60px;
        height: 60px;
        margin: 0;
    }
    
    /* Adjust title position */
    h1 {
        position: fixed;
        top: 10px;
        font-size: 1.8rem;
        white-space: normal;
        width: 90%;
        padding: 10px;
    }
    
    /* Hide 3D faces */
    .cell-back, .cell-right, .cell-left, .cell-top, .cell-bottom {
        display: none !important;
    }
    
    /* Adjust UI elements */
    .energy-container, .villager-counter {
        position: fixed;
        top: 15%;
        left: 5%;
    }
	
    .villager-counter {
        position: fixed;
        top: 17%;
        left: 5%;
        font-size: 1.5rem;
    }
    
    .villager-icon {
        width: 40px;
        height: 40px;
    }
    
    /* Instruction bubbles */
    .instruction-container {
        position: fixed;
        top: auto;
        bottom: 180px;
        left: 10px;
        right: 10px;
        width: auto;
        transform: none;
    }
    
    .instruction-bubble::after {
        display: none;
    }
    
    .resource-container, .upgrade-container {
        display: none; /* Hide on mobile for simplicity */
    }
	
	.victory-title {
		margin-top:40%
	}
	
	.villager, .boar {
        width: 15% !important;
        height: 15% !important;    
    }
	
	@keyframes gridExpand {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(0.8);
    opacity: 0.7;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.grid-3d.expanding {
  animation: gridExpand 1s ease-out;
}

}