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

:root {
    --primary-color: #2c3e50;
    --secondary-color: #8e44ad;
    --accent-color: #e74c3c;
    --text-color: #ecf0f1;
    --dark-bg: #0a0b10;
    --panel-bg: rgba(30, 40, 55, 0.88);
    --modal-bg: rgba(18, 24, 34, 0.97);
    --border-color: #3a8ac0;
    --gold-color: #d4a030;
}

body {
    font-family: 'Arial', sans-serif;
    background-color: var(--dark-bg);
    color: var(--text-color);
    overflow: hidden;
    width: 100vw;
    height: 100vh;
}

.hidden {
    display: none !important;
}

button {
    cursor: pointer;
    border: 1px solid transparent;
    outline: none;
    background-color: var(--primary-color);
    color: var(--text-color);
    padding: 10px 20px;
    border-radius: 4px;
    font-size: 16px;
    transition: background-color 0.2s, border-color 0.2s, box-shadow 0.2s;
    letter-spacing: 0.03em;
}

button:hover {
    background-color: #357db3;
    border-color: rgba(74, 169, 240, 0.5);
    box-shadow: 0 0 8px rgba(74, 169, 240, 0.3);
}

button.primary {
    background-color: var(--accent-color);
}

button.primary:hover {
    background-color: #d84030;
    box-shadow: 0 0 10px rgba(231, 76, 60, 0.45);
}

/* ── Loading Screen ─────────────────────────────── */
@keyframes pulse-logo {
    0%, 100% { opacity: 1;   filter: drop-shadow(0 0 6px rgba(142,68,173,0.6)); }
    50%       { opacity: 0.8; filter: drop-shadow(0 0 18px rgba(142,68,173,1)); }
}

@keyframes shimmer {
    0%   { background-position: -200% center; }
    100% { background-position:  200% center; }
}

#loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at center, #12141e 0%, #0a0b10 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.5s;
}

#loading-screen.active {
    opacity: 1;
}

.logo-container {
    width: 60%;
    max-width: 600px;
    margin-bottom: 50px;
    animation: pulse-logo 2.4s ease-in-out infinite;
}

#game-logo {
    width: 100%;
    height: auto;
}

.loading-bar {
    width: 50%;
    max-width: 500px;
    height: 6px;
    background-color: rgba(26, 53, 69, 0.8);
    border-radius: 3px;
    overflow: hidden;
    border: 1px solid rgba(58, 138, 192, 0.4);
}

.loading-progress {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg,
        var(--secondary-color) 0%,
        #c084f0 40%,
        var(--secondary-color) 100%);
    background-size: 200% auto;
    border-radius: 3px;
    transition: width 0.3s ease-in-out;
    animation: shimmer 1.6s linear infinite;
}

/* ── Splash Screen ──────────────────────────────── */
@keyframes title-glow {
    0%, 100% { text-shadow: 0 0 8px rgba(74,169,166,0.5),  0 0 20px rgba(74,169,166,0.2); }
    50%       { text-shadow: 0 0 16px rgba(74,169,166,0.9), 0 0 40px rgba(74,169,166,0.5), 0 0 60px rgba(142,68,173,0.3); }
}

#splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(ellipse at 50% 30%, rgba(142,68,173,0.12) 0%, transparent 60%),
        linear-gradient(160deg, #080c14 0%, #101828 50%, #0e1420 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 900;
}

/* Subtle grid overlay on splash */
#splash-screen::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(58,138,192,0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(58,138,192,0.05) 1px, transparent 1px);
    background-size: 48px 48px;
    pointer-events: none;
}

.splash-container {
    text-align: center;
    position: relative;
    z-index: 1;
}

.splash-container h1 {
    font-size: 52px;
    margin-bottom: 48px;
    letter-spacing: 0.06em;
    color: var(--text-color);
    animation: title-glow 3s ease-in-out infinite;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 16px;
    align-items: center;
}

.menu-btn {
    width: 220px;
    padding: 14px 20px;
    font-size: 17px;
    border: 1px solid rgba(58,138,192,0.35);
    background: linear-gradient(145deg, rgba(44,62,80,0.9), rgba(30,45,60,0.95));
    letter-spacing: 0.04em;
    border-radius: 5px;
    transition: background 0.2s, border-color 0.2s, box-shadow 0.2s, transform 0.1s;
}

.menu-btn:hover {
    background: linear-gradient(145deg, rgba(53,125,179,0.85), rgba(44,80,110,0.9));
    border-color: rgba(74,169,240,0.65);
    box-shadow: 0 0 14px rgba(74,169,240,0.35);
    transform: translateY(-1px);
}

.menu-btn:active {
    transform: translateY(0);
}

/* Character Creation, Load Game, and Options Screens */
.screen-container {
    background-color: var(--panel-bg);
    border-radius: 8px;
    padding: 30px;
    max-width: 800px;
    width: 90%;
    margin: 0 auto;
}

.screen-container h2 {
    margin-bottom: 30px;
    text-align: center;
}

.character-creation {
    display: flex;
    gap: 30px;
    margin-bottom: 30px;
}

