:root {
    --green: #008751;
    --green-light: #3ddc97;
    --green-dark: #005c36;
    --bg: #121212;
    --panel: #1e1e1e;
    --track: #2c2c2c;
    --text: #ffffff;
    --muted: #aaaaaa;
    --good: #3ddc97;
    --bad: #ff6b6b;
    --font: "Nunito", "Avenir Next", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
    --font-logo: "Lilita One", "Arial Black", Impact, sans-serif;
}

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

html, body {
    margin: 0;
    height: 100%;
    background: #000;
    color: var(--text);
    font-family: var(--font);
}

/* ---------- App shell: fills the whole screen ---------- */
.app {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 480px;
    height: 100vh;
    height: 100dvh;
    margin: 0 auto;
    background: var(--bg);
    overflow: hidden;
}

/* ---------- Top bar ---------- */
.topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
    background: #000;
    border-bottom: 2px solid var(--green);
}

.menu-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid #fff;
    background: transparent;
    color: #fff;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}

.logo {
    flex: 1;
    font-family: var(--font-logo);
    font-size: 28px;
    letter-spacing: 1px;
    color: var(--green-light);
    white-space: nowrap;
}

.badge {
    font-family: var(--font-logo);
    font-size: 15px;
    color: #fff;
    background: var(--green);
    border: 2px solid #fff;
    border-radius: 999px;
    padding: 4px 12px;
    letter-spacing: 1px;
}

/* ---------- Profile strip ---------- */
.profile {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    background: var(--panel);
    border-bottom: 1px solid #333;
}

.avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--green-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    flex-shrink: 0;
}

.who { flex: 1; min-width: 0; }

.name {
    font-size: 22px;
    font-weight: 800;
    color: var(--green-light);
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 3px;
}

.occupation {
    font-size: 15px;
    font-weight: 700;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.money { text-align: right; }

.cash {
    font-size: 24px;
    font-weight: 800;
    color: var(--good);
}

.money-label {
    font-size: 14px;
    font-weight: 700;
    color: var(--muted);
}

/* ---------- Life log ---------- */
.log {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 6px 16px 40px;
    font-size: 17px;
    font-weight: 600;
    line-height: 1.4;
}

.age-header {
    margin-top: 16px;
    padding-bottom: 3px;
    font-weight: 800;
    color: var(--green-light);
    border-bottom: 1px solid #2f2f2f;
}

.entry { margin: 6px 0; }
.entry.danger { color: var(--bad); font-weight: 800; }

.eff {
    display: inline-block;
    margin-left: 6px;
    font-size: 14px;
    font-weight: 800;
}
.eff.good { color: var(--good); }
.eff.bad  { color: var(--bad); }

/* ---------- Bottom tab bar ---------- */
.tabs {
    display: grid;
    grid-template-columns: 1fr 1fr 92px 1fr 1fr;
    align-items: end;
    background: var(--green-dark);
    border-top: 2px solid var(--green);
    padding: 6px 0 8px;
    position: relative;
}

.tab {
    background: none;
    border: none;
    color: #fff;
    font-family: var(--font);
    font-size: 10.5px;
    letter-spacing: -0.2px;
    white-space: nowrap;
    font-weight: 700;
    padding: 4px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
}
.tab:active { opacity: 0.7; }

.tab-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #eafff5;
    color: var(--green-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 800;
}

.tab-center {
    display: flex;
    justify-content: center;
}

/* Squircle Age button, raised above the bar */
#age-btn {
    width: 80px;
    height: 80px;
    margin-top: -38px;
    border-radius: 32%;
    border: none;
    background: linear-gradient(180deg, #1fbf6b 0%, var(--green) 100%);
    color: #fff;
    font-family: var(--font);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0;
    cursor: pointer;
    box-shadow: 0 0 0 5px var(--green-dark), 0 8px 16px rgba(0, 0, 0, 0.55);
    transition: transform 0.1s;
}
#age-btn:active { transform: scale(0.94); }

#age-btn:disabled {
    background: #444;
    color: #888;
    box-shadow: 0 0 0 5px var(--green-dark);
    cursor: not-allowed;
}

.age-icon { font-size: 34px; font-weight: 800; line-height: 0.9; }
.age-label { font-size: 14px; font-weight: 800; line-height: 1.05; text-align: center; max-width: 68px; }

/* ---------- Stat bars ---------- */
.stats {
    display: flex;
    flex-direction: column;
    gap: 7px;
    padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
    background: var(--panel);
}

.stat-row {
    display: grid;
    grid-template-columns: 112px 26px 1fr;
    align-items: center;
    gap: 5px;
}

.stat-label {
    text-align: right;
    white-space: nowrap;
    font-size: 14px;
    font-weight: 800;
    color: var(--green-light);
}

.stat-icon { font-size: 20px; text-align: center; }

.bar {
    position: relative;
    height: 26px;
    background: var(--track);
    border-radius: 4px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    width: 0;
    border-radius: 4px 0 0 4px;
    transition: width 0.4s ease, background-color 0.4s ease;
}

.bar-pct {
    position: absolute;
    right: 8px;
    top: 0;
    height: 100%;
    display: flex;
    align-items: center;
    font-size: 15px;
    font-weight: 800;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

/* ---------- Modals ---------- */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.82);
    justify-content: center;
    align-items: center;
    padding: 20px;
    z-index: 1000;
}

#welcome-modal { background: var(--bg); z-index: 2000; }

