/* Bucket of Bullets - Rustic Western 8-bit Style */

@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

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

:root {
    /* Wood & leather palette */
    --wood-dark: #2d1810;
    --wood-medium: #4a3020;
    --wood-light: #6b4830;
    --wood-highlight: #8b6840;
    --leather: #5c3d2e;
    --leather-light: #7a5240;

    /* Text colors */
    --gold: #d4a437;
    --gold-bright: #ffd700;
    --cream: #f5deb3;
    --rust: #b7410e;

    /* UI colors */
    --hp-red: #8b0000;
    --hunger-orange: #cd853f;
    --thirst-blue: #4682b4;

    /* Background */
    --bg-dark: #1a0f08;
    --bg-overlay: rgba(20, 10, 5, 0.95);

    /* Borders */
    --border-rope: #8b7355;
    --border-nail: #4a4a4a;

    /* Rarity colors */
    --rarity-common: #9d9d9d;
    --rarity-uncommon: #1eff00;
    --rarity-rare: #0070dd;
    --rarity-epic: #a335ee;
    --rarity-legendary: #ff8000;
}

html, body {
    height: 100%;
    overflow: hidden;
    background: var(--bg-dark);
    font-family: 'Press Start 2P', monospace;
    color: var(--cream);
    font-size: 10px;
}

/* ================================
   MAIN LAYOUT
   ================================ */
#game-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-width: 900px;
    margin: 0 auto;
    background: linear-gradient(180deg, var(--bg-dark) 0%, #0d0705 100%);
    position: relative;
}

/* ================================
   SCREEN EFFECTS (low health/hunger/thirst/poison)
   ================================ */
#screen-effects {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 1000;
}

.screen-vignette {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* Health - Red vignette */
#effect-health {
    box-shadow: inset 0 0 100px 40px rgba(180, 0, 0, 0.6);
}
#effect-health.critical {
    animation: pulse-health 1s ease-in-out infinite;
}

/* Hunger - Orange/brown vignette */
#effect-hunger {
    box-shadow: inset 0 0 80px 30px rgba(139, 90, 43, 0.5);
}
#effect-hunger.critical {
    animation: pulse-hunger 1.5s ease-in-out infinite;
}

/* Thirst - Blue/cyan vignette */
#effect-thirst {
    box-shadow: inset 0 0 80px 30px rgba(0, 100, 150, 0.5);
}
#effect-thirst.critical {
    animation: pulse-thirst 1.5s ease-in-out infinite;
}

/* Poison - Green vignette */
#effect-poison {
    box-shadow: inset 0 0 100px 50px rgba(50, 180, 50, 0.6);
}
#effect-poison.active {
    animation: pulse-poison 0.8s ease-in-out infinite;
}

@keyframes pulse-health {
    0%, 100% { opacity: var(--effect-opacity, 0.5); }
    50% { opacity: calc(var(--effect-opacity, 0.5) * 1.5); }
}

@keyframes pulse-hunger {
    0%, 100% { opacity: var(--effect-opacity, 0.4); }
    50% { opacity: calc(var(--effect-opacity, 0.4) * 1.3); }
}

@keyframes pulse-thirst {
    0%, 100% { opacity: var(--effect-opacity, 0.4); }
    50% { opacity: calc(var(--effect-opacity, 0.4) * 1.3); }
}

@keyframes pulse-poison {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 0.7; }
}

#main-area {
    display: flex;
    flex: 1;
    min-height: 0;
}

/* ================================
   GAME CANVAS - Big cowboy view
   ================================ */
#game-canvas {
    flex: 1;
    min-width: 0;
    background: #4a7c9b;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    border: 4px solid var(--wood-dark);
    border-right: none;
}

/* ================================
   SIDE PANEL - Map, Inventory, etc
   ================================ */
#side-panel {
    width: 100px;
    background: linear-gradient(180deg, var(--wood-medium) 0%, var(--wood-dark) 100%);
    border: 4px solid var(--wood-dark);
    display: flex;
    flex-direction: column;
    padding: 8px;
    gap: 8px;
}

.side-btn-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.side-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 4px;
    background: linear-gradient(180deg, var(--wood-light) 0%, var(--wood-medium) 100%);
    border: 3px solid var(--wood-dark);
    border-top-color: var(--wood-highlight);
    border-left-color: var(--wood-highlight);
    color: var(--gold);
    cursor: pointer;
    font-family: 'Press Start 2P', monospace;
    transition: all 0.1s;
}

.side-btn:hover {
    background: linear-gradient(180deg, var(--wood-highlight) 0%, var(--wood-light) 100%);
    color: var(--gold-bright);
}

