:root {
    --ui-font: 'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif;
    --heart-color: #ff3b3b;
    --stamina-color: #55ff55;
}

* {
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
}

body, html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    background-color: #000;
    overflow: hidden;
    position: fixed;
    top: 0;
    left: 0;
    overscroll-behavior: none;
    overscroll-behavior-x: none;
    touch-action: none;
    font-family: var(--ui-font);
}

#gameCanvas, #fgCanvas {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    touch-action: none;
    z-index: 1;
}

#fishingCanvas {
    position: relative;
    display: block;
    width: 600px;
    height: 600px;
    max-width: 92vw;
    max-height: 75vh;
    aspect-ratio: 1 / 1;
    object-fit: contain;
    background-color: #1a1a1a;
    border: 4px solid #555;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.7);
    cursor: crosshair;
    margin: 0 auto;
}

/* UI Layer - Hidden when not playing */
body:not(.is-playing) #ui-layer { display: none; }

#ui-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 20px;
    z-index: 15;
}

/* Hearts & Rupees HUD */
#ui-top-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    width: 100%;
}
#health-container, #inv-health-container {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    max-width: 200px;
}
#rupee-container, #inv-rupee-container {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 20px;
    font-weight: bold;
    color: #55ff55;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
    background: rgba(0,0,0,0.4);
    padding: 4px 12px;
    border-radius: 12px;
    border: 1px solid rgba(85,255,85,0.4);
    letter-spacing: 0;
}
#rupee-count, #inv-rupee-count {
    letter-spacing: 0;
    font-variant-numeric: tabular-nums;
}
#inv-top-bar {
    position: absolute;
    top: 20px;
    left: 20px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    z-index: 5;
    letter-spacing: 0;
}
.hud-audio-btn, .hud-pause-btn, .hud-inventory-btn {
    background: rgba(0,0,0,0.4);
    border: 1px solid rgba(255,255,255,0.4);
    color: white;
    font-size: 18px;
    padding: 4px 10px;
    border-radius: 12px;
    cursor: pointer;
    pointer-events: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.hud-audio-btn.enabled {
    border-color: #55ff55;
    box-shadow: 0 0 8px rgba(85,255,85,0.5);
}
.hud-pause-btn:hover, .hud-inventory-btn:hover {
    background: rgba(255,255,255,0.2);
    border-color: #ffeb7a;
}

/* Circular Day / Night Celestial Dial HUD Widget */
.day-night-widget {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    user-select: none;
    pointer-events: auto;
}
.dial-housing {
    position: relative;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.7), inset 0 0 8px rgba(0, 0, 0, 0.8);
    overflow: hidden;
    background: #0b1021;
    border: 2px solid #d4af37;
}
.dial-sky-window {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    overflow: hidden;
    background: linear-gradient(180deg, #1e90ff 0%, #87ceeb 60%, #b0e0e6 100%);
    transition: background 0.8s ease;
}
.dial-disc {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transform-origin: center center;
    transition: transform 0.1s linear;
}
.dial-celestial {
    position: absolute;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.dial-sun {
    top: 3px;
    left: 50%;
    transform: translateX(-50%);
}
.dial-moon {
    bottom: 3px;
    left: 50%;
    transform: translateX(-50%) rotate(180deg);
}
.dial-horizon-cover {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 52px;
    height: 27px;
    pointer-events: none;
    z-index: 4;
}
.dial-horizon-cover svg {
    width: 100%;
    height: 100%;
    display: block;
}
.dial-bezel-rim {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    box-shadow: inset 0 0 5px rgba(255, 215, 0, 0.6), 0 0 6px rgba(0, 0, 0, 0.7);
    pointer-events: none;
    z-index: 5;
    border: 2px solid #ffd700;
}

/* Fullscreen Sleeping Black Fade Overlay */
.sleep-fade-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #000000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.8s ease-in-out;
    z-index: 99;
}
.sleep-fade-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

#pause-screen {
    color: #00eeff;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px 10px;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}
#inventory-screen {
    color: #ffeb7a;
    justify-content: flex-start;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px 10px 60px 10px;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

/* Modal Tab Bar for toggling Pause and Inventory */
.modal-tab-bar {
    display: flex;
    gap: 12px;
    margin-top: 15px;
    margin-bottom: 10px;
}
.tab-btn {
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid #666;
    color: #bbb;
    padding: 8px 20px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    letter-spacing: 1px;
}
.tab-btn:hover {
    border-color: white;
    color: white;
}
.tab-btn.active {
    background: rgba(255, 235, 122, 0.25);
    border-color: #ffeb7a;
    color: #ffeb7a;
    box-shadow: 0 0 12px rgba(255, 235, 122, 0.4);
}

/* Inventory Layout */
#inventory-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    width: 90%;
    max-width: 520px;
    background: rgba(20, 30, 25, 0.85);
    border: 2px solid #ffeb7a;
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 0 25px rgba(0,0,0,0.8), inset 0 0 15px rgba(255,235,122,0.15);
    box-sizing: border-box;
}