.modal-card {
    width: 100%;
    max-width: 380px;
    max-height: 90vh;
    overflow-y: auto;
    background: #2a2a2a;
    border-radius: 14px;
    border-left: 5px solid var(--green);
    padding: 20px;
    text-align: center;
}

.modal-card.welcome {
    background: var(--panel);
    border: 2px solid var(--green);
    padding: 25px;
}

.welcome h1 { margin: 0 0 8px; font-family: var(--font-logo); font-size: 34px; color: var(--green-light); }
.tagline { margin: 0 0 18px; color: var(--muted); font-style: italic; }

.guide {
    text-align: left;
    background: #2a2a2a;
    padding: 14px;
    border-radius: 8px;
    margin-bottom: 18px;
    font-size: 14px;
    line-height: 1.45;
    color: #ddd;
}
.guide h3 {
    margin: 0 0 6px;
    padding-bottom: 4px;
    font-size: 15px;
    color: var(--green-light);
    border-bottom: 1px solid #444;
}
.guide p { margin: 0 0 12px; }
.guide ul { margin: 0 0 12px; padding-left: 20px; }
.guide .small { font-size: 13px; color: var(--muted); margin-bottom: 0; }

.choice-question {
    margin: 0 0 18px;
    font-size: 17px;
    font-weight: 800;
    line-height: 1.4;
}

.choice-buttons { display: flex; flex-direction: column; gap: 10px; }

.choice-btn, .big-btn {
    font-family: var(--font);
    font-size: 16px;
    font-weight: 800;
    color: #fff;
    background: var(--green);
    border: none;
    border-radius: 10px;
    padding: 13px;
    cursor: pointer;
    width: 100%;
}
.choice-btn:active, .big-btn:active { background: var(--green-dark); }
.big-btn { font-size: 18px; padding: 15px; }

.sheet-title { margin: 0 0 12px; color: var(--green-light); font-family: var(--font-logo); font-weight: 400; font-size: 26px; }
.sheet-body { margin-bottom: 16px; text-align: left; font-size: 16px; font-weight: 600; line-height: 1.45; }
.sheet-body p { margin: 0 0 8px; }

.link-btn {
    display: block;
    width: 100%;
    margin-top: 10px;
    padding: 8px;
    background: none;
    border: none;
    color: var(--muted);
    font-family: var(--font);
    font-size: 14px;
    font-weight: 700;
    text-decoration: underline;
    cursor: pointer;
}

/* ---------- Lower area wrapper + slide-over panel ---------- */
.main { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; }

.panel { display: none; position: absolute; inset: 0; z-index: 20; flex-direction: column; background: var(--bg); }

.panel-head {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 14px; background: var(--green-dark); border-bottom: 2px solid var(--green);
}
.panel-x {
    width: 40px; height: 40px; border-radius: 50%; border: 2px solid #fff;
    background: transparent; color: #fff; font-size: 20px; line-height: 1; cursor: pointer;
}
.panel-title {
    flex: 1; text-align: center; padding-right: 52px;
    font-family: var(--font-logo); font-size: 22px; letter-spacing: 0.5px; color: #fff; white-space: nowrap;
}
.panel-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }

.occ-row {
    display: flex; align-items: center; gap: 14px; padding: 14px 16px;
    border-bottom: 1px solid #2a2a2a; cursor: pointer;
}
.occ-row:active { background: #1c1c1c; }
.occ-row.special { background: linear-gradient(90deg, #2a2210, #1c1c1c); }
.occ-icon { width: 40px; text-align: center; font-size: 30px; }
.occ-text { flex: 1; min-width: 0; }
.occ-title { font-size: 20px; font-weight: 800; color: var(--green-light); }
.occ-sub { font-size: 15px; font-weight: 600; color: var(--muted); }
.occ-arrow { font-size: 28px; font-weight: 800; color: var(--green-light); }

.occ-current { margin: 12px 14px; padding: 12px 14px; background: var(--panel); border: 1px solid var(--green); border-radius: 10px; }
.occ-current .occ-title { font-size: 17px; }

.job-card { margin: 10px 14px; padding: 12px 14px; background: var(--panel); border-radius: 10px; border-left: 4px solid var(--green); }
.job-title { font-size: 18px; font-weight: 800; }
.job-company { font-size: 14px; font-weight: 600; color: var(--muted); }
.job-pay { margin: 4px 0; font-size: 16px; font-weight: 800; color: var(--good); }
.job-req { font-size: 13px; font-weight: 700; color: var(--muted); margin-bottom: 8px; }
.job-req.bad { color: var(--bad); }
.small-btn {
    font-family: var(--font); font-size: 15px; font-weight: 800; color: #fff; background: var(--green);
    border: none; border-radius: 8px; padding: 9px 16px; cursor: pointer;
}
.small-btn.danger { background: #8a2a2a; }
.panel-note { margin: 24px 20px; text-align: center; font-size: 16px; font-weight: 600; color: var(--muted); line-height: 1.5; }

.occ-row.static { cursor: default; }
.occ-row.static:active { background: transparent; }
.occ-row.cur { background: #10281c; border-left: 4px solid var(--green); }
.occ-row.static .occ-title { font-size: 18px; }

/* ---------- Fixes after renaming ---------- */
.name { font-size: 20px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.modal-card.welcome { display: flex; flex-direction: column; max-height: 92vh; overflow: hidden; }
.modal-card.welcome .guide { flex: 1; min-height: 0; overflow-y: auto; }
