:root {
    --bg-main: #0c0a0e;
    --bg-panel: #16131c;
    --bg-card: #201c29;
    --border: #312a3d;
    --border-glow: #634f7d;
    --gold: #f4a261;
    --green: #2a9d8f;
    --red: #e76f51;
    --purple: #a855f7;
    --blue: #38bdf8;
    --text: #f3f4f6;
    --text-dim: #9ca3af;
}

* { 
    box-sizing: border-box; 
    -webkit-tap-highlight-color: transparent; 
}

html, body {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    background: var(--bg-main);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    overflow: hidden;
    display: flex;
    justify-content: center;
}

.app-container {
    width: 100%;
    max-width: 500px;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: #09080b;
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
    position: relative;
    overflow: hidden;
}

header {
    background: #09080b;
    border-bottom: 1px solid var(--border);
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex-shrink: 0;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo { 
    font-size: 0.85rem; 
    font-weight: 800; 
    color: var(--gold); 
}

.util-group { display: flex; gap: 4px; }

.util-btn {
    background: var(--bg-card);
    color: var(--text-dim);
    border: 1px solid var(--border);
    padding: 2px 6px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.65rem;
    font-weight: 600;
}

.util-btn:hover { border-color: var(--gold); color: #fff; }

.res-bar {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 2px;
    background: var(--bg-panel);
    padding: 4px 2px;
    border-radius: 6px;
    border: 1px solid var(--border);
    width: 100%;
}

.res-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 0.55rem;
    color: var(--text-dim);
    min-width: 0;
}

.res-item .val { 
    font-weight: 700; 
    color: #fff; 
    font-size: 0.65rem; 
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.res-item .rate {
    font-size: 0.5rem;
    color: var(--green);
    font-weight: 600;
}

.hero-hud-strip {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    background: var(--bg-panel);
    padding: 4px 8px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.bar-label { 
    display: flex; 
    justify-content: space-between; 
    font-size: 0.6rem; 
    margin-bottom: 2px; 
}

.progress-bar {
    width: 100%;
    background: #000;
    border: 1px solid var(--border);
    height: 5px;
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill { 
    height: 100%; 
    width: 0%; 
    transition: width 0.2s; 
}

.app-body {
    flex: 1;
    display: flex;
    position: relative;
    overflow: hidden;
    width: 100%;
}

.view-panel {
    flex: 1;
    padding: 8px;
    display: none;
    flex-direction: column;
    gap: 6px;
    width: 100%;
    height: 100%;
    overflow-y: auto;
}

.view-panel.active { display: flex; }

.card {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 8px;
    width: 100%;
    box-sizing: border-box;
}

.card-header {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--gold);
    margin-bottom: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    padding-bottom: 2px;
}

.btn {
    background: var(--bg-card);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 5px 6px 5px 6px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.65rem;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
	min-height:5vh;
	max-height:10vh;
    box-sizing: border-box;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn:hover:not(:disabled) {
    border-color: var(--gold);
    background: var(--border-glow);
}

.btn-primary { 
    background: var(--gold); 
    color: #000; 
    border: none; 
    font-weight: 700; 
}

.btn-primary:hover:not(:disabled) {
    background: #e08e4c;
}

.btn:disabled { 
    opacity: 0.4; 
    cursor: not-allowed; 
}

.grid-1 { display: flex; flex-direction: column; gap: 4px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; width: 100%; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 4px; width: 100%; }

.building-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 6px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 50px;
    cursor: pointer;
    box-sizing: border-box;
}

.building-card.built { border-color: var(--border-glow); }
.building-card.disabled { opacity: 0.4; cursor: not-allowed; }

.boss-tracker {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #000;
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid var(--border);
    margin-bottom: 4px;
}

.tracker-node {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    transition: all 0.2s ease;
}

.tracker-node.reached { background: var(--green); border-color: var(--green); box-shadow: 0 0 5px var(--green); }
.tracker-node.boss { border-radius: 2px; background: var(--bg-card); border-color: var(--red); }
.tracker-node.boss.reached { background: var(--red); box-shadow: 0 0 5px var(--red); }

/* Pinned Log Wrapper (Locked to Bottom) */
.pinned-log-wrapper {
    background: #08070b;
    border-top: 1px solid var(--border);
    padding: 4px;
    flex-shrink: 0;
}

.log-box {
    background: transparent;
    height: 70px;
    overflow-y: auto;
    font-size: 0.62rem;
    font-family: monospace;
    display: flex;
    flex-direction: column-reverse;
}

.log-entry { margin-top: 1px; }
.log-gain { color: var(--green); }
.log-combat { color: var(--red); }
.log-sys { color: var(--purple); }
.log-quest { color: var(--blue); }

/* Inline Alert Banner */
.alert-banner {
    background: var(--red);
    color: #fff;
    padding: 4px 8px;
    font-size: 0.65rem;
    font-weight: 700;
    text-align: center;
    display: none;
    flex-shrink: 0;
}

/* Bottom Navigation Bar */
.bottom-nav {
    background: #09080b;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    padding: 3px 0;
    flex-shrink: 0;
}

.nav-item {
    background: transparent;
    border: none;
    color: var(--text-dim);
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 0.58rem;
    padding: 2px 4px;
    cursor: pointer;
    font-weight: 600;
    position: relative;
}

.nav-item .nav-icon { font-size: 0.9rem; }
.nav-item.active { color: var(--gold); }

/* Visual Badge for Skill/Attribute points */
.badge {
    position: absolute;
    top: 0px;
    right: 8px;
    background: var(--red);
    color: #fff;
    font-size: 0.55rem;
    border-radius: 50%;
    width: 14px;
    height: 14px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    box-shadow: 0 0 6px rgba(231, 111, 81, 0.8);
}