.side-btn:active {
    border-top-color: var(--wood-dark);
    border-left-color: var(--wood-dark);
    border-bottom-color: var(--wood-highlight);
    border-right-color: var(--wood-highlight);
}

.btn-icon {
    font-size: 16px;
    margin-bottom: 2px;
}

.btn-label {
    font-size: 7px;
}

/* Side panel stats */
.side-stats {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 6px;
    background: var(--wood-dark);
    border: 2px solid var(--border-rope);
}

.mini-stat {
    display: flex;
    align-items: center;
    gap: 4px;
}

.stat-icon {
    font-size: 10px;
    width: 14px;
}

.mini-bar {
    flex: 1;
    height: 8px;
    background: #1a1a1a;
    border: 1px solid var(--border-rope);
}

.mini-bar .fill {
    height: 100%;
    transition: width 0.3s;
}

.mini-bar.hp .fill {
    background: var(--hp-red);
    width: 100%;
}

.mini-bar.hunger .fill {
    background: var(--hunger-orange);
    width: 100%;
}

.mini-bar.thirst .fill {
    background: var(--thirst-blue);
    width: 100%;
}

/* Location box */
.location-box {
    margin-top: auto;
    padding: 6px;
    background: var(--wood-dark);
    border: 2px solid var(--border-rope);
    text-align: center;
}

#location-name {
    font-size: 7px;
    color: var(--gold);
    margin-bottom: 2px;
    word-wrap: break-word;
}

#distance-info {
    font-size: 8px;
    color: var(--cream);
}

/* ================================
   BOTTOM PANEL - Text & Actions
   ================================ */
#bottom-panel {
    display: flex;
    gap: 8px;
    padding: 8px;
    background: var(--wood-dark);
    border-top: 4px solid var(--wood-medium);
    min-height: 100px;
}

#text-box {
    flex: 1;
    padding: 10px;
    background: linear-gradient(180deg, #2a1f15 0%, #1a1208 100%);
    border: 3px solid var(--border-rope);
    border-radius: 2px;
    overflow-y: auto;
    /* Parchment texture effect */
    box-shadow: inset 0 0 20px rgba(0,0,0,0.5);
}

#text-content {
    font-size: 9px;
    line-height: 1.6;
    color: var(--cream);
}

#action-area {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 140px;
}

.action-group {
    display: none;
    flex-wrap: wrap;
    gap: 6px;
}

.action-group.active {
    display: flex;
}

.action-btn {
    flex: 1 1 calc(50% - 3px);
    min-width: 60px;
    padding: 10px 8px;
    background: linear-gradient(180deg, var(--leather-light) 0%, var(--leather) 100%);
    border: 3px solid var(--wood-dark);
    border-top-color: var(--wood-light);
    border-left-color: var(--wood-light);
    color: var(--cream);
    font-family: 'Press Start 2P', monospace;
    font-size: 8px;
    cursor: pointer;
    transition: all 0.1s;
}

.action-btn:hover {
    background: linear-gradient(180deg, var(--wood-light) 0%, var(--leather-light) 100%);
    color: var(--gold-bright);
}

.action-btn:active {
    border-top-color: var(--wood-dark);
    border-left-color: var(--wood-dark);
    border-bottom-color: var(--wood-light);
    border-right-color: var(--wood-light);
}

.action-btn.primary {
    background: linear-gradient(180deg, var(--rust) 0%, #8b2500 100%);
    color: var(--gold-bright);
}

.action-btn.primary:hover {
    background: linear-gradient(180deg, #d4500e 0%, var(--rust) 100%);
}

/* ================================
   OVERLAYS - Panels & Menus
   ================================ */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-overlay);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.overlay.active {
    display: flex;
}

/* Title Screen - override overlay dark background */
#title-screen.overlay {
    background: url('../assets/backgrounds/desert-b-dusk.png') center bottom / cover no-repeat;
}

#title-screen.overlay[data-time="dawn"] {
    background: url('../assets/backgrounds/desert-b-dawn.png') center bottom / cover no-repeat;
}

#title-screen.overlay[data-time="noon"],
#title-screen.overlay[data-time="day"] {
    background: url('../assets/backgrounds/desert-b-noon.png') center bottom / cover no-repeat;
}

#title-screen.overlay[data-time="dusk"],
#title-screen.overlay[data-time="sunset"] {
    background: url('../assets/backgrounds/desert-b-dusk.png') center bottom / cover no-repeat;
}

#title-screen.overlay[data-time="night"] {
    background: url('../assets/backgrounds/desert-b-night.png') center bottom / cover no-repeat;
}


.title-content {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 20px;
}

