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

body {
    font-family: 'Courier New', monospace;
    background: linear-gradient(135deg, #A8E6CF, #FFB3BA);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

#game-container {
    position: relative;
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    overflow: hidden;
}

#game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #B8B8FF;
    padding: 10px 20px;
    color: #333;
}

#player-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

#player-avatar {
    width: 32px;
    height: 32px;
    background: #FDBCB4;
    border-radius: 50%;
    border: 2px solid #333;
}

#player-name {
    font-weight: bold;
    font-size: 16px;
}

#time-weather {
    display: flex;
    align-items: center;
    gap: 15px;
}

#game-time {
    background: rgba(255,255,255,0.3);
    padding: 5px 10px;
    border-radius: 15px;
}

#weather-display {
    font-size: 24px;
}

#canvas {
    display: block;
    background: #A8E6CF;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

/* Virtual D-Pad Styles */
.dpad-container {
    position: absolute;
    bottom: 80px;
    left: 20px;
    width: 120px;
    height: 120px;
    opacity: 0.3;
    transition: opacity 0.3s ease;
    z-index: 100;
}

.dpad-container:hover,
.dpad-container.active {
    opacity: 0.8;
}

.dpad-container.bottom-left {
    bottom: 80px;
    left: 20px;
}

.dpad-container.bottom-right {
    bottom: 80px;
    right: 20px;
}

.dpad-container.top-left {
    top: 80px;
    left: 20px;
}

.dpad-container.top-right {
    top: 80px;
    right: 20px;
}

.dpad-container.small {
    width: 90px;
    height: 90px;
}

.dpad-container.medium {
    width: 120px;
    height: 120px;
}

.dpad-container.large {
    width: 150px;
    height: 150px;
}

#virtual-dpad {
    position: relative;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(255,255,255,0.9), rgba(200,200,200,0.7));
    border-radius: 50%;
    border: 3px solid #333;
    display: grid;
    grid-template-areas: 
        ". up ."
        "left center right"
        ". down .";
    grid-template-rows: 1fr 1fr 1fr;
    grid-template-columns: 1fr 1fr 1fr;
}

.dpad-button {
    border: 2px solid #333;
    background: rgba(255,255,255,0.8);
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #333;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

#dpad-up {
    grid-area: up;
    border-radius: 15px 15px 5px 5px;
    border-bottom: none;
}

#dpad-down {
    grid-area: down;
    border-radius: 5px 5px 15px 15px;
    border-top: none;
}

#dpad-left {
    grid-area: left;
    border-radius: 15px 5px 5px 15px;
    border-right: none;
}

#dpad-right {
    grid-area: right;
    border-radius: 5px 15px 15px 5px;
    border-left: none;
}

#dpad-center {
    grid-area: center;
    border-radius: 50%;
    background: rgba(255,200,200,0.8);
    font-size: 14px;
}

.dpad-button:hover,
.dpad-button:active,
.dpad-button.pressed {
    background: #FFD700;
    transform: scale(0.95);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
}

/* Interaction Button */
#interaction-button {
    position: absolute;
    bottom: 100px;
    right: 30px;
    z-index: 100;
}

#interact-btn {
    width: 60px;
    height: 60px;
    border: 3px solid #333;
    border-radius: 50%;
    background: rgba(255,255,255,0.9);
    font-size: 24px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

#interact-btn:hover {
    background: #FFD700;
    transform: scale(1.1);
}

#bottom-hud {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #FFB3BA;
    padding: 15px 20px;
}

#inventory-bar {
    display: flex;
    gap: 8px;
}

.inventory-slot {
    width: 40px;
    height: 40px;
    background: rgba(255,255,255,0.7);
    border: 2px solid #333;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.inventory-slot:hover {
    background: rgba(255,255,255,0.9);
    transform: translateY(-2px);
}

#tool-wheel {
    display: flex;
    gap: 10px;
}

.tool-btn {
    width: 45px;
    height: 45px;
    border: none;
    border-radius: 50%;
    background: rgba(255,255,255,0.8);
    font-size: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.tool-btn:hover, .tool-btn.selected {
    background: #FFD700;
    transform: scale(1.1);
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

#menu-btn {
    width: 50px;
    height: 50px;
    border: none;
    border-radius: 8px;
    background: #B8B8FF;
    color: white;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
}

#menu-btn:hover {
    background: #9999FF;
    transform: scale(1.05);
}

/* Modal Styles */
.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;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 1000;
}

