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

:root {
    --primary-color: #000000;
    --secondary-color: #000000;
    --accent-color: #ffffff;
    --success-color: #ffffff;
    --text-color: #ffffff;
    --text-muted: #cccccc;
    --border-color: #ffffff;
    --bg-dark: #000000;
    --bg-darker: #000000;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-color);
    overflow: hidden;
    height: 100vh;
}

.container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.header {
    background: #000000;
    padding: 1rem 2rem;
    border-bottom: 2px solid #ffffff;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header h1 {
    font-size: 1.8rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.header-controls {
    display: flex;
    gap: 1rem;
}

.game-wrapper {
    display: flex;
    flex: 1;
    overflow: hidden;
    gap: 1rem;
    padding: 1rem;
}

.chat-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: #000000;
    border: 1px solid #ffffff;
    border-radius: 8px;
    overflow: hidden;
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid #ffffff;
    background-color: #000000;
}

.chat-header h2 {
    font-size: 1.2rem;
}

.location-badge {
    background-color: #000000;
    padding: 0.5rem 1rem;
    border: 1px solid #ffffff;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
    color: #ffffff;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.message {
    padding: 1rem;
    border-radius: 6px;
    max-width: 90%;
    word-wrap: break-word;
    animation: slideIn 0.3s ease-out;
}

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

.message.system {
    background-color: #000000;
    border: 1px solid #ffffff;
    border-left: 3px solid #ffffff;
    align-self: flex-start;
    color: #ffffff;
}

.message.player {
    background-color: #000000;
    border: 1px solid #ffffff;
    border-left: 3px solid #ffffff;
    align-self: flex-end;
    max-width: 80%;
    color: #ffffff;
}

.message.narrator {
    background-color: #000000;
    border: 1px solid #ffffff;
    border-left: 3px solid #ffffff;
    align-self: flex-start;
    color: #ffffff;
}

.message.event {
    background-color: #000000;
    border: 1px solid #ffffff;
    border-left: 3px solid #ffffff;
    align-self: flex-start;
    color: #ffffff;
}

.message p {
    line-height: 1.5;
}

.chat-input-area {
    display: flex;
    gap: 0.5rem;
    padding: 1rem;
    border-top: 1px solid #ffffff;
    background-color: #000000;
}

.action-input {
    flex: 1;
    padding: 0.75rem;
    background-color: #000000;
    border: 1px solid #ffffff;
    border-radius: 4px;
    color: #ffffff;
    font-size: 1rem;
}

.action-input:focus {
    outline: none;
    border-color: #ffffff;
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.3);
}

.action-input::placeholder {
    color: var(--text-muted);
}

.side-panel {
    width: 320px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.side-panel::-webkit-scrollbar {
    width: 6px;
}

.side-panel::-webkit-scrollbar-track {
    background: var(--secondary-color);
    border-radius: 3px;
}

.side-panel::-webkit-scrollbar-thumb {
    background: var(--accent-color);
    border-radius: 3px;
}

.section {
    background-color: #000000;
    border: 1px solid #ffffff;
    border-radius: 8px;
    padding: 1rem;
}

.section h3 {
    margin-bottom: 1rem;
    font-size: 1.1rem;
    border-bottom: 1px solid #ffffff;
    padding-bottom: 0.5rem;
    color: #ffffff;
}

.player-stats {
}

.stat-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.95rem;
}

.stat-label {
    color: var(--text-muted);
    font-weight: 500;
}

.stat-value {
    color: var(--text-color);
    font-weight: 600;
}

.hp-bar-container {
    margin-bottom: 1rem;
}

.hp-bar-label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.hp-bar {
    width: 100%;
    height: 20px;
    background-color: #000000;
    border: 1px solid #ffffff;
    border-radius: 4px;
    overflow: hidden;
}

.hp-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #ffffff, #cccccc);
    transition: width 0.3s ease;
}

.xp-bar-fill {
    height: 100%;
    background: repeating-linear-gradient(45deg, #ffffff, #ffffff 4px, #666666 4px, #666666 8px);
    transition: width 0.3s ease;
}

/* 전투 패널 */
.section.combat {
    border: 2px solid #ffffff;
}

.section.hidden {
    display: none;
}

.combat-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.skill-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.hunt-section {
    padding: 0.75rem;
}

.hunt-btn {
    width: 100%;
}

/* 게임 오버 */
.game-over-section {
    padding: 1rem;
    border: 2px solid #ffffff;
    text-align: center;
}

.game-over-text {
    color: #cccccc;
    margin-bottom: 0.75rem;
}

/* 상점 */
.shop-modal-content {
    max-width: 600px;
}

.shop-gold {
    text-align: right;
    color: #ffffff;
    font-weight: 600;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #ffffff;
}

.shop-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.shop-tab.active {
    background-color: #1a1a1a;
    border: 2px solid #ffffff;
}

.shop-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 350px;
    overflow-y: auto;
}

