:root {
    --hd-yellow: #FFD700;
    --hd-orange: #FF8c00;
    --hd-blue: #87CEEB;
    --hd-green: #90EE90;
    --hd-brown: #8B4513;
    --hd-text: #5D4037;
    --hd-font-stack: 'Poppins', sans-serif;
    --hd-body-font: 'Poppins', sans-serif;
}

* {
    box-sizing: border-box;
    user-select: none;
    /* Prevent text selection */
    -webkit-tap-highlight-color: transparent;
}

body,
html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: var(--hd-body-font);
    background-color: #333;
    color: var(--hd-text);
}

#game-container {
    width: 100%;
    height: 100%;
    position: relative;
    max-width: 600px;
    /* Constrain width on desktop */
    margin: 0 auto;
    background: #000;
    overflow: hidden;
}

.game-stage {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: opacity 0.5s ease-in-out;
}

.game-stage.hidden {
    opacity: 0;
    pointer-events: none;
    z-index: 0;
}

.game-stage.active {
    opacity: 1;
    pointer-events: all;
    z-index: 10;
}

/* Backgrounds */
.background-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    z-index: -1;
}

#stage-intro .background-layer {
    background-image: url('../images/bg_intro.png');
    background-color: #87CEEB;
}

#stage-mining .background-layer {
    background-image: url('../images/bg_mine.png');
    background-color: #5D4037;
}

#stage-smelting .background-layer {
    background-image: url('../images/bg_furnace.png');
    background-color: #FF7043;
}

#stage-shaping .background-layer {
    background-image: url('../images/bg_smithy.png');
    background-color: #795548;
}

#stage-gem .background-layer {
    background-image: url('../images/bg_gem.png');
    background-color: #3E2723;
}

#stage-reveal .background-layer {
    background-image: url('../images/bg_reveal.png');
    background-color: #F8BBD0;
}

/* UI Elements */
.ui-layer {
    padding: 20px;
    text-align: center;
    pointer-events: none;
    /* Let clicks pass through to game elements */
}

.ui-layer * {
    pointer-events: all;
}

.title-text {
    font-family: var(--hd-font-stack);
    font-size: 2.5rem;
    color: #fff;
    text-shadow: 2px 2px 0px var(--hd-brown), 4px 4px 0px rgba(0, 0, 0, 0.3);
    margin-top: 20%;
}

.subtitle-text {
    font-size: 1.2rem;
    color: #fff;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    background: rgba(0, 0, 0, 0.4);
    padding: 10px;
    border-radius: 10px;
    display: inline-block;
    margin-bottom: 20px;
}

.game-btn {
    background: linear-gradient(to bottom, #FFEB3B, #FBC02D);
    border: 4px solid #FFF;
    border-radius: 20px;
    padding: 15px 30px;
    font-family: var(--hd-font-stack);
    font-size: 1.5rem;
    color: var(--hd-brown);
    cursor: pointer;
    box-shadow: 0 5px 0 #F57F17, 0 10px 10px rgba(0, 0, 0, 0.3);
    transition: transform 0.1s;
    outline: none;
    display: inline-block;
}

.game-btn:active {
    transform: translateY(5px);
    box-shadow: 0 0 0 #F57F17, 0 5px 5px rgba(0, 0, 0, 0.3);
}

.game-btn.hidden {
    display: none;
}

.instruction-text {
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid var(--hd-brown);
    border-radius: 10px;
    padding: 10px;
    color: var(--hd-brown);
    font-weight: bold;
    display: inline-block;
    margin-bottom: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* Animations */
@keyframes bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-20px);
    }
}

.bounce {
    animation: bounce 2s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }

    100% {
        transform: scale(1);
    }
}

.pulse {
    animation: pulse 1.5s infinite;
}

/* Stage Specifics */
/* Intro */
#stage-intro {
    justify-content: center;
    align-items: center;
}

#stage-intro .content-layer {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
}

#stage-intro .title-text {
    margin-top: 0;
    margin-bottom: 20px;
}

.final-ring-container img {
    max-width: 250px;
    height: auto;
}

.mascot-container {
    margin: 30px 0;
}

.mascot {
    width: 120px;
}

/* Mining */
.interaction-layer {
    flex-grow: 1;
    position: relative;
    width: 100%;
}

.ore-vein {
    position: absolute;
    width: 80px;
    height: 80px;
    background-color: #B0BEC5;
    /* Fallback for ore image */
    background-image: url('../images/silver_ore_vein.png');
    background-size: contain;
    background-repeat: no-repeat;
    cursor: pointer;
    border-radius: 50%;
    box-shadow: inset -5px -5px 10px rgba(0, 0, 0, 0.3);
}

/* Reset hidden for utility */
.hidden {
    display: none !important;
}

/* Reveal */
#stage-reveal {
    justify-content: center;
    align-items: center;
}

#stage-reveal .content-layer {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding-top: 0 !important;
    /* Override inline padding if present */
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.modal-content {
    width: 85%;
    max-width: 400px;
    background: #FFF8E1;
    padding: 30px;
    border-radius: 5px;
    position: relative;
    text-align: center;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    background-image: repeating-linear-gradient(#FFF8E1 0px, #FFF8E1 24px, #B2EBF2 25px);
}

.close-modal {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 2rem;
    cursor: pointer;
    color: var(--hd-brown);
}

.handwritten-font {
    font-family: 'Poppins', sans-serif;
    font-size: 1.1rem;
    line-height: 28px;
    color: #444;
    white-space: pre-wrap;
    text-align: left;
    font-weight: 500;
}

/* Draggables */
.draggable {
    touch-action: none;
    cursor: grab;
}

.draggable-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
}

.ore-chunk {
    width: 60px;
    height: 60px;
    background-color: #B0BEC5;
    border-radius: 50%;
    margin: 10px;
    border: 2px solid #546E7A;
}

.furnace-opening {
    width: 150px;
    height: 150px;
    background-color: #3E2723;
    margin: 0 auto;
    border-radius: 50% 50% 0 0;
    position: relative;
    top: 50px;
    border: 5px solid #5D4037;
}

.gem-option {
    width: 60px;
    height: 60px;
    background-color: rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    margin: 10px;
}

.gem-option img {
    max-width: 100%;
}

.socket {
    width: 100px;
    height: 100px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 50%;
    margin: 50px auto;
    border: 2px dashed #FFF;
}