.modal.visible {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: linear-gradient(135deg, #FFB3BA, #B8B8FF);
    padding: 30px;
    border-radius: 20px;
    max-width: 500px;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0,0,0,0.3);
}

.modal-content h2 {
    color: #333;
    margin-bottom: 20px;
    font-size: 28px;
}

#character-preview {
    margin: 20px 0;
    display: flex;
    justify-content: center;
}

#preview-canvas {
    border: 3px solid #333;
    border-radius: 15px;
    background: #A8E6CF;
    image-rendering: pixelated;
}

.customization-panel {
    text-align: left;
    margin: 20px 0;
}

.option-group {
    margin: 15px 0;
}

.option-group label {
    display: block;
    font-weight: bold;
    margin-bottom: 8px;
    color: #333;
}

.hair-styles {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.hair-style {
    padding: 8px 15px;
    border: 2px solid #333;
    background: rgba(255,255,255,0.8);
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
}

.hair-style:hover, .hair-style.selected {
    background: #FFD700;
    transform: scale(1.05);
}

.color-picker {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.color-option {
    width: 35px;
    height: 35px;
    border: 3px solid #333;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
}

.color-option:hover {
    transform: scale(1.1);
    box-shadow: 0 0 10px rgba(0,0,0,0.3);
}

.color-option.selected {
    border-width: 4px;
    border-color: #FFD700;
}

.pastel-btn {
    background: linear-gradient(135deg, #FFD700, #FFA500);
    border: none;
    padding: 15px 30px;
    font-size: 18px;
    font-weight: bold;
    color: white;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.2);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    margin-top: 20px;
}

.pastel-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 7px 20px rgba(0,0,0,0.3);
    background: linear-gradient(135deg, #FFED4E, #FF8C00);
}

/* Enhanced Dialogue System */
#dialogue-box {
    position: absolute;
    bottom: 150px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255,255,255,0.95);
    border: 3px solid #333;
    border-radius: 20px;
    padding: 20px;
    max-width: 450px;
    min-width: 350px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    transition: all 0.3s ease;
}

#dialogue-box.hidden {
    opacity: 0;
    visibility: hidden;
    transform: translateX(-50%) translateY(20px);
}

.dialogue-content {
    display: flex;
    align-items: flex-start;
    gap: 15px;
}

#villager-portrait {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #DDA0DD;
    border: 3px solid #333;
    flex-shrink: 0;
}

.dialogue-text-area {
    flex: 1;
}

#speaker-name {
    font-weight: bold;
    font-size: 14px;
    color: #666;
    margin-bottom: 5px;
}

#dialogue-text {
    font-size: 16px;
    line-height: 1.4;
    color: #333;
}

#dialogue-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 15px;
}

.dialogue-option {
    background: #B8B8FF;
    border: 2px solid #333;
    border-radius: 15px;
    padding: 8px 15px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #333;
    font-size: 14px;
}

.dialogue-option:hover {
    background: #9999FF;
    transform: translateY(-1px);
}

/* Activity Panel */
#activity-panel {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255,255,255,0.95);
    border: 3px solid #333;
    border-radius: 20px;
    padding: 30px;
    text-align: center;
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
    min-width: 300px;
}

#activity-panel.hidden {
    display: none;
}

#activity-title {
    font-size: 24px;
    color: #333;
    margin-bottom: 20px;
}

#fishing-game {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

#casting-meter {
    position: relative;
    width: 200px;
    height: 20px;
    background: #ddd;
    border: 2px solid #333;
    border-radius: 10px;
    overflow: hidden;
}

#power-bar {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, #00ff00, #ffff00, #ff0000);
    opacity: 0.3;
}

#power-indicator {
    position: absolute;
    left: 0;
    top: -2px;
    width: 4px;
    height: 24px;
    background: #333;
    border-radius: 2px;
    transition: left 0.1s ease;
}

#cast-button {
    background: #4CAF50;
    border: none;
    padding: 12px 25px;
    font-size: 16px;
    color: white;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 3px 10px rgba(0,0,0,0.2);
}

#cast-button:hover {
    background: #45a049;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

/* Village Map */
#village-map {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255,255,255,0.95);
    border: 3px solid #333;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
    min-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
}

#village-map.hidden {
    display: none;
}

.map-content h3 {
    text-align: center;
    margin-bottom: 20px;
    font-size: 24px;
    color: #333;
}

