html {
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

body {
    font-family: 'MedievalSharp', serif;
    background: #440c0c url('https://www.transparenttextures.com/patterns/brick-wall-dark.png') repeat;
    color: #fdf6e3;
    text-align: center;
    padding: 20px;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}


#game-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    background: rgba(35, 27, 20, 0.95);
    border: 5px solid #a67c52;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.8);
    border-radius: 12px;
    position: relative;
}

#enemy-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin: 20px 0;
}

#enemy-box {
    background: #222 url('https://www.transparenttextures.com/patterns/skulls.png') repeat;
    padding: 10px;
    border: 3px double #c9b79c;
    border-radius: 8px;
    box-shadow: 0 0 10px #8b4513;
}

#enemy-wrapper {
    position: relative;
    display: inline-block;
}

#enemy-canvas {
    background-color: #000;
    image-rendering: pixelated;
    cursor: pointer;
    touch-action: manipulation;
}

#damage-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

.floating-gold-earned {
    position: absolute;
    color: rgb(9, 226, 82);
    font-size: 20px;
    animation: floatUp 1s ease-out forwards;
}

.floating-damage {
    position: absolute;
    color: red;
    font-size: 20px;
    animation: floatUp 1s ease-out forwards;
}

@keyframes floatUp {
    0% {
        opacity: 1;
        transform: translateY(0);
    }

    100% {
        opacity: 0;
        transform: translateY(-40px);
    }
}

#health-bar {
    width: 150px;
    height: 24px;
    background: url('https://www.transparenttextures.com/patterns/wood-pattern.png') repeat;
    border: 2px solid #ffde9e;
    border-radius: 6px;
    box-shadow: inset 0 0 5px #000, 0 0 8px #8b0000;
    margin: 10px auto;
    overflow: hidden;
    position: relative;
}

#health-fill {
    height: 100%;
    background: linear-gradient(to right, #8b0000, #b22222);
    box-shadow: inset 0 0 4px #400;
    width: 100%;
    transition: width 0.01s ease;
}


#prev-level,
#next-level {
    padding: 10px;
    font-size: 18px;
    background-color: #333;
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    width: 50px;
    height: 50px;
}

#prev-level:hover,
#next-level:hover {
    background-color: #555;
}

button {
    background: linear-gradient(#7b4b26, #4d2a15);
    color: #fdf6e3;
    border: 2px solid #a67c52;
    padding: 8px 16px;
    font-family: 'MedievalSharp', serif;
    border-radius: 6px;
    cursor: pointer;
    transition: transform 0.1s ease;
    touch-action: manipulation;
}

button:hover {
    transform: scale(1.05);
    background: linear-gradient(#996633, #5c3b20);
}

button:disabled {
    background: #444;
    color: #ccc;
    cursor: not-allowed;
}

#stats,
#shop,
#mercenary-shop,
#auto-level-container {
    margin-top: 20px;
}

.merc-row {
    margin-top: 6px;
}

.merc-row button {
    margin-left: 6px;
    font-size: 12px;
    padding: 4px 8px;
}

/* Hero Ability Bar */
#ability-bar {
    margin-top: 20px;
    padding-top: 10px;
}

#ability-bar .ability-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-top: 10px;
}

#ability-bar button {
    background-color: #444;
    color: white;
    border: 2px solid #a67c52;
    padding: 10px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.3s;
    min-width: 150px;
}

#ability-bar button:hover {
    background-color: #444;
}

#ability-bar button:disabled {
    background-color: #444;
    color: #ccc;
    cursor: not-allowed;
}

#ability-bar button.locked {
    background-color: #222;
    color: #777;
    border: 1px solid #555;
    cursor: not-allowed;
}

#save-load-controls button {
    margin: 5px;
}

h1,
h3 {
    font-family: 'MedievalSharp', serif;
    color: #ffde9e;
    border-bottom: 2px solid #a67c52;
    padding-bottom: 4px;
    margin-bottom: 10px;
}

#autosave-indicator {
    margin-left: 10px;
    font-size: 14px;
    color: #00cc88;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0.4s ease;
    display: inline-block;
    width: 100px;
    /* optional: fix width for consistency */
    text-align: left;
}

#name-status,
#msg-status {
    margin-left: 10px;
    font-size: 14px;
    color: #00cc88;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0.4s ease;
    display: inline-block;
    /* optional: fix width for consistency */
    text-align: center;
}

#gold-bar {
    align-items: center;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: #3e1f0d;
    color: #ffde9e;
    padding: 10px;
    font-size: 16px;
    font-family: 'MedievalSharp', serif;
    z-index: 1000;
    border-bottom: 2px solid #a67c52;
    border-top: 2px solid #a67c52;
    text-align: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
}

#gold-fixed {
    display: inline-block;
    min-width: 80px;
    text-align: right;
}

