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

body {
    background: #1a1a2e;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    width: 100vw;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    overflow: hidden;
}

#game-container {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#game-canvas {
    display: block;
    cursor: default;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

#chat-panel {
    display: none;
    position: absolute;
    right: 10px;
    top: 10px;
    width: 310px;
    max-height: calc(100% - 20px);
    height: 600px;
    background: #2c2c3a;
    border: 2px solid #444;
    border-radius: 8px;
    flex-direction: column;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.4);
    z-index: 100;
}

#chat-panel.active {
    display: flex;
}

#chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #3a3a4a;
    border-radius: 6px 6px 0 0;
    border-bottom: 1px solid #555;
}

#chat-npc-name {
    color: #5ce0d8;
    font-weight: bold;
    font-size: 16px;
}

#chat-close {
    background: none;
    border: none;
    color: #aaa;
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s;
}

#chat-close:hover {
    background: #e94560;
    color: white;
}

#chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

#chat-messages::-webkit-scrollbar {
    width: 6px;
}

#chat-messages::-webkit-scrollbar-track {
    background: #2c2c3a;
}

#chat-messages::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 3px;
}

.message {
    padding: 8px 12px;
    border-radius: 12px;
    max-width: 85%;
    word-wrap: break-word;
    font-size: 14px;
    line-height: 1.4;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

.message.player {
    background: #4a6fa5;
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.message.npc {
    background: #3a3a4a;
    color: #e0e0e0;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.message.system {
    background: transparent;
    color: #888;
    align-self: center;
    font-style: italic;
    font-size: 12px;
}

#chat-input-area {
    display: flex;
    padding: 12px;
    gap: 8px;
    border-top: 1px solid #444;
}

#chat-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #555;
    border-radius: 20px;
    background: #1a1a2e;
    color: white;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

#chat-input:focus {
    border-color: #5ce0d8;
}

#chat-send {
    padding: 10px 16px;
    background: #5ce0d8;
    color: #1a1a2e;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: background 0.2s;
}

#chat-send:hover {
    background: #4bc8c0;
}

#instructions {
    margin-top: 12px;
    color: #888;
    font-size: 13px;
    text-align: center;
}

#instructions strong {
    color: #5ce0d8;
}

/* Intro Screen - overlay on top of game */
#intro-screen {
    position: fixed;
    top: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    width: 100vw;
    background: rgba(10, 10, 20, 0.85);
    backdrop-filter: blur(2px);
    gap: 4px;
    padding: 20px;
    z-index: 1000;
}

#intro-logo {
    max-width: 400px;
    width: 80%;
    image-rendering: pixelated;
    clip-path: inset(0 0 30% 0);
    margin-bottom: -60px;
}

#intro-text {
    color: #aab;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    text-align: center;
    line-height: 1.6;
    max-width: 500px;
    margin-top: 2px;
    margin-bottom: 28px;
}

#intro-start {
    margin-top: 16px;
    padding: 14px 48px;
    background: #161D26;
    color: #0578FF;
    border: 3px solid #0578FF;
    font-family: 'Courier New', monospace;
    font-size: 20px;
    font-weight: bold;
    letter-spacing: 4px;
    cursor: pointer;
    image-rendering: pixelated;
    transition: all 0.2s;
}

#intro-start:hover {
    background: #0578FF;
    color: #161D26;
}

#intro-footer {
    color: #bbb;
    font-family: 'Courier New', monospace;
    font-size: 11px;
    position: absolute;
    bottom: 20px;
}

#intro-footer strong {
    color: #ddd;
}


/* Name prompt */
#name-prompt {
    position: fixed;
    top: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    width: 100vw;
    background: rgba(10, 10, 20, 0.9);
    gap: 14px;
    z-index: 1001;
}

#name-prompt-text {
    color: #ccc;
    font-family: 'Courier New', monospace;
    font-size: 16px;
}

#name-input {
    padding: 10px 20px;
    border: 2px solid #0578FF;
    border-radius: 4px;
    background: #161D26;
    color: #fff;
    font-family: 'Courier New', monospace;
    font-size: 16px;
    text-align: center;
    outline: none;
    width: 200px;
}

#name-confirm {
    padding: 10px 36px;
    background: #161D26;
    color: #0578FF;
    border: 2px solid #0578FF;
    font-family: 'Courier New', monospace;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    letter-spacing: 2px;
}

#name-confirm:hover {
    background: #0578FF;
    color: #161D26;
}