/* Rope frame around title card */
.title-card-frame {
    position: relative;
    padding: 15px;
    background: linear-gradient(135deg, #6b5335 0%, #8b7355 50%, #6b5335 100%);
    border: 8px solid;
    border-color: #9a7a55 #5a4a35 #4a3a28 #7a6a45;
    border-radius: 6px;
    box-shadow:
        inset 0 0 0 2px #a08060,
        inset 0 0 0 4px #3a2818,
        0 10px 40px rgba(0,0,0,0.7),
        0 0 0 4px rgba(0,0,0,0.3);
}

/* Inner rope detail */
.title-card-frame::before {
    content: '';
    position: absolute;
    top: 4px;
    left: 4px;
    right: 4px;
    bottom: 4px;
    border: 3px solid #9a8060;
    border-radius: 4px;
    pointer-events: none;
}

.title-card {
    display: block;
    max-width: 500px;
    width: 100%;
    height: auto;
    image-rendering: pixelated;
}

/* Buttons overlay on the title card */
.title-overlay-buttons {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

.title-overlay-buttons .wood-btn {
    min-width: 200px;
    background: linear-gradient(180deg, rgba(107, 72, 48, 0.95) 0%, rgba(74, 48, 32, 0.95) 100%);
    backdrop-filter: blur(2px);
}

.title-overlay-buttons .subtitle {
    font-size: 9px;
    color: var(--cream);
    text-shadow: 2px 2px 4px rgba(0,0,0,0.9);
    letter-spacing: 2px;
    margin-bottom: 15px;
}

/* Wood button style */
.wood-btn {
    padding: 14px 28px;
    background: linear-gradient(180deg, var(--wood-light) 0%, var(--wood-medium) 100%);
    border: 4px solid var(--wood-dark);
    border-top-color: var(--wood-highlight);
    border-left-color: var(--wood-highlight);
    color: var(--gold);
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
    cursor: pointer;
    transition: all 0.1s;
    min-width: 180px;
    text-shadow: 1px 1px 0 var(--wood-dark);
}

.wood-btn:hover:not(:disabled) {
    background: linear-gradient(180deg, var(--wood-highlight) 0%, var(--wood-light) 100%);
    color: var(--gold-bright);
}

.wood-btn:active:not(:disabled) {
    border-top-color: var(--wood-dark);
    border-left-color: var(--wood-dark);
    border-bottom-color: var(--wood-highlight);
    border-right-color: var(--wood-highlight);
}

.wood-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.wood-btn.small {
    padding: 10px 16px;
    font-size: 8px;
    min-width: auto;
}

/* Panel frames for overlays */
.panel-frame {
    background: linear-gradient(180deg, var(--wood-medium) 0%, var(--wood-dark) 100%);
    border: 6px solid var(--wood-light);
    padding: 20px;
    max-width: 350px;
    width: 90%;
    box-shadow:
        inset 0 0 0 2px var(--wood-dark),
        0 0 30px rgba(0,0,0,0.8);
}

.panel-frame.wide {
    max-width: 500px;
}

.panel-title {
    font-size: 12px;
    color: var(--gold-bright);
    text-align: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--border-rope);
}

.panel-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 15px;
    padding-top: 10px;
    border-top: 2px solid var(--border-rope);
}

/* Character Creation - Landscape layout with desert background */
#char-creation.overlay {
    background: url('../assets/backgrounds/desert-b-dusk.png') center bottom / cover no-repeat;
}

#char-creation.overlay[data-time="dawn"] {
    background: url('../assets/backgrounds/desert-b-dawn.png') center bottom / cover no-repeat;
}

#char-creation.overlay[data-time="noon"],
#char-creation.overlay[data-time="day"] {
    background: url('../assets/backgrounds/desert-b-noon.png') center bottom / cover no-repeat;
}

#char-creation.overlay[data-time="dusk"],
#char-creation.overlay[data-time="sunset"] {
    background: url('../assets/backgrounds/desert-b-dusk.png') center bottom / cover no-repeat;
}

#char-creation.overlay[data-time="night"] {
    background: url('../assets/backgrounds/desert-b-night.png') center bottom / cover no-repeat;
}

#char-creation .panel-frame {
    max-width: 700px;
}

.creation-form {
    display: grid;
    grid-template-columns: 200px 1fr;
    grid-template-rows: auto auto auto;
    gap: 15px;
}

.char-preview-container {
    grid-row: 1 / 4;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 15px;
    background: rgba(0,0,0,0.3);
    border: 2px solid var(--border-rope);
}

#char-preview-canvas {
    width: 180px;
    height: 280px;
    image-rendering: pixelated;
    background: repeating-linear-gradient(
        45deg,
        rgba(0,0,0,0.1),
        rgba(0,0,0,0.1) 5px,
        transparent 5px,
        transparent 10px
    );
}