#inventory-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    width: 100%;
    max-height: 280px;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px;
    box-sizing: border-box;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 235, 122, 0.6) rgba(0, 0, 0, 0.3);
}

#inventory-grid::-webkit-scrollbar {
    width: 6px;
}

#inventory-grid::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
}

#inventory-grid::-webkit-scrollbar-thumb {
    background: rgba(255, 235, 122, 0.6);
    border-radius: 4px;
}

#inventory-grid::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 235, 122, 0.9);
}

.inventory-slot {
    position: relative;
    width: 100%;
    min-width: 0;
    aspect-ratio: 1;
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid #555;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    padding: 6px;
    box-sizing: border-box;
}

.inventory-slot:hover, .inventory-slot.selected {
    border-color: #ffeb7a;
    background: rgba(255, 235, 122, 0.15);
    box-shadow: 0 0 12px rgba(255, 235, 122, 0.4);
}

.inventory-slot.empty {
    opacity: 0.35;
    cursor: default;
    border-style: dashed;
}

.item-icon {
    font-size: 28px;
    line-height: 1;
    margin-bottom: 2px;
}

.item-label {
    font-size: 11px;
    font-weight: bold;
    color: #eee;
    text-transform: capitalize;
    letter-spacing: 0;
    text-align: center;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Counter Icon badge in the bottom right corner of item entry */
.item-counter-badge {
    position: absolute;
    bottom: 3px;
    right: 4px;
    background: rgba(0, 0, 0, 0.9);
    border: 1px solid #ffeb7a;
    color: #ffeb7a;
    font-size: 11px;
    font-weight: bold;
    padding: 1px 5px;
    border-radius: 8px;
    letter-spacing: 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.8);
    display: flex;
    align-items: center;
    gap: 2px;
}

#inventory-details {
    width: 100%;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255,235,122,0.4);
    border-radius: 10px;
    padding: 12px 16px;
    text-align: center;
}

#item-detail-title {
    font-size: 18px;
    font-weight: bold;
    color: #ffeb7a;
    margin-bottom: 4px;
    letter-spacing: 1px;
}

#item-detail-desc {
    font-size: 13px;
    color: #ccc;
    font-weight: normal;
    text-transform: none;
    letter-spacing: 0;
    line-height: 1.4;
}

/* Equipped Gear Top Window */
#equipment-window {
    width: 90%;
    max-width: 520px;
    background: rgba(15, 25, 35, 0.9);
    border: 2px solid #00eeff;
    border-radius: 16px;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    box-shadow: 0 0 20px rgba(0, 238, 255, 0.2), inset 0 0 15px rgba(0, 238, 255, 0.1);
}

.equipment-title {
    font-size: 14px;
    font-weight: bold;
    color: #00eeff;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.inventory-section-header {
    font-size: 14px;
    font-weight: bold;
    color: #ffeb7a;
    letter-spacing: 2px;
    margin-bottom: 6px;
    text-transform: uppercase;
    text-shadow: 0 0 8px rgba(255, 235, 122, 0.4);
}

#equipment-slots-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    width: 100%;
}

.equipment-slot {
    position: relative;
    width: 120px;
    height: 64px;
    background: rgba(0, 0, 0, 0.6);
    border: 2px dashed #00eeff;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    padding: 4px;
}

.equipment-slot:hover, .equipment-slot.active {
    border-style: solid;
    border-color: #00eeff;
    background: rgba(0, 238, 255, 0.2);
    box-shadow: 0 0 12px rgba(0, 238, 255, 0.5);
}

.equipment-slot.selecting {
    border-style: solid;
    border-color: #ffeb7a;
    background: rgba(255, 235, 122, 0.25);
    box-shadow: 0 0 16px rgba(255, 235, 122, 0.7);
    animation: selectPulse 1.2s infinite alternate;
}

@keyframes selectPulse {
    from { transform: scale(1); box-shadow: 0 0 10px rgba(255, 235, 122, 0.5); }
    to { transform: scale(1.05); box-shadow: 0 0 20px rgba(255, 235, 122, 0.9); }
}