#prev-level:disabled,
#next-level:disabled {
    background-color: #222;
    color: #777;
    cursor: not-allowed;
    opacity: 0.6;
}

.popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.popup-content {
    background: #2e1b10;
    color: #fdf6e3;
    border: 3px solid #a67c52;
    padding: 20px;
    border-radius: 10px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    font-family: 'MedievalSharp', serif;
    text-align: center;
}

#message-scroll,
#leaderboard-scroll {
    flex: 1;
    overflow-y: auto;
    text-align: left;
    margin: 10px 0;
    padding: 10px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid #a67c52;
    border-radius: 6px;
}

@media (max-height: 500px) {
    .popup-content {
        max-height: 90vh;
    }
}

.highlight-player {
    background-color: rgba(139, 69, 19, 0.3);
    /* dark wood tone */
    color: #ffd700;
    /* gold */
    font-weight: bold;
    border-left: 5px solid #cfa75e;
    padding-left: 8px;
    font-family: 'MedievalSharp', serif;
}

#upgrade-multiplier {
    display: inline-block;
    margin-left: 20px;
    font-size: 14px;
}

.upgrade-multiplier {
    display: inline-block;
    margin-left: 20px;
    font-size: 14px;
}

button.mult-btn-tiny {
    font-size: 10px;
    padding: 2px 6px;
}



.upgrade-multiplier button {
    font-size: 12px;
    padding: 4px 8px;
    margin-left: 4px;
    border: 1px solid #a67c52;
    background-color: #5c3b20;
    color: #fdf6e3;
    border-radius: 6px;
    font-family: 'MedievalSharp', serif;
    cursor: pointer;
}

.upgrade-multiplier button:hover {
    background-color: #7b4b26;
    transform: scale(1.05);
}

.upgrade-multiplier button.active {
    background: #a67c52;
    /* Warm leather/golden tone */
    color: #fffbea;
    border: 2px solid #d4af7f;
    /* optional: gold accent border */
}

.popup-toast {
    position: fixed;
    top: 10px;
    right: 10px;
    background: #222;
    border: 2px solid gold;
    padding: 10px 20px;
    color: white;
    font-family: 'MedievalSharp', serif;
    z-index: 99999;
    border-radius: 6px;
    opacity: 0;
    transition: opacity 0.5s ease;
}

#achievement-menu .popup-content {
    max-height: 80vh;
    overflow-y: auto;
}

.scrollable-list {
    max-height: 300px;
    overflow-y: auto;
    text-align: left;
    padding: 10px;
    border: 2px solid #a67c52;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
}

.upgrade-row,
.achievement {
    padding: 8px;
    margin-bottom: 6px;
    background-color: #3a2a1a;
    border-left: 5px solid gray;
    border-radius: 4px;
    color: #ccc;
}

.achievement.unlocked {
    border-left-color: gold;
    color: #fff;
}

#view-switch {
    display: inline-block;
}

#view-switch button {
    margin: 0 5px;
    padding: 4px 10px;
    font-size: 14px;
    background: linear-gradient(#5c3b20, #3a2414);
    border: 2px solid #a67c52;
    color: #fdf6e3;
    border-radius: 6px;
    cursor: pointer;
}

#view-switch button:hover {
    background: linear-gradient(#996633, #5c3b20);
}

.structure-row button.locked {
  background-color: #222;
  color: #777;
  border: 1px solid #555;
  cursor: not-allowed;
}


#kingdom-box {
    width: 100%;
    max-width: 400px;
    aspect-ratio: 1 / 1; /* Keeps square */
    background: #222 url('https://www.transparenttextures.com/patterns/skulls.png') repeat;
    padding: 10px;
    border: 3px double #c9b79c;
    border-radius: 8px;
    box-shadow: 0 0 10px #8b4513;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 20px auto;
    box-sizing: border-box;
}

#kingdom-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

#switch-mode {
    position: fixed;
    top: 0px;
    left: 0;
    width: 100%;
    background: #3e1f0d;
    color: #ffde9e;
    padding: 10px;
    font-size: 16px;
    font-family: 'MedievalSharp', serif;
    z-index: 1000;
    border-bottom: 2px solid #a67c52;
    border-top: 2px solid #a67c52;
    text-align: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
}

.upgrade-row > div {
    align-items: center;
}

.popup-message {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #3e1f0d;
    color: #ffde9e;
    border: 2px solid #a67c52;
    padding: 12px 20px;
    font-family: 'MedievalSharp', serif;
    font-size: 16px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.5);
    max-width: 80%;
    text-align: center;
    opacity: 1;
    visibility: visible;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

.popup-message.fade-out {
    opacity: 0;
    visibility: hidden;
}

.popup-message button {
    padding: 2px 6px;
}

.checkbox-group {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 8px;
}