/* Right side form sections stack vertically */
.creation-form .form-group:nth-child(2),
.creation-form .form-group:nth-child(3),
.creation-form .form-group:nth-child(4),
.creation-form .form-group:nth-child(5) {
    grid-column: 2;
}

.creation-form .stat-preview,
.creation-form #start-game-btn {
    grid-column: 1 / -1;
}

.form-group {
    text-align: left;
}

.form-group label {
    display: block;
    font-size: 8px;
    color: var(--gold);
    margin-bottom: 6px;
}

.form-group input {
    width: 100%;
    padding: 10px;
    background: var(--bg-dark);
    border: 3px solid var(--border-rope);
    color: var(--cream);
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
}

.form-group input:focus {
    outline: none;
    border-color: var(--gold);
}

.background-options {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.bg-option {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    background: var(--bg-dark);
    border: 3px solid var(--border-rope);
    color: var(--cream);
    font-family: 'Press Start 2P', monospace;
    cursor: pointer;
    transition: all 0.1s;
}

.bg-option:hover {
    border-color: var(--gold);
}

.bg-option.selected {
    background: var(--wood-dark);
    border-color: var(--gold-bright);
}

.bg-name {
    font-size: 9px;
    color: var(--cream);
}

.bg-bonus {
    font-size: 7px;
    color: var(--gold);
}

/* Gender selection */
.gender-options {
    display: flex;
    gap: 8px;
}

.gender-option {
    flex: 1;
    padding: 10px;
    background: var(--bg-dark);
    border: 3px solid var(--border-rope);
    color: var(--cream);
    font-family: 'Press Start 2P', monospace;
    font-size: 8px;
    cursor: pointer;
    transition: all 0.1s;
}

.gender-option:hover {
    border-color: var(--gold);
}

.gender-option.selected {
    background: var(--wood-dark);
    border-color: var(--gold-bright);
}

/* Color pickers */
.color-pickers {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.color-pick {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.color-pick span {
    font-size: 7px;
    color: var(--gold);
}

.color-swatches {
    display: flex;
    gap: 4px;
}

.swatch {
    width: 24px;
    height: 24px;
    border: 2px solid var(--border-rope);
    cursor: pointer;
    padding: 0;
    transition: all 0.1s;
}

.swatch:hover {
    transform: scale(1.1);
    border-color: var(--cream);
}

.swatch.selected {
    border-color: var(--gold-bright);
    box-shadow: 0 0 8px var(--gold);
}

.stat-preview {
    background: var(--bg-dark);
    padding: 10px;
    border: 2px solid var(--border-rope);
}

.stat-row {
    display: flex;
    justify-content: space-between;
    font-size: 8px;
    padding: 4px 0;
    border-bottom: 1px solid var(--wood-dark);
}

.stat-row:last-child {
    border-bottom: none;
}

/* ================================
   BACKPACK INVENTORY UI
   ================================ */

.inventory-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px;
}

.backpack-wrapper {
    position: relative;
    display: inline-block;
}

.backpack-bg {
    max-width: 90vw;
    max-height: 70vh;
    height: auto;
    image-rendering: pixelated;
}

/* Grid positioned over backpack's grid area */
#inventory-grid {
    position: absolute;
    /* These percentages position grid over the backpack's grid area */
    top: 18%;
    left: 16%;
    width: 52%;
    height: 62%;
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    grid-template-rows: repeat(5, 1fr);
    gap: 1.5%;
    padding: 1%;
}

#inventory-grid .item-slot {
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(139, 115, 85, 0.3);
    cursor: pointer;
}

#inventory-grid .item-slot:hover {
    background: rgba(212, 164, 55, 0.2);
    border-color: var(--gold);
}

#inventory-grid .item-slot.selected {
    background: rgba(212, 164, 55, 0.3);
    border: 2px solid var(--gold);
    box-shadow: 0 0 8px rgba(212, 164, 55, 0.5);
}

#inventory-grid .item-slot img {
    width: 90%;
    height: 90%;
    object-fit: contain;
    image-rendering: pixelated;
}

/* Item info panel (black box on right side of backpack) */
#item-info-panel {
    position: absolute;
    top: 14%;
    right: 2%;
    width: 18%;
    height: 32%;
    padding: 4%;
    overflow: hidden;
}

#item-info-content {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    font-size: 8px;
    color: var(--cream);
}

.item-info-placeholder {
    color: #666;
    font-size: 7px;
    text-align: center;
    margin-top: 30%;
}

