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

:root {
    --bg-dark: #0a0a0f;
    --bg-card: #12121a;
    --bg-input: #1a1a25;
    --text-primary: #e0d8c8;
    --text-dim: #7a7568;
    --accent: #c4a35a;
    --accent-glow: #c4a35a44;
    --danger: #8b2020;
    --hp-bar: #8b2020;
    --hp-bar-bg: #2a1515;
    --border: #2a2a35;
}

body {
    background: var(--bg-dark);
    color: var(--text-primary);
    font-family: 'Georgia', 'Times New Roman', serif;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    -webkit-user-select: none;
    user-select: none;
}

/* === TOP BAR === */
#top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    z-index: 10;
    cursor: pointer;
}

#hp-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

#hp-icon {
    font-size: 18px;
    filter: drop-shadow(0 0 4px var(--danger));
}

#hp-bar-outer {
    width: 120px;
    height: 12px;
    background: var(--hp-bar-bg);
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--danger);
}

#hp-bar-inner {
    width: 100%;
    height: 100%;
    background: var(--hp-bar);
    border-radius: 6px;
    transition: width 0.5s ease, background 0.3s ease;
    box-shadow: 0 0 8px var(--danger);
}

#hp-bar-inner.low {
    background: #cc3333;
    animation: pulse-hp 1s infinite;
}

@keyframes pulse-hp {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

#hp-text {
    font-size: 13px;
    color: var(--text-dim);
    font-family: monospace;
    min-width: 55px;
}

#location-text {
    font-size: 12px;
    color: var(--accent);
    font-style: italic;
    max-width: 40%;
    text-align: right;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* === GENDER SCREEN === */
#gender-screen {
    position: fixed;
    inset: 0;
    background: var(--bg-dark);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
    gap: 24px;
}

#gender-screen.hidden {
    display: none;
}

#gender-title {
    font-size: 22px;
    color: var(--accent);
    text-shadow: 0 0 20px var(--accent-glow);
    text-align: center;
}

#gender-subtitle {
    font-size: 16px;
    color: var(--text-dim);
}

#gender-buttons {
    display: flex;
    gap: 16px;
    margin-top: 20px;
}

.gender-btn {
    padding: 14px 32px;
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--accent);
    border-radius: 8px;
    font-size: 16px;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
}

.gender-btn:hover, .gender-btn:active {
    background: var(--accent);
    color: var(--bg-dark);
    box-shadow: 0 0 20px var(--accent-glow);
}

/* === CHAT === */
#chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

#chat-messages {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: auto;
}

.chat-msg {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 15px;
    line-height: 1.6;
    animation: fadeIn 0.3s ease;
}

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

.chat-msg.user {
    align-self: flex-end;
    background: var(--accent);
    color: var(--bg-dark);
    border-bottom-right-radius: 4px;
}

.chat-msg.assistant {
    align-self: flex-start;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}

.chat-msg.system {
    align-self: center;
    background: transparent;
    color: var(--text-dim);
    font-style: italic;
    font-size: 13px;
    max-width: 90%;
    text-align: center;
}

/* === DICE OVERLAY === */
#dice-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

#dice-overlay.hidden {
    display: none;
}

#dice-container {
    text-align: center;
}

#dice {
    font-size: 80px;
    animation: roll 0.6s ease-out;
}

@keyframes roll {
    0% { transform: rotate(0deg) scale(0.5); opacity: 0; }
    50% { transform: rotate(360deg) scale(1.2); }
    100% { transform: rotate(720deg) scale(1); opacity: 1; }
}

#dice-result {
    margin-top: 20px;
    font-size: 28px;
    font-weight: bold;
    color: var(--accent);
    text-shadow: 0 0 15px var(--accent-glow);
}

/* === INPUT BAR === */
#input-bar {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

#action-input {
    flex: 1;
    padding: 12px 16px;
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 15px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

#action-input:focus {
    border-color: var(--accent);
}

#action-input::placeholder {
    color: var(--text-dim);
}

#send-btn {
    width: 44px;
    height: 44px;
    background: var(--accent);
    color: var(--bg-dark);
    border: none;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

#send-btn:hover {
    box-shadow: 0 0 15px var(--accent-glow);
    transform: scale(1.05);
}

#send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

#reset-btn {
    width: 44px;
    height: 44px;
    background: transparent;
    color: var(--danger);
    border: 1px solid var(--danger);
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

#reset-btn:hover {
    background: var(--danger);
    color: white;
}

/* === STATUS OVERLAY === */
#status-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 20px;
}

#status-overlay.hidden {
    display: none;
}

#status-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    max-width: 350px;
    width: 100%;
    position: relative;
    max-height: 80vh;
    overflow-y: auto;
}

#status-close {
    position: absolute;
    top: 10px;
    right: 14px;
    font-size: 18px;
    color: var(--text-dim);
    cursor: pointer;
}

#status-content {
    font-size: 14px;
    line-height: 1.6;
}

#status-content .status-label {
    color: var(--accent);
    font-weight: bold;
    margin-top: 10px;
}

#status-content .status-value {
    color: var(--text-primary);
}

/* === SCROLLBAR === */
::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

/* Typing cursor */
.chat-msg.typing::after {
    content: '|';
    animation: blink-cursor 0.5s infinite;
    color: var(--accent);
}

@keyframes blink-cursor {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}