.shop-list.hidden {
    display: none;
}

.shop-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background-color: #000000;
    border: 1px solid #ffffff;
    border-radius: 4px;
    gap: 0.75rem;
}

.shop-item-info {
    flex: 1;
}

.shop-item-name {
    color: #ffffff;
    font-weight: 600;
    font-size: 0.95rem;
}

.shop-item-desc {
    color: #cccccc;
    font-size: 0.8rem;
    margin-top: 0.2rem;
}

.shop-item-price {
    color: #ffffff;
    font-weight: 600;
    white-space: nowrap;
}

/* 오늘의 특가 */
.shop-item-special {
    border: 2px solid #ffffff;
}

.special-badge {
    font-size: 0.7rem;
    font-weight: 700;
    border: 1px solid #ffffff;
    border-radius: 3px;
    padding: 0.1rem 0.35rem;
    margin-left: 0.4rem;
}

.original-price {
    color: #888888;
    text-decoration: line-through;
    font-weight: 400;
    margin-right: 0.4rem;
}

.shop-list::-webkit-scrollbar {
    width: 4px;
}

.shop-list::-webkit-scrollbar-thumb {
    background: #ffffff;
    border-radius: 2px;
}

/* 이동 */
.travel-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.travel-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 0.75rem;
    background-color: #000000;
    border: 1px solid #ffffff;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
    gap: 0.5rem;
}

.travel-item:hover {
    background-color: #1a1a1a;
}

.travel-item.current {
    border: 2px solid #ffffff;
    cursor: default;
}

.travel-item-name {
    color: #ffffff;
    font-weight: 600;
    font-size: 0.9rem;
}

.travel-item-level {
    color: #cccccc;
    font-size: 0.8rem;
    white-space: nowrap;
}

/* 퀘스트 진행 */
.quest-progress {
    color: #cccccc;
    font-size: 0.85rem;
    margin-top: 0.3rem;
}

/* 완료한 퀘스트 기록 */
.quest-completed-header {
    color: #888888;
    font-size: 0.8rem;
    margin-top: 0.75rem;
    padding-top: 0.5rem;
    border-top: 1px dashed #555555;
}

.quest-item.completed {
    color: #888888;
    border-color: #555555;
    text-decoration: line-through;
}

.quest-board-btn {
    margin-top: 0.75rem;
}

/* 나레이터 응답 대기 표시 */
.typing-indicator p {
    color: #cccccc;
    font-style: italic;
}

/* 정신력 바 (체력 바와 동일한 톤, 점선 무늬로 구분) */
.mp-bar-fill {
    background: repeating-linear-gradient(
        45deg,
        #ffffff,
        #ffffff 4px,
        #999999 4px,
        #999999 8px
    );
}

/* 상태 이상 표시 */
.status-effects {
    color: #cccccc;
    font-size: 0.85rem;
    margin: 0.4rem 0;
    min-height: 1em;
}

/* 저장 슬롯 */
.save-slot-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.save-slot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
    border: 1px solid #ffffff;
    border-radius: 4px;
    gap: 0.5rem;
}

.save-slot-info {
    color: #ffffff;
    font-size: 0.85rem;
    flex: 1;
}

.save-slot-info .save-slot-time {
    color: #888888;
    font-size: 0.75rem;
}

.save-slot-actions {
    display: flex;
    gap: 0.4rem;
}

/* 모델 선택 */
#modelSelect {
    width: 100%;
    padding: 0.5rem;
    background-color: #000000;
    color: #ffffff;
    border: 1px solid #ffffff;
    border-radius: 4px;
    margin: 0.4rem 0;
    font-family: inherit;
}

