* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, sans-serif;
    background: #111;
    color: #ffffff;
    text-align: center;
}

.screen {
    display: none;
    padding: 40px 16px 24px;
}

.screen.active {
    display: block;
}

h1 {
    font-size: 56px;
    margin-bottom: 10px;
    line-height: 1.1;
}

h2 {
    margin-bottom: 20px;
    font-size: 24px;
}

.subtitle {
    margin-bottom: 30px;
    color: #cccccc;
    font-size: 24px;
}

button {
    display: inline-block;
    margin: 10px 8px 0 0;
    padding: 12px 24px;
    font-size: 16px;
    background: #444444;
    color: #ffffff;
    border: none;
    cursor: pointer;
    min-height: 44px;
}

button:hover {
    background: #666666;
}

#hud {
    width: min(600px, 100%);
    margin: 0 auto 12px auto;
    text-align: left;
}

#stats-panel,
#quest-tracker,
#controls-hint {
    background: #1b1b1b;
    border: 1px solid #555555;
    padding: 10px 12px;
    color: #ffffff;
    margin-bottom: 8px;
    line-height: 1.4;
}

.stats-title {
    font-weight: bold;
    color: #9ed0ff;
    margin-bottom: 10px;
    font-size: 15px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 10px;
}

.stat-card {
    background: #232323;
    border: 1px solid #444444;
    padding: 8px;
    min-height: 64px;
}

.stat-label {
    font-size: 12px;
    color: #bbbbbb;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.stat-value {
    font-size: 18px;
    font-weight: bold;
    color: #ffd27f;
    line-height: 1.2;
    word-break: break-word;
}

#xp-bar-wrap {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

#xp-bar {
    width: 100%;
    height: 12px;
    background: #2b2b2b;
    border: 1px solid #555555;
    overflow: hidden;
}

#xp-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(to right, #4da6ff 0%, #00e6c3 100%);
}

#xp-text {
    font-size: 12px;
    color: #cccccc;
}

#game-area-wrapper {
    width: min(600px, 100%);
    margin: 20px auto 0;
}

#game-area {
    position: relative;
    width: 100%;
    aspect-ratio: 3 / 2;
    min-height: 260px;
    background: linear-gradient(to bottom, #6a5431 0%, #5c4728 100%);
    border: 2px solid #555555;
    overflow: hidden;
}

/* MAP DECOR */
.camp-ground-layer {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 10% 15%, rgba(255, 235, 180, 0.08) 0, rgba(255, 235, 180, 0.08) 2%, transparent 2.2%),
        radial-gradient(circle at 28% 72%, rgba(255, 235, 180, 0.06) 0, rgba(255, 235, 180, 0.06) 2%, transparent 2.2%),
        radial-gradient(circle at 80% 30%, rgba(255, 235, 180, 0.07) 0, rgba(255, 235, 180, 0.07) 2%, transparent 2.2%),
        radial-gradient(circle at 66% 82%, rgba(255, 235, 180, 0.06) 0, rgba(255, 235, 180, 0.06) 2%, transparent 2.2%);
    opacity: 0.9;
    pointer-events: none;
}

.camp-path {
    position: absolute;
    background: rgba(212, 181, 117, 0.5);
    border: 1px solid rgba(255, 231, 176, 0.15);
    pointer-events: none;
}

.path-horizontal {
    left: 90px;
    top: 170px;
    width: 410px;
    height: 42px;
    border-radius: 10px;
}

.path-vertical {
    left: 280px;
    top: 90px;
    width: 42px;
    height: 220px;
    border-radius: 10px;
}

.camp-zone {
    position: absolute;
    pointer-events: none;
}

.camp-center-zone {
    left: 225px;
    top: 125px;
    width: 150px;
    height: 115px;
    border: 2px dashed rgba(255, 232, 177, 0.2);
    border-radius: 12px;
    background: rgba(255, 225, 150, 0.04);
}

.camp-marker {
    position: absolute;
    pointer-events: none;
}