.inventory-slot.selectable-weapon {
    border-color: #ffeb7a !important;
    box-shadow: 0 0 10px rgba(255, 235, 122, 0.5);
    animation: itemGlow 1.5s infinite alternate;
}

@keyframes itemGlow {
    from { border-color: #ffeb7a; }
    to { border-color: #00eeff; box-shadow: 0 0 14px rgba(0, 238, 255, 0.7); }
}

.inventory-slot.greyed-out {
    opacity: 0.3 !important;
    filter: grayscale(100%);
    pointer-events: none !important;
    border-color: #444 !important;
}

.equipment-slot.empty {
    opacity: 0.6;
    border-color: #555;
}

.equip-slot-label {
    position: absolute;
    top: -8px;
    background: #000;
    color: #00eeff;
    font-size: 9px;
    font-weight: bold;
    padding: 1px 6px;
    border-radius: 6px;
    border: 1px solid #00eeff;
    letter-spacing: 1px;
}

.equip-slot-placeholder {
    font-size: 11px;
    color: #888;
    letter-spacing: 0;
    text-transform: uppercase;
    pointer-events: none;
}

/* Crafting Bench Styling */
#crafting-section {
    width: 100%;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid #ffeb7a;
    border-radius: 12px;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    box-shadow: inset 0 0 12px rgba(255, 235, 122, 0.1);
}

.crafting-title {
    font-size: 14px;
    font-weight: bold;
    color: #ffeb7a;
    letter-spacing: 2px;
    text-transform: uppercase;
}

#crafting-bench-body {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
}

.crafting-slot, .crafting-result-slot {
    position: relative;
    width: 60px;
    height: 60px;
    background: rgba(0, 0, 0, 0.6);
    border: 2px dashed #666;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.crafting-slot:not(.empty) {
    border-style: solid;
    border-color: #ffeb7a;
    background: rgba(255, 235, 122, 0.15);
    box-shadow: 0 0 8px rgba(255, 235, 122, 0.3);
}

.crafting-slot .remove-craft-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    background: #e74c3c;
    color: white;
    font-size: 10px;
    font-weight: bold;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.6);
}

.crafting-result-slot {
    width: 68px;
    height: 68px;
    border-color: #888;
}

.crafting-result-slot.active {
    border-style: solid;
    border-color: #00eeff;
    background: rgba(0, 238, 255, 0.25);
    box-shadow: 0 0 16px rgba(0, 238, 255, 0.6);
    animation: craftGlow 1.5s infinite alternate;
    cursor: pointer;
}

@keyframes craftGlow {
    from { box-shadow: 0 0 10px rgba(0, 238, 255, 0.5); transform: scale(1); }
    to { box-shadow: 0 0 20px rgba(0, 238, 255, 0.9); transform: scale(1.05); }
}

.craft-slot-placeholder {
    font-size: 10px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0;
    pointer-events: none;
}

.crafting-symbol {
    font-size: 20px;
    font-weight: bold;
    color: #ffeb7a;
    letter-spacing: 0;
}
.audio-toggle-btn {
    margin-top: 15px;
    margin-bottom: 15px;
    font-size: 16px;
    padding: 10px 24px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid #888;
    color: #ccc;
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.3s;
}
.audio-toggle-btn:hover {
    border-color: white;
    color: white;
}
.audio-toggle-btn.enabled {
    border-color: #55ff55;
    color: #55ff55;
    background: rgba(0, 50, 0, 0.6);
    box-shadow: 0 0 15px rgba(85, 255, 85, 0.4);
}
.rupee-icon-svg {
    filter: drop-shadow(0 0 5px #00e640);
    display: inline-block;
    vertical-align: middle;
}
.heart {
    width: 24px;
    height: 24px;
    background-color: var(--heart-color);
    clip-path: polygon(50% 100%, 0 45%, 0 15%, 25% 0, 50% 15%, 75% 0, 100% 15%, 100% 45%);
    filter: drop-shadow(2px 2px 0px rgba(0,0,0,0.5));
    transition: transform 0.2s;
}
.heart.empty {
    background-color: #333;
    border: 2px solid #555;
    clip-path: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
}

/* Notifications */
#notification {
    position: fixed;
    top: 20%;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    font-size: 24px;
    text-align: center;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
    opacity: 0;
    transition: opacity 0.5s;
    letter-spacing: 2px;
    z-index: 18;
}

/* Overlay Screens */
.overlay-screen {
    position: fixed;
    overscroll-behavior: contain;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 10px;
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
    transition: opacity 0.5s, visibility 0.5s;
    text-align: center;
    z-index: 20;
}