#map-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-bottom: 20px;
}

.map-location {
    background: rgba(168, 230, 207, 0.3);
    border: 2px solid #333;
    border-radius: 15px;
    padding: 15px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.map-location:hover {
    background: rgba(168, 230, 207, 0.6);
    transform: translateY(-2px);
}

.map-location.special-npc {
    background: rgba(255, 179, 186, 0.3);
}

.map-location.special-npc:hover {
    background: rgba(255, 179, 186, 0.6);
}

.location-icon {
    font-size: 24px;
    margin-bottom: 5px;
}

.map-location span {
    display: block;
    font-size: 14px;
    font-weight: bold;
    color: #333;
}

#close-map {
    background: #FF6B6B;
    border: none;
    padding: 10px 20px;
    color: white;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: block;
    margin: 0 auto;
}

#close-map:hover {
    background: #FF5252;
    transform: translateY(-1px);
}

/* Settings Panel */
#settings-panel {
    position: absolute;
    top: 50%;
    right: 20px;
    transform: translateY(-50%);
    background: rgba(255,255,255,0.95);
    border: 3px solid #333;
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
    min-width: 250px;
}

#settings-panel.hidden {
    display: none;
}

.settings-content h3 {
    text-align: center;
    margin-bottom: 20px;
    color: #333;
}

.setting-group {
    margin: 15px 0;
}

.setting-group label {
    display: block;
    font-weight: bold;
    margin-bottom: 5px;
    color: #333;
}

.setting-group select,
.setting-group input {
    width: 100%;
    padding: 8px;
    border: 2px solid #333;
    border-radius: 8px;
    font-size: 14px;
}

#close-settings {
    background: #B8B8FF;
    border: none;
    padding: 10px 20px;
    color: white;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: block;
    margin: 20px auto 0;
}

#close-settings:hover {
    background: #9999FF;
    transform: translateY(-1px);
}

/* Notifications */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(255,255,255,0.95);
    border: 2px solid #333;
    border-radius: 15px;
    padding: 15px 20px;
    font-weight: bold;
    color: #333;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    animation: slideIn 0.3s ease;
    z-index: 1001;
}

.notification.fade-out {
    animation: fadeOut 0.5s ease forwards;
}

@keyframes slideIn {
    from {
        transform: translateX(300px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes fadeOut {
    to {
        opacity: 0;
        transform: translateY(-20px);
    }
}

/* Responsive Design */
@media (max-width: 900px) {
    #game-container {
        margin: 10px;
        border-radius: 15px;
    }
    
    #canvas {
        width: 100%;
        max-width: 800px;
        height: auto;
    }
    
    #bottom-hud {
        flex-direction: column;
        gap: 15px;
        padding: 10px;
    }
    
    .modal-content {
        margin: 20px;
        padding: 20px;
        max-width: 90%;
    }
    
    #dialogue-box {
        left: 10px;
        right: 10px;
        transform: none;
        max-width: none;
    }
    
    #dialogue-box.hidden {
        transform: translateY(20px);
    }
    
    #settings-panel {
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        right: auto;
    }
    
    .dpad-container {
        bottom: 20px;
        left: 10px;
    }
    
    #interaction-button {
        bottom: 30px;
        right: 10px;
    }
    
    #map-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .hair-styles, .color-picker {
        justify-content: center;
    }
    
    .inventory-slot {
        width: 35px;
        height: 35px;
    }
    
    .tool-btn {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
    
    #game-header {
        padding: 8px 15px;
        font-size: 14px;
    }
    
    #player-name {
        font-size: 14px;
    }
    
    .dpad-container.medium {
        width: 100px;
        height: 100px;
    }
    
    .dpad-container.large {
        width: 120px;
        height: 120px;
    }
    
    #interact-btn {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }
    
    #map-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .map-location {
        padding: 10px;
    }
}

/* Touch device optimizations */
@media (hover: none) {
    .dpad-container {
        opacity: 0.6;
    }
    
    .dpad-button:active {
        background: #FFD700;
        transform: scale(0.95);
    }
    
    #interact-btn:active {
        background: #FFD700;
        transform: scale(0.95);
    }
}

/* Hide elements for different screen orientations */
@media (orientation: landscape) and (max-height: 500px) {
    #game-header {
        padding: 5px 15px;
    }
    
    #bottom-hud {
        padding: 8px 15px;
    }
    
    .dpad-container {
        bottom: 10px;
        left: 10px;
    }
}