.marker-tent {
    width: 42px;
    height: 32px;
    background: linear-gradient(to bottom, #a3743d 0%, #845b2e 100%);
    border: 2px solid #c89a62;
    border-bottom-width: 3px;
    clip-path: polygon(50% 0%, 100% 40%, 100% 100%, 0% 100%, 0% 40%);
    opacity: 0.85;
}

.marker-tent-left {
    left: 62px;
    top: 88px;
}

.marker-tent-right {
    right: 72px;
    top: 92px;
}

.marker-stones {
    left: 430px;
    bottom: 58px;
    width: 58px;
    height: 24px;
    background:
        radial-gradient(circle at 10% 70%, #c7b08b 0 14%, transparent 15%),
        radial-gradient(circle at 28% 35%, #b49a73 0 16%, transparent 17%),
        radial-gradient(circle at 48% 72%, #d3bb95 0 14%, transparent 15%),
        radial-gradient(circle at 68% 30%, #bfa57e 0 16%, transparent 17%),
        radial-gradient(circle at 88% 68%, #cfb58e 0 14%, transparent 15%);
    opacity: 0.8;
}

/* WORLD LABELS */
.world-label {
    position: absolute;
    padding: 4px 8px;
    font-size: 12px;
    line-height: 1;
    color: #fff7e6;
    background: rgba(0, 0, 0, 0.55);
    border: 1px solid rgba(255, 230, 180, 0.18);
    border-radius: 6px;
    white-space: nowrap;
    pointer-events: none;
    z-index: 5;
    transform: translateX(-50%);
}

#npc-label {
    left: 130px;
    top: 82px;
}

#water-label {
    left: 472px;
    top: 224px;
    display: none;
}

#supply-label {
    left: 520px;
    top: 110px;
    display: none;
}

/* INTERACTION HIGHLIGHTS */
.interact-highlight {
    position: absolute;
    display: none;
    border-radius: 50%;
    pointer-events: none;
    z-index: 3;
    box-shadow: 0 0 0 2px rgba(255,255,255,0.10);
}

#npc-highlight {
    width: 52px;
    height: 52px;
    left: 104px;
    top: 104px;
    background: radial-gradient(circle, rgba(255, 200, 90, 0.22) 0%, rgba(255, 200, 90, 0.12) 45%, rgba(255, 200, 90, 0.02) 75%, transparent 100%);
}

#water-highlight {
    width: 56px;
    height: 56px;
    left: 444px;
    top: 244px;
    background: radial-gradient(circle, rgba(90, 180, 255, 0.24) 0%, rgba(90, 180, 255, 0.14) 45%, rgba(90, 180, 255, 0.02) 75%, transparent 100%);
}

#supply-highlight {
    width: 56px;
    height: 56px;
    left: 492px;
    top: 116px;
    background: radial-gradient(circle, rgba(255, 215, 120, 0.24) 0%, rgba(255, 215, 120, 0.14) 45%, rgba(255, 215, 120, 0.02) 75%, transparent 100%);
}

/* PLAYER */
#player {
    position: absolute;
    width: 28px;
    height: 28px;
    left: 286px;
    top: 176px;
    background: #00e6c3;
    border: 3px solid #0a6b5f;
    border-radius: 4px;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08);
    z-index: 4;
}

#player::before {
    content: "";
    position: absolute;
    width: 60%;
    height: 24%;
    left: 20%;
    top: 14%;
    background: #08453f;
    border-radius: 2px;
}

#player::after {
    content: "";
    position: absolute;
    width: 30%;
    height: 30%;
    background: #ffffff;
    border-radius: 50%;
}

#player.face-down::after {
    left: 35%;
    top: 60%;
}

#player.face-up::after {
    left: 35%;
    top: 10%;
}

#player.face-left::after {
    left: 10%;
    top: 35%;
}

#player.face-right::after {
    left: 60%;
    top: 35%;
}

/* NPC */
#npc {
    position: absolute;
    width: 28px;
    height: 28px;
    left: 116px;
    top: 116px;
    background: #ffb347;
    border: 3px solid #9a6120;
    border-radius: 4px;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08);
    z-index: 4;
}