.overlay-screen.visible {
    opacity: 1;
    pointer-events: auto;
    visibility: visible;
}

.overlay-screen:not(.visible),
.overlay-screen:not(.visible) * {
    pointer-events: none !important;
}

#intro-cutscene {
    background-color: #000;
    transition: background-color 2s ease, opacity 2s ease;
    z-index: 1000; 
}

.cutscene-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 1.8rem;
    font-family: 'Times New Roman', serif;
    letter-spacing: 2px;
    opacity: 0;
    transition: opacity 1.5s ease;
    pointer-events: none;
    text-align: center;
    text-transform: none;
}

.cutscene-text.visible {
    opacity: 1;
}

#title-screen { background: rgba(0, 0, 0, 0.7); }
.game-title {
    font-size: 64px;
    color: #ffeb7a;
    text-shadow: 0 0 20px #ffaa00, 0 0 40px #ff0000;
    margin-bottom: 10px;
    letter-spacing: 15px;
}

@media (max-width: 768px) {
    .game-title { font-size: 40px; letter-spacing: 8px; }
}

#game-over { color: #ff3b3b; }
#victory { color: #ffd700; }

.subtitle {
    font-size: 18px;
    letter-spacing: 2px;
    color: white;
    margin-top: 10px;
    margin-bottom: 40px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
}

.btn {
    padding: 15px 40px;
    background: rgba(0,0,0,0.5);
    border: 2px solid white;
    color: white;
    font-size: 18px;
    font-family: var(--ui-font);
    cursor: pointer;
    letter-spacing: 2px;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.btn:hover, .btn:active, .btn.gamepad-selected {
    background: white;
    color: black;
    box-shadow: 0 0 20px #00eeff, 0 0 10px white;
    transform: scale(1.04);
}

.gamepad-selected, .crafting-slot.selected, .crafting-result-slot.selected {
    box-shadow: 0 0 18px #00eeff, inset 0 0 8px #00eeff !important;
    border-color: #00eeff !important;
    outline: 2px solid #00eeff !important;
    outline-offset: 2px;
    transform: scale(1.05);
    transition: transform 0.15s ease, box-shadow 0.15s ease !important;
    z-index: 10 !important;
}

/* Leaderboard Styles */
.leaderboard {
    margin-top: 30px;
    font-size: 16px;
    color: white;
    background: rgba(0,0,0,0.6);
    padding: 20px;
    border-radius: 8px;
    border: 2px solid #555;
    width: 350px;
    text-align: left;
    text-transform: none;
    letter-spacing: 1px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.8);
}
.leaderboard h3 { 
    margin: 0 0 15px 0; 
    text-align: center; 
    color: #00eeff; 
    letter-spacing: 4px; 
    text-transform: uppercase;
}
.lb-entry { 
    display: flex; 
    justify-content: space-between; 
    margin-bottom: 8px; 
    font-family: monospace;
    font-size: 18px;
}
.lb-entry span:nth-child(2) { color: #ffeb7a; } /* Time */
.lb-entry span:nth-child(3) { color: #aaa; font-size: 14px; } /* Date */

#leaderboard-input-section {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    margin-bottom: 30px;
    text-transform: none;
    letter-spacing: 1px;
}
#initials-input {
    font-size: 24px;
    width: 80px;
    text-align: center;
    text-transform: uppercase;
    padding: 5px;
    font-family: var(--ui-font);
    border: 2px solid #00eeff;
    background: #222;
    color: white;
    outline: none;
}

/* Mobile Controls */
#mobile-controls {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 40%;
    pointer-events: none;
    z-index: 16;
    touch-action: none;
}

.joystick-zone {
    position: absolute;
    bottom: 20px;
    left: 20px;
    width: 150px;
    height: 150px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    pointer-events: auto;
}

.joystick-knob {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 60px;
    height: 60px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.action-buttons {
    position: absolute;
    bottom: 20px;
    right: 20px;
    display: flex;
    align-items: flex-end;
    gap: 15px;
    pointer-events: auto;
}

.action-btn-col {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
}

.action-btn {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.4);
    border: 2px solid rgba(255, 255, 255, 0.5);
    color: white;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

.action-btn:active {
    background: rgba(255, 255, 255, 0.4);
}

#btn-special {
    background: rgba(70, 45, 0, 0.55);
    border-color: #ffd700;
    color: #ffeb7a;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.35), 0 4px 6px rgba(0,0,0,0.3);
}