.item-info-name {
    font-size: 9px;
    font-weight: bold;
    margin-bottom: 4px;
    text-transform: uppercase;
}

.item-info-rarity {
    font-size: 7px;
    text-transform: uppercase;
    margin-bottom: 6px;
}

.item-info-type {
    font-size: 7px;
    color: #aaa;
    margin-bottom: 8px;
}

.item-info-stats {
    font-size: 7px;
    margin-bottom: 8px;
    line-height: 1.4;
}

.item-info-stats .stat-bonus {
    color: #4f4;
}

.item-info-value {
    font-size: 7px;
    color: var(--gold);
    margin-bottom: 8px;
}

.item-info-actions {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: auto;
}

.item-action-btn {
    background: var(--wood-dark);
    border: 1px solid var(--border-rope);
    color: var(--cream);
    padding: 4px 6px;
    font-size: 7px;
    font-family: 'Press Start 2P', cursive;
    cursor: pointer;
    text-align: center;
}

.item-action-btn:hover {
    background: var(--wood-medium);
    border-color: var(--gold);
}

.item-action-btn.primary {
    background: var(--leather);
    border-color: var(--gold);
}

.item-action-btn.danger {
    border-color: var(--rust);
}

.item-action-btn.danger:hover {
    background: rgba(183, 65, 14, 0.3);
}

.inventory-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 500px;
    margin-top: 10px;
    padding: 8px 15px;
    background: var(--wood-dark);
    border: 2px solid var(--border-rope);
    border-radius: 4px;
}

#money-display {
    font-size: 12px;
    color: var(--gold-bright);
}

/* Equipped badge */
.equipped-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    background: var(--gold);
    color: var(--wood-dark);
    font-size: 6px;
    padding: 1px 3px;
    border-radius: 2px;
    font-weight: bold;
}

/* Quantity badge */
.item-qty {
    position: absolute;
    bottom: 2px;
    right: 2px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    font-size: 6px;
    padding: 1px 3px;
    border-radius: 2px;
}

/* Empty slot placeholder */
.empty-slot {
    background: transparent !important;
    border: 1px dashed rgba(139, 115, 85, 0.2) !important;
}

/* Map Content */
#map-content {
    background: var(--bg-dark);
    padding: 15px;
    border: 2px solid var(--border-rope);
    font-size: 8px;
    line-height: 1.8;
    max-height: 250px;
    overflow-y: auto;
}

.map-location {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px dashed var(--wood-dark);
}

.map-location.current {
    color: var(--gold-bright);
}

.map-location.visited {
    color: var(--cream);
}

.map-location.future {
    color: var(--wood-light);
}

/* Cloud Save */
#cloud-content {
    text-align: center;
}

.cloud-section {
    padding: 15px 0;
}

.cloud-section p {
    font-size: 8px;
    margin-bottom: 10px;
}

.rustic-hr {
    border: none;
    height: 2px;
    background: var(--border-rope);
}

#cloud-code-input {
    width: 120px;
    padding: 10px;
    background: var(--bg-dark);
    border: 3px solid var(--border-rope);
    color: var(--gold-bright);
    font-family: 'Press Start 2P', monospace;
    font-size: 14px;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 4px;
    margin-bottom: 10px;
}

.code-display {
    margin-top: 15px;
    padding: 10px;
    background: var(--bg-dark);
    border: 2px solid var(--gold);
    font-size: 8px;
}

.code-display span {
    font-size: 16px;
    color: var(--gold-bright);
    letter-spacing: 4px;
}

.hidden {
    display: none !important;
}

/* Journal */
.journal-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 10px;
    background: var(--bg-dark);
    border: 2px solid var(--border-rope);
    margin-bottom: 10px;
    font-size: 8px;
}

.journal-entries {
    max-height: 150px;
    overflow-y: auto;
    padding: 10px;
    background: var(--bg-dark);
    border: 2px solid var(--border-rope);
    font-size: 8px;
}

.journal-entry {
    padding: 6px 0;
    border-bottom: 1px dashed var(--wood-dark);
}

/* ================================
   RESPONSIVE
   ================================ */
@media (max-width: 600px) {
    #side-panel {
        width: 80px;
    }

    .btn-icon {
        font-size: 14px;
    }

    .btn-label {
        font-size: 6px;
    }

    .game-title {
        font-size: 14px;
    }

    .title-art {
        font-size: 5px;
    }

    .wood-btn {
        padding: 12px 20px;
        font-size: 8px;
        min-width: 140px;
    }

    #text-content {
        font-size: 8px;
    }

    .action-btn {
        padding: 8px 6px;
        font-size: 7px;
    }

    #action-area {
        min-width: 120px;
    }
}