.character-preview {
    flex: 1;
    min-height: 300px;
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.character-options {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.option-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.option-group label {
    font-weight: bold;
}

.option-group input[type="text"] {
    padding: 8px;
    background-color: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-color);
}

.creation-actions, .load-actions, .options-actions {
    display: flex;
    justify-content: space-between;
    margin-top: 20px;
}

/* Options controls */
.options-controls {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 30px;
}

.option-slider, .option-toggle {
    display: flex;
    align-items: center;
    gap: 15px;
}

.option-slider input[type="range"] {
    flex-grow: 1;
}

/* Game Container */
#game-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

#game-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* UI Elements */
#ui-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
}

.ui-panel {
    position: absolute;
    background-color: var(--panel-bg);
    border: 1px solid rgba(58, 138, 192, 0.5);
    border-radius: 6px;
    padding: 10px;
    pointer-events: auto;
    backdrop-filter: blur(4px);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
}

#player-stats {
    top: 20px;
    left: 20px;
    width: 210px;
}

.health-bar, .energy-bar {
    height: 16px;
    background-color: rgba(0, 0, 0, 0.45);
    border-radius: 8px;
    margin-bottom: 8px;
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.health-value, .energy-value {
    height: 100%;
    width: 70%;
    background: linear-gradient(90deg, #b02020 0%, #e74c3c 60%, #f08070 100%);
    border-radius: 8px;
    transition: width 0.25s ease;
}

.energy-value {
    background: linear-gradient(90deg, #1a60a8 0%, #3498db 60%, #70c8f0 100%);
}

.health-label, .energy-label {
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 11px;
    font-weight: bold;
    text-shadow: 0 0 3px #000, 0 0 6px #000;
    letter-spacing: 0.04em;
    z-index: 1;
}

#mini-map {
    top: 20px;
    right: 20px;
    width: 180px;
    height: 180px;
    border-radius: 8px;
    overflow: hidden;
}

#action-bar {
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 8px;
}

#time-display {
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-radius: 20px;
}

.day-cycle {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: radial-gradient(circle at 40% 40%, #ffe060, #e8a010);
    border: 2px solid rgba(255, 255, 255, 0.6);
    box-shadow: 0 0 8px rgba(255, 200, 0, 0.4);
}

.time-text {
    font-size: 16px;
    font-weight: bold;
    letter-spacing: 0.06em;
}

.season-indicator {
    width: 22px;
    height: 22px;
    border-radius: 50%;
}

#notification-area {
    position: absolute;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    width: 80%;
    max-width: 600px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    pointer-events: none;
}

/* ── Notification toast ─────────────────────────── */
.notification {
    background: rgba(18, 24, 34, 0.92);
    border: 1px solid rgba(58, 138, 192, 0.5);
    border-radius: 6px;
    padding: 8px 18px;
    font-size: 14px;
    color: var(--text-color);
    box-shadow: 0 2px 10px rgba(0,0,0,0.4);
    animation: fadeInDown 0.3s ease;
}

@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Modal Interfaces */
.game-modal {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: var(--modal-bg);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    z-index: 10;
    pointer-events: auto;
    min-width: 300px;
    max-width: 90%;
    max-height: 90vh;
    overflow: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
}

.close-modal-btn {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-color);
    cursor: pointer;
    padding: 0 5px;
}

.modal-content {
    padding: 20px;
}

/* Inventory Modal */
.inventory-container {
    display: flex;
    gap: 20px;
}

.equipment-slots {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.inventory-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
}

.inventory-slot, .equipment-slot {
    width: 60px;
    height: 60px;
    background-color: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

.character-stats {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

/* Dialogue Modal */
#dialogue-modal .modal-content {
    display: flex;
    gap: 20px;
}

.npc-portrait {
    width: 100px;
    height: 100px;
    background-color: rgba(0, 0, 0, 0.3);
    border-radius: 50%;
    flex-shrink: 0;
}

.dialogue-content {
    flex-grow: 1;
}

.npc-name {
    font-weight: bold;
    font-size: 18px;
    margin-bottom: 10px;
}

.dialogue-text {
    margin-bottom: 20px;
    line-height: 1.5;
}

.dialogue-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Trading Modal */
.trading-container {
    display: flex;
    gap: 20px;
}

.trading-section {
    flex: 1;
}

.trading-section h4 {
    margin-bottom: 10px;
}

.trading-controls {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 20px;
}

.trade-values {
    text-align: center;
}

/* Sky gradient for cyberpunk feel */
.renderBackground {
    background: linear-gradient(to bottom, #0a0b1e 0%, #3b1e3f 50%, #5e1b35 100%);
}

/* Developer Tools */
#dev-tools {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: var(--panel-bg);
    border-top: 2px solid var(--border-color);
    z-index: 100;
    pointer-events: auto;
    height: 300px;
    display: flex;
    flex-direction: column;
}

.dev-tools-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    border-bottom: 1px solid var(--border-color);
}

.dev-tools-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
}

.dev-tab-btn {
    padding: 10px 20px;
    background: none;
    border: none;
    color: var(--text-color);
    border-right: 1px solid var(--border-color);
}

.dev-tab-btn.active {
    background-color: rgba(74, 169, 166, 0.3);
}

.dev-tools-content {
    flex-grow: 1;
    overflow: auto;
    padding: 10px;
}

.dev-tab-content {
    display: none;
    height: 100%;
}

.dev-tab-content.active {
    display: flex;
}

#entity-inspector {
    display: flex;
    gap: 20px;
}

.entity-list {
    width: 30%;
    overflow: auto;
    border-right: 1px solid var(--border-color);
    padding-right: 10px;
}

.entity-details {
    flex-grow: 1;
    overflow: auto;
}