#btn-special:active {
    background: rgba(255, 215, 0, 0.4);
}

@media (max-width: 768px) {
    body.is-playing #mobile-controls,
    body.is-fishing #mobile-controls {
        display: block;
    }
    body.is-fishing #mobile-controls {
        z-index: 25 !important;
    }
    body.is-fishing #btn-dash {
        display: none;
    }
    #ui-layer { padding: 10px; }
    #ui-top-bar, #inv-top-bar { gap: 8px; }
    #inv-top-bar {
        position: relative;
        top: auto;
        left: auto;
        align-self: flex-start;
        margin-bottom: 5px;
    }
    #rupee-container, #inv-rupee-container { font-size: 16px; padding: 3px 8px; }
    .hud-audio-btn, .hud-pause-btn, .hud-inventory-btn { font-size: 16px; padding: 5px 10px; }
    #inventory-container {
        width: 96%;
        padding: 15px 10px;
        gap: 12px;
    }
    #inventory-grid {
        gap: 8px;
        max-height: 240px;
        padding: 12px;
    }
    .inventory-slot {
        padding: 4px;
        border-radius: 8px;
    }
    .item-icon {
        font-size: 22px;
    }
    .item-label {
        font-size: 9px;
    }
}

#instructions {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255,255,255,0.7);
    font-size: 14px;
    text-align: center;
    pointer-events: none;
    background: rgba(0,0,0,0.5);
    padding: 5px 15px;
    border-radius: 10px;
    z-index: 18;
}
@media (max-width: 768px) {
    #instructions { display: none; }
}

/* --- Link Character Base --- */
#link {
  position: fixed;
  width: 50px;
  height: 50px;
  transform: translate(-50%, -50%) scale(0.7);
  transform-origin: center center;
  z-index: 5; 
  pointer-events: none;
  display: none;
}

body.is-playing #link {
  display: block;
}

/* --- Drop Shadow --- */
#shadow {
  position: absolute;
  width: 36px;
  height: 12px;
  background-color: rgba(0, 0, 0, 0.25);
  border-radius: 50%;
  bottom: -6px; 
  left: 50%;
  transform: translateX(-50%);
  z-index: 0; 
}

/* --- The 3D Head Mask --- */
#head {
  width: 50px;
  height: 50px;
  background-color: #f1c40f; 
  border: 3px solid #333;
  border-radius: 50%;
  position: absolute;
  z-index: 1;
  box-sizing: border-box;
  overflow: hidden; 
  box-shadow: inset -5px -5px 10px rgba(0, 0, 0, 0.2);
}

#face-skin {
  width: 46px;
  height: 46px;
  background-color: #ffdbac;
  border-radius: 50%;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

#hair-front {
  width: 40px;
  height: 18px;
  background-color: #f1c40f; 
  border-radius: 20px 20px 0 0;
  position: absolute;
  left: 50%;
  top: -2px;
  transform: translateX(-50%);
}

.eye {
  width: 6px;
  height: 8px;
  background-color: #111;
  border-radius: 50%;
  position: absolute;
  top: 22px;
  transition: all 0.1s ease;
}
.eye.closed {
  height: 2px;
  top: 25px;
  border-radius: 0;
  background-color: #333;
}
#left-eye { left: 12px; }
#right-eye { right: 12px; }

/* --- The Cap (SVG) --- */
#hat-cap {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 3; 
  overflow: visible;
}

/* --- The Floppy Hat Container --- */
#hat-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none; 
  z-index: 4; 
  display: none;
}

body.is-playing #hat-container {
  display: block;
}

.hat-node {
  position: absolute;
  background-color: #2ecc71;
  border-radius: 50%;
}

/* --- Foreground Canvas Layer for Depth Sorting --- */
#fgCanvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 12;
}

/* --- Crafting Knowledge Book Screen --- */
#knowledge-screen {
    color: #f5f5dc;
    justify-content: flex-start;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px 10px 60px 10px;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

#cy-knowledge {
    width: 92%;
    max-width: 1000px;
    height: 52vh;
    min-height: 380px;
    border: 3px solid #8A2BE2;
    border-radius: 16px;
    background: #0e0e11;
    margin: 10px auto;
    box-shadow: 0 0 25px rgba(138, 43, 226, 0.4), inset 0 0 20px rgba(0,0,0,0.8);
    position: relative;
    overflow: hidden;
    text-align: left;
    display: block;
    cursor: grab;
}

#cy-knowledge canvas {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    display: block !important;
}

#cy-knowledge:active {
    cursor: grabbing;
}