@media (max-height: 500px) {
    #bottom-panel {
        min-height: 80px;
    }

    .side-btn {
        padding: 6px 4px;
    }

    .btn-icon {
        font-size: 12px;
    }
}

/* ================================
   SCROLLBAR
   ================================ */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-dark);
}

::-webkit-scrollbar-thumb {
    background: var(--border-rope);
    border-radius: 0;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--wood-light);
}

/* ================================
   CRT SCANLINE EFFECT (subtle)
   ================================ */
#game-container::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.05) 0px,
        rgba(0, 0, 0, 0.05) 1px,
        transparent 1px,
        transparent 2px
    );
    pointer-events: none;
    z-index: 1000;
}

/* ================================
   ITEM RARITY SYSTEM
   ================================ */

/* Base item slot/frame */
.item-slot {
    position: relative;
    width: 64px;
    height: 64px;
    background: rgba(0, 0, 0, 0.4);
    border: 2px solid var(--wood-dark);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.item-slot:hover {
    transform: scale(1.05);
}

.item-slot img {
    max-width: 56px;
    max-height: 56px;
    image-rendering: pixelated;
}

/* Rarity: Common (Gray) - no glow */
.rarity-common {
    border-color: var(--rarity-common);
}

.rarity-common .item-name {
    color: var(--rarity-common);
}

/* Rarity: Uncommon (Green) - slight glow */
.rarity-uncommon {
    border-color: var(--rarity-uncommon);
    box-shadow:
        0 0 5px rgba(30, 255, 0, 0.3),
        inset 0 0 3px rgba(30, 255, 0, 0.1);
}

.rarity-uncommon .item-name {
    color: var(--rarity-uncommon);
}

/* Rarity: Rare (Blue) - moderate glow */
.rarity-rare {
    border-color: var(--rarity-rare);
    box-shadow:
        0 0 8px rgba(0, 112, 221, 0.5),
        0 0 15px rgba(0, 112, 221, 0.2),
        inset 0 0 5px rgba(0, 112, 221, 0.15);
}

.rarity-rare .item-name {
    color: var(--rarity-rare);
}

/* Rarity: Epic (Purple) - pulse glow */
.rarity-epic {
    border-color: var(--rarity-epic);
    box-shadow:
        0 0 10px rgba(163, 53, 238, 0.6),
        0 0 20px rgba(163, 53, 238, 0.3),
        inset 0 0 8px rgba(163, 53, 238, 0.2);
    animation: pulse-epic 2s ease-in-out infinite;
}

.rarity-epic .item-name {
    color: var(--rarity-epic);
    text-shadow: 0 0 5px rgba(163, 53, 238, 0.5);
}

@keyframes pulse-epic {
    0%, 100% {
        box-shadow:
            0 0 10px rgba(163, 53, 238, 0.6),
            0 0 20px rgba(163, 53, 238, 0.3),
            inset 0 0 8px rgba(163, 53, 238, 0.2);
    }
    50% {
        box-shadow:
            0 0 15px rgba(163, 53, 238, 0.8),
            0 0 30px rgba(163, 53, 238, 0.5),
            inset 0 0 12px rgba(163, 53, 238, 0.3);
    }
}

/* Rarity: Legendary (Orange) - strong pulse glow */
.rarity-legendary {
    border-color: var(--rarity-legendary);
    border-width: 3px;
    box-shadow:
        0 0 12px rgba(255, 128, 0, 0.7),
        0 0 25px rgba(255, 128, 0, 0.4),
        0 0 40px rgba(255, 128, 0, 0.2),
        inset 0 0 10px rgba(255, 128, 0, 0.25);
    animation: pulse-legendary 1.5s ease-in-out infinite;
}

.rarity-legendary .item-name {
    color: var(--rarity-legendary);
    text-shadow:
        0 0 5px rgba(255, 128, 0, 0.6),
        0 0 10px rgba(255, 128, 0, 0.3);
    animation: text-glow-legendary 1.5s ease-in-out infinite;
}

@keyframes pulse-legendary {
    0%, 100% {
        box-shadow:
            0 0 12px rgba(255, 128, 0, 0.7),
            0 0 25px rgba(255, 128, 0, 0.4),
            0 0 40px rgba(255, 128, 0, 0.2),
            inset 0 0 10px rgba(255, 128, 0, 0.25);
        border-color: #ff8000;
    }
    50% {
        box-shadow:
            0 0 18px rgba(255, 128, 0, 0.9),
            0 0 35px rgba(255, 128, 0, 0.6),
            0 0 55px rgba(255, 128, 0, 0.35),
            inset 0 0 15px rgba(255, 128, 0, 0.35);
        border-color: #ffaa00;
    }
}

@keyframes text-glow-legendary {
    0%, 100% {
        text-shadow:
            0 0 5px rgba(255, 128, 0, 0.6),
            0 0 10px rgba(255, 128, 0, 0.3);
    }
    50% {
        text-shadow:
            0 0 8px rgba(255, 128, 0, 0.9),
            0 0 15px rgba(255, 128, 0, 0.5),
            0 0 20px rgba(255, 128, 0, 0.3);
    }
}

/* Item tooltip */
.item-tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(20, 10, 5, 0.95);
    border: 2px solid var(--wood-medium);
    border-radius: 4px;
    padding: 8px 12px;
    min-width: 180px;
    z-index: 100;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
}