.equipment-slots {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.slot {
    background-color: #000000;
    border: 1px solid #ffffff;
    border-radius: 6px;
    padding: 0.75rem;
    text-align: center;
}

.slot-label {
    font-size: 0.9rem;
    color: #cccccc;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.slot-content {
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.5rem;
    border: 1px dashed #ffffff;
    border-radius: 4px;
    background-color: #000000;
}

.empty-slot {
    color: var(--text-muted);
    font-size: 1.5rem;
}

.item-in-slot {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.item-in-slot .item-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.item-in-slot .item-effect {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.slot-action {
    width: 100%;
    padding: 0.4rem;
    font-size: 0.8rem;
}

.inventory-info {
    text-align: right;
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.inventory-list {
    /* 고정 높이 대신 아이템 개수에 맞춰 자연스럽게 늘고 줄어듦.
       전체 스크롤은 .side-panel 하나가 담당 (중첩 스크롤 제거) */
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.inventory-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background-color: #000000;
    border: 1px solid #ffffff;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.inventory-item:hover {
    background-color: #1a1a1a;
    border-color: #ffffff;
}

.inventory-item-name {
    flex: 1;
    font-size: 0.95rem;
}

.inventory-item-qty {
    background-color: #1a1a1a;
    padding: 0.25rem 0.5rem;
    border: 1px solid #ffffff;
    border-radius: 3px;
    font-size: 0.85rem;
    font-weight: 600;
    margin-right: 0.5rem;
    color: #ffffff;
}

.inventory-item-actions {
    display: flex;
    gap: 0.25rem;
}

.empty-message {
    text-align: center;
    color: var(--text-muted);
    padding: 1rem;
    font-size: 0.9rem;
}

.quest-list {
    /* 퀘스트 개수에 맞춰 자연스럽게 늘고 줄어듦 (인벤토리와 동일 원칙) */
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.quest-item {
    padding: 0.75rem;
    background-color: #000000;
    border-left: 3px solid #ffffff;
    border-radius: 4px;
    font-size: 0.9rem;
    line-height: 1.4;
    border: 1px solid #ffffff;
    color: #ffffff;
}

.btn {
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
    font-size: 0.95rem;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.btn-primary {
    background-color: #000000;
    color: #ffffff;
    border: 2px solid #ffffff;
}

.btn-primary:hover {
    background-color: #1a1a1a;
    border: 2px solid #ffffff;
}

.btn-secondary {
    background-color: #000000;
    color: #ffffff;
    border: 1px solid #ffffff;
}

.btn-secondary:hover {
    background-color: #1a1a1a;
    border: 1px solid #ffffff;
}

.btn-small {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background-color: #000000;
    border: 1px solid #ffffff;
    border-radius: 8px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(255, 255, 255, 0.2);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid #ffffff;
    background-color: #000000;
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover {
    color: var(--accent-color);
}

.modal-body {
    padding: 1.5rem;
}

.job-intro {
    text-align: center;
    margin-bottom: 2rem;
    font-size: 1.1rem;
    color: #ffffff;
}

.job-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}

.job-card {
    background-color: #000000;
    border: 2px solid #ffffff;
    border-radius: 8px;
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
}

.job-card:hover {
    background-color: #1a1a1a;
    border-color: #ffffff;
    transform: translateY(-5px);
    box-shadow: 0 8px 16px rgba(255, 255, 255, 0.1);
}

.job-card-name {
    font-size: 1.3rem;
    font-weight: 700;
    color: #ffffff;
    margin-bottom: 0.5rem;
}

.job-card-description {
    font-size: 0.9rem;
    color: #cccccc;
    margin-bottom: 1rem;
    line-height: 1.4;
}

.job-card-stats {
    font-size: 0.85rem;
    color: #999999;
    text-align: left;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #333333;
}

.job-stat-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.3rem;
}

.job-stat-label {
    color: #cccccc;
}

.job-stat-value {
    color: #ffffff;
    font-weight: 600;
}

.setting-group {
    margin-bottom: 1.5rem;
}

.setting-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-color);
}

.setting-group input {
    width: 100%;
    padding: 0.75rem;
    background-color: #000000;
    border: 1px solid #ffffff;
    border-radius: 4px;
    color: #ffffff;
    margin-bottom: 0.5rem;
}

.setting-group input:focus {
    outline: none;
    border-color: #ffffff;
}

.hint {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

.hint code {
    background-color: var(--primary-color);
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
}

.status-message {
    margin-top: 0.75rem;
    padding: 0.75rem;
    border-radius: 4px;
    font-size: 0.9rem;
    display: none;
}

.status-message.success {
    display: block;
    background-color: rgba(39, 174, 96, 0.2);
    border: 1px solid var(--success-color);
    color: var(--success-color);
}

.status-message.error {
    display: block;
    background-color: rgba(231, 76, 60, 0.2);
    border: 1px solid var(--accent-color);
    color: var(--accent-color);
}

/* Scrollbar styling */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: var(--primary-color);
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--accent-color);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #c0392b;
}

@media (max-width: 1024px) {
    .game-wrapper {
        flex-direction: column;
    }

    .side-panel {
        width: 100%;
        max-height: 300px;
    }

    .equipment-slots {
        grid-template-columns: 1fr;
    }
}