#npc::before {
    content: "";
    position: absolute;
    width: 62%;
    height: 24%;
    left: 19%;
    top: 14%;
    background: #6d4013;
    border-radius: 2px;
}

#npc::after {
    content: "";
    position: absolute;
    width: 28%;
    height: 28%;
    left: 36%;
    top: 58%;
    background: #fff0d1;
    border-radius: 50%;
}

/* WATER SOURCE */
#water-source {
    position: absolute;
    width: 30px;
    height: 30px;
    left: 457px;
    top: 257px;
    border: 3px solid #9ed0ff;
    border-radius: 5px;
    background: radial-gradient(circle at 35% 35%, #d8f2ff 0%, #93d6ff 30%, #4da6ff 65%, #2d6bcf 100%);
    box-shadow: inset 0 0 8px rgba(255, 255, 255, 0.18);
    z-index: 4;
}

/* SUPPLY CRATE */
#supply-crate {
    position: absolute;
    width: 30px;
    height: 30px;
    left: 505px;
    top: 129px;
    display: none;
    background: linear-gradient(to bottom, #c69046 0%, #98642d 100%);
    border: 3px solid #6e461d;
    border-radius: 4px;
    box-shadow: inset 0 0 0 2px rgba(255, 225, 170, 0.18);
    z-index: 4;
}

#supply-crate::before,
#supply-crate::after {
    content: "";
    position: absolute;
    background: rgba(90, 55, 20, 0.8);
}

#supply-crate::before {
    left: 50%;
    top: 2px;
    width: 3px;
    height: calc(100% - 4px);
    transform: translateX(-50%);
}

#supply-crate::after {
    left: 2px;
    top: 50%;
    width: calc(100% - 4px);
    height: 3px;
    transform: translateY(-50%);
}

#interaction-hint {
    position: absolute;
    display: none;
    padding: 6px 10px;
    background: rgba(0, 0, 0, 0.85);
    color: #ffffff;
    border: 1px solid #888888;
    font-size: 14px;
    pointer-events: none;
    z-index: 6;
    max-width: 180px;
}

#dialogue-box {
    position: absolute;
    left: 50%;
    bottom: 12px;
    transform: translateX(-50%);
    width: calc(100% - 24px);
    min-height: 140px;
    background: rgba(0, 0, 0, 0.95);
    border: 2px solid #888888;
    padding: 15px;
    display: none;
    text-align: left;
    z-index: 10;
}

#dialogue-name {
    font-weight: bold;
    margin-bottom: 10px;
    color: #ffd27f;
    font-size: 16px;
}

#dialogue-text {
    line-height: 1.5;
    margin-bottom: 15px;
    font-size: 15px;
}

#dialogue-action-btn {
    display: none;
}

#inventory-panel,
#bible-panel {
    position: absolute;
    top: 16px;
    right: 16px;
    width: min(260px, calc(100% - 32px));
    min-height: 220px;
    background: rgba(0, 0, 0, 0.96);
    border: 2px solid #888888;
    padding: 15px;
    display: none;
    text-align: left;
    z-index: 12;
}

#inventory-title,
#bible-title {
    font-size: 20px;
    font-weight: bold;
    margin-bottom: 12px;
    color: #9ed0ff;
}

#inventory-list {
    min-height: 120px;
    margin-bottom: 15px;
}

.inventory-item {
    border: 1px solid #555555;
    padding: 10px;
    margin-bottom: 8px;
    background: #191919;
}

.inventory-item-name {
    font-weight: bold;
    color: #ffd27f;
    margin-bottom: 4px;
    font-size: 16px;
}

.inventory-item-desc {
    font-size: 14px;
    color: #dddddd;
    line-height: 1.4;
}

.inventory-empty {
    color: #bbbbbb;
    font-style: italic;
}

#bible-arc {
    font-weight: bold;
    color: #ffd27f;
    margin-bottom: 10px;
    line-height: 1.4;
}

#bible-reference {
    margin-bottom: 10px;
    color: #9ed0ff;
    line-height: 1.4;
}

#bible-summary {
    line-height: 1.5;
    color: #dddddd;
    margin-bottom: 15px;
    font-size: 14px;
}