.item-slot:hover .item-tooltip {
    opacity: 1;
}

.item-tooltip .item-name {
    font-size: 10px;
    margin-bottom: 4px;
    font-weight: bold;
}

.item-tooltip .item-type {
    font-size: 8px;
    color: var(--cream);
    opacity: 0.7;
    margin-bottom: 6px;
}

.item-tooltip .item-stats {
    font-size: 8px;
    color: var(--gold);
    margin-bottom: 4px;
}

.item-tooltip .item-stats .stat-line {
    margin: 2px 0;
}

.item-tooltip .item-description {
    font-size: 8px;
    color: var(--cream);
    opacity: 0.8;
    font-style: italic;
    margin-top: 6px;
    border-top: 1px solid var(--wood-dark);
    padding-top: 6px;
}

.item-tooltip .item-value {
    font-size: 8px;
    color: var(--gold-bright);
    margin-top: 6px;
}

/* Inventory grid */
.inventory-grid {
    display: grid;
    grid-template-columns: repeat(5, 64px);
    gap: 8px;
    padding: 10px;
}

/* Equipment slots panel */
.equipment-panel {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px;
}

.equipment-slot {
    position: relative;
}

.equipment-slot .slot-label {
    font-size: 8px;
    color: var(--cream);
    opacity: 0.6;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.equipment-slot .item-slot {
    width: 72px;
    height: 72px;
}

.equipment-slot .item-slot.empty {
    border-style: dashed;
    opacity: 0.5;
}

.equipment-slot .item-slot.empty::after {
    content: attr(data-slot-icon);
    font-size: 24px;
    opacity: 0.3;
}

/* Stat display */
.stat-bonus {
    color: var(--rarity-uncommon);
}

.stat-penalty {
    color: var(--rust);
}

/* Item badges */
.item-qty {
    position: absolute;
    bottom: 2px;
    right: 2px;
    background: rgba(0, 0, 0, 0.8);
    color: var(--cream);
    font-size: 8px;
    padding: 1px 4px;
    border-radius: 3px;
}

.equipped-badge {
    position: absolute;
    top: 2px;
    left: 2px;
    background: var(--rarity-uncommon);
    color: #000;
    font-size: 8px;
    font-weight: bold;
    padding: 1px 4px;
    border-radius: 3px;
}

/* Inventory grid override for game */
#inventory-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
    gap: 8px;
    padding: 10px;
    max-height: 300px;
    overflow-y: auto;
}

#inventory-grid .item-slot {
    cursor: pointer;
}

#inventory-grid .item-slot:hover {
    transform: scale(1.08);
    z-index: 10;
}

/* ============================================
   MUSIC CONTROLS
   ============================================ */

/* Simple music toggle - icon only */
#title-music-toggle {
    position: absolute;
    bottom: 12px;
    right: 12px;
    padding: 6px;
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 20px;
    opacity: 0.6;
    transition: opacity 0.2s;
}

#title-music-toggle:hover {
    opacity: 1;
}

#title-music-toggle .sound-on {
    display: inline;
}

#title-music-toggle .sound-off {
    display: none;
}

#title-music-toggle.muted .sound-on {
    display: none;
}

#title-music-toggle.muted .sound-off {
    display: inline;
}

/* Hat toggle in character creation */
.hat-toggle {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: 8px;
    font-size: 9px;
    color: var(--cream);
    cursor: pointer;
}

.hat-toggle input[type="checkbox"] {
    width: 14px;
    height: 14px;
    cursor: pointer;
    accent-color: var(--gold);
}

/* ============================================
   SETTINGS OVERLAY
   ============================================ */

.settings-section {
    margin-bottom: 20px;
}

.settings-header {
    color: var(--gold);
    font-size: 12px;
    margin-bottom: 10px;
    padding-bottom: 5px;
    border-bottom: 1px solid var(--wood-light);
}

.settings-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    color: var(--cream);
    font-size: 11px;
}

