:root {
    --bg-color: #f4f4f4;
    --text-color: #333;
    --primary-color: #2c3e50; /* Dark Blue */
    --accent-color: #e74c3c; /* Red */
    --success-color: #27ae60;
    --border-color: #ddd;
    --card-bg: #fff;
    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 0;
    line-height: 1.6;
    display: flex;
    justify-content: center;
    min-height: 100vh;
}

#app {
    width: 100%;
    max-width: 600px; /* Mobile focused max width */
    background-color: var(--card-bg);
    display: flex;
    flex-direction: column;
    height: 100vh;
    box-shadow: 0 0 20px rgba(0,0,0,0.1);
}

/* Header Sections */
header {
    background-color: var(--primary-color);
    color: white;
    padding: 10px 15px;
    text-align: center;
    flex-shrink: 0;
}

h1 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 600;
}

#subtitle {
    font-size: 0.8rem;
    opacity: 0.8;
}

/* Stats Bar */
#stats-bar {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    background-color: #34495e;
    color: white;
    padding: 8px 5px;
    font-size: 0.85rem;
    text-align: center;
    flex-shrink: 0;
}

.stat-item {
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 0.7rem;
    opacity: 0.7;
}

.stat-value {
    font-weight: bold;
}

.warning { color: #e74c3c; }
.safe { color: #2ecc71; }

/* Main Content Area */
#main-area {
    flex-grow: 1;
    overflow-y: auto;
    padding: 15px;
    position: relative;
    background-color: #fff;
}

/* Sections */
.section-title {
    font-size: 1rem;
    font-weight: bold;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 5px;
    margin-bottom: 10px;
    margin-top: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Market List */
.item-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.item-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #eee;
}

.item-info {
    flex: 1;
}

.item-name {
    font-weight: 500;
    font-size: 1rem;
}

.item-price {
    font-size: 0.9rem;
    color: #666;
}

.item-actions {
    display: flex;
    gap: 8px;
}

button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

button:active {
    transform: translateY(1px);
}

button.buy-btn { background-color: var(--success-color); }
button.sell-btn { background-color: var(--accent-color); }
button:disabled { background-color: #ccc; cursor: not-allowed; }

/* Location List */
.location-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-top: 10px;
}

.location-btn {
    background-color: #ecf0f1;
    color: var(--text-color);
    padding: 12px;
    border: 1px solid #bdc3c7;
    text-align: center;
}

.location-btn.active {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* Interaction Log / Messages */
#message-area {
    min-height: 80px;
    padding: 10px;
    background-color: #fff9c4;
    border-top: 1px solid var(--border-color);
    font-size: 0.9rem;
    flex-shrink: 0;
    max-height: 150px;
    overflow-y: auto;
}

.msg { margin-bottom: 4px; }
.msg-turn { color: #888; font-size: 0.8rem; }
.msg-important { color: #d35400; font-weight: bold; }

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.modal-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

.modal {
    background: white;
    width: 90%;
    max-width: 400px;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    text-align: center;
}

.modal h2 { margin-top: 0; }

.modal-content {
    margin-bottom: 20px;
    max-height: 60vh;
    overflow-y: auto;
}

.modal-close {
    background-color: var(--primary-color);
    padding: 10px 20px;
    font-size: 1rem;
}

/* Tabs for navigation in main area */
.nav-tabs {
    display: flex;
    background: #e0e0e0;
    border-bottom: 1px solid #ccc;
}

.nav-tab {
    flex: 1;
    padding: 12px;
    text-align: center;
    cursor: pointer;
    font-weight: 500;
    color: #666;
    border-bottom: 3px solid transparent;
}

.nav-tab.active {
    background: #fff;
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

/* Utility */
.hidden { display: none !important; }

/* Animations */
@keyframes shake {
  0% { transform: translate(1px, 1px) rotate(0deg); }
  10% { transform: translate(-1px, -2px) rotate(-1deg); }
  20% { transform: translate(-3px, 0px) rotate(1deg); }
  30% { transform: translate(3px, 2px) rotate(0deg); }
  40% { transform: translate(1px, -1px) rotate(1deg); }
  50% { transform: translate(-1px, 2px) rotate(-1deg); }
  60% { transform: translate(-3px, 1px) rotate(0deg); }
  70% { transform: translate(3px, 1px) rotate(-1deg); }
  80% { transform: translate(-1px, -1px) rotate(1deg); }
  90% { transform: translate(1px, 2px) rotate(0deg); }
  100% { transform: translate(1px, -2px) rotate(-1deg); }
}

.shake {
  animation: shake 0.5s;
}