#touch-controls {
    width: min(600px, 100%);
    margin: 14px auto 0;
    display: none;
    text-align: left;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

body.show-touch-controls #touch-controls {
    display: block;
}

#touch-controls-title {
    font-size: 14px;
    color: #bdbdbd;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

#touch-controls-inner {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: stretch;
}

#dpad,
#action-buttons {
    flex: 1;
}

#dpad {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 220px;
}

.dpad-middle-row {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: center;
}

.dpad-center {
    width: 56px;
    height: 56px;
}

.touch-btn {
    background: #2b2b2b;
    border: 1px solid #666666;
    color: #ffffff;
    border-radius: 8px;
    margin: 0;
    touch-action: manipulation;
}

.touch-btn:hover {
    background: #3a3a3a;
}

.touch-btn:active,
.touch-btn.pressed {
    background: #5a5a5a;
}

.dpad-btn {
    width: 56px;
    height: 56px;
    padding: 0;
    font-size: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#move-up-btn,
#move-down-btn {
    align-self: center;
}

#action-buttons {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 8px;
    max-width: 260px;
}

.action-btn {
    width: 100%;
    min-height: 48px;
    font-size: 15px;
}

.footer-help {
    width: min(600px, 100%);
    margin: 14px auto 0;
    line-height: 1.5;
    padding: 0 4px;
}

/* Tablet */
@media (max-width: 900px) {
    h1 {
        font-size: 48px;
    }

    .subtitle {
        font-size: 22px;
    }

    #inventory-panel,
    #bible-panel {
        top: 12px;
        right: 12px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* Mobile */
@media (max-width: 640px) {
    .screen {
        padding: 28px 12px 20px;
    }

    h1 {
        font-size: 40px;
    }

    h2 {
        font-size: 22px;
    }

    .subtitle {
        font-size: 20px;
        margin-bottom: 24px;
    }

    button {
        width: 100%;
        max-width: 320px;
        margin: 10px auto 0;
        display: block;
        font-size: 16px;
    }

    #hud {
        width: 100%;
    }

    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .stat-value {
        font-size: 16px;
    }

    #quest-tracker,
    #controls-hint,
    #stats-panel {
        font-size: 14px;
    }

    #game-area {
        min-height: 240px;
    }

    .path-horizontal {
        left: 58px;
        top: 165px;
        width: calc(100% - 116px);
    }

    .path-vertical {
        left: calc(50% - 21px);
        top: 92px;
        height: 190px;
    }

    .camp-center-zone {
        left: calc(50% - 65px);
        width: 130px;
        top: 128px;
        height: 102px;
    }

    .marker-tent-left {
        left: 28px;
        top: 86px;
    }

    .marker-tent-right {
        right: 30px;
        top: 90px;
    }

    .marker-stones {
        left: auto;
        right: 28px;
        bottom: 52px;
    }

    #npc-label {
        top: 84px;
        font-size: 11px;
    }

    #water-label,
    #supply-label {
        font-size: 11px;
    }

    #water-label {
        top: 228px;
    }

    #supply-label {
        top: 116px;
    }

    #dialogue-box {
        min-height: 150px;
        padding: 12px;
    }

    #dialogue-name {
        font-size: 15px;
    }

    #dialogue-text {
        font-size: 14px;
    }

    #inventory-panel,
    #bible-panel {
        left: 50%;
        right: auto;
        top: 12px;
        transform: translateX(-50%);
        width: calc(100% - 24px);
        min-height: 180px;
        padding: 12px;
    }

    #inventory-title,
    #bible-title {
        font-size: 18px;
    }

    .inventory-item-name {
        font-size: 15px;
    }

    .inventory-item-desc,
    #bible-summary,
    #bible-reference,
    #bible-arc {
        font-size: 13px;
    }

    #touch-controls-inner {
        flex-direction: column;
        gap: 10px;
    }

    #dpad,
    #action-buttons {
        max-width: none;
        width: 100%;
    }

    #action-buttons {
        gap: 10px;
    }

    .action-btn {
        max-width: none;
    }

    .footer-help {
        font-size: 14px;
    }
}