.settings-control {
    display: flex;
    align-items: center;
    gap: 10px;
}

.toggle-btn {
    padding: 6px 12px;
    background: var(--wood-dark);
    border: 2px solid var(--rust);
    color: var(--rust);
    font-family: inherit;
    font-size: 10px;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
}

.toggle-btn.on {
    background: var(--wood-medium);
    border-color: var(--gold);
    color: var(--gold);
}

#settings-music-volume {
    width: 100px;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--wood-dark);
    border-radius: 3px;
    cursor: pointer;
}

#settings-music-volume::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--gold);
    cursor: pointer;
}

#settings-music-volume::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--gold);
    cursor: pointer;
    border: none;
}

#settings-volume-display {
    width: 35px;
    text-align: right;
    color: var(--gold);
}

/* ============================================
   WORLD MAP OVERLAY
   ============================================ */

.map-panel {
    max-width: 500px;
}

#map-container {
    position: relative;
    display: inline-block;
    width: 100%;
    background: var(--wood-dark);
    border: 2px solid var(--wood-light);
    border-radius: 4px;
}

#world-map-img {
    display: block;
    width: 100%;
    height: auto;
    max-height: 400px;
    object-fit: contain;
    image-rendering: pixelated;
}

#map-markers {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.map-marker {
    position: absolute;
    transform: translate(-50%, -50%);
    font-size: 20px;
    cursor: pointer;
    pointer-events: auto;
    text-shadow: 2px 2px 2px rgba(0,0,0,0.8);
    transition: transform 0.15s, filter 0.15s;
}

.map-marker:hover {
    transform: translate(-50%, -50%) scale(1.4);
    filter: drop-shadow(0 0 6px var(--gold));
}

.map-marker.undiscovered {
    filter: grayscale(1) brightness(0.5);
    opacity: 0.4;
}

.map-marker.undiscovered:hover {
    filter: grayscale(1) brightness(0.7);
}

.player-marker {
    position: absolute;
    transform: translate(-50%, -50%);
    font-size: 24px;
    filter: drop-shadow(0 0 4px #ff6600);
    animation: pulse-marker 1.5s infinite;
    z-index: 10;
}

@keyframes pulse-marker {
    0%, 100% { transform: translate(-50%, -50%) scale(1); }
    50% { transform: translate(-50%, -50%) scale(1.2); }
}

#map-legend {
    display: flex;
    gap: 15px;
    padding: 8px;
    font-size: 9px;
    color: var(--cream);
    justify-content: center;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.legend-icon {
    font-size: 14px;
}

.map-info {
    background: var(--wood-dark);
    border: 2px solid var(--wood-light);
    border-radius: 4px;
    padding: 10px;
    margin: 10px 0;
    font-size: 10px;
}

.map-info.hidden {
    display: none;
}

.map-info strong {
    color: var(--gold);
    font-size: 11px;
}

.map-info p {
    margin: 5px 0 0 0;
    color: var(--cream);
    line-height: 1.4;
}

/* ============================================
   TRAVEL PROGRESS BAR
   ============================================ */

.travel-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: linear-gradient(180deg, rgba(45, 24, 16, 0.9) 0%, rgba(26, 15, 8, 0.95) 100%);
    border-bottom: 2px solid var(--wood-light);
}

.travel-bar.hidden {
    display: none;
}

.travel-start,
.travel-end {
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 80px;
}

.travel-start {
    justify-content: flex-start;
}

.travel-end {
    justify-content: flex-end;
}

.travel-icon {
    font-size: 16px;
}

.travel-name {
    font-size: 8px;
    color: var(--cream);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 70px;
}

.travel-track {
    flex: 1;
    position: relative;
    height: 20px;
    display: flex;
    align-items: center;
}

.travel-line {
    position: absolute;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--wood-dark);
    border: 1px solid var(--wood-light);
    border-radius: 2px;
}

.travel-line::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--progress, 0%);
    background: linear-gradient(90deg, var(--gold) 0%, #c4a35a 100%);
    border-radius: 2px;
    transition: width 0.3s ease;
}

.travel-marker {
    position: absolute;
    left: var(--progress, 0%);
    transform: translateX(-50%);
    font-size: 18px;
    filter: drop-shadow(1px 1px 2px rgba(0,0,0,0.8));
    transition: left 0.3s ease;
    z-index: 1;
}

/* Animate marker bobbing while walking */
@keyframes travel-bob {
    0%, 100% { transform: translateX(-50%) translateY(0); }
    50% { transform: translateX(-50%) translateY(-3px); }
}

.travel-bar.walking .travel-marker {
    animation: travel-bob 0.4s ease-in-out infinite;
}
