:root {
    color-scheme: light dark;
    font-family: "SF Pro Display", "Segoe UI", "Helvetica Neue", system-ui, sans-serif;

    /* Default Theme (Gradient) */
    --bg-main: radial-gradient(circle at top, #23212f, #0a0913 55%, #03030a);
    --bg-shell: rgba(15, 14, 26, 0.82);
    --bg-hero-card: linear-gradient(140deg, rgba(71, 55, 142, 0.22), rgba(28, 24, 68, 0.7));
    --bg-panel: rgba(255, 255, 255, 0.05);
    --bg-stat: rgba(255, 255, 255, 0.04);
    --bg-quest: rgba(16, 19, 34, 0.7);
    --bg-log: rgba(6, 7, 14, 0.62);
    --bg-combat-log: rgba(0, 0, 0, 0.4);
    --bg-item: rgba(255, 255, 255, 0.06);
    --bg-header: rgba(10, 9, 19, 0.95);
    --bg-modal: rgba(15, 14, 26, 0.95);
    --bg-input: rgba(255, 255, 255, 0.05);
    --bg-select: rgba(0, 0, 0, 0.3);
    --bg-tab: rgba(255, 255, 255, 0.08);
    --bg-tab-hover: rgba(255, 255, 255, 0.12);
    --bg-tab-active: rgba(255, 255, 255, 0.15);
    
    /* Button gradients - colorful for gradient theme */
    --btn-primary: linear-gradient(120deg, #ffd85b, #ff9671);
    --btn-primary-shadow: rgba(255, 152, 113, 0.28);
    --btn-secondary: linear-gradient(120deg, #4facfe, #00c6ff);
    --btn-secondary-shadow: rgba(79, 172, 254, 0.25);
    --btn-tertiary: linear-gradient(120deg, #845ec2, #d65db1);
    --btn-tertiary-shadow: rgba(132, 94, 194, 0.26);
    --btn-danger: linear-gradient(120deg, #ff4d6d, #c9184a);
    --btn-danger-shadow: rgba(255, 77, 109, 0.3);
}

/* True Dark Theme */
body.true-dark {
    --bg-main: #000000;
    --bg-shell: rgba(0, 0, 0, 0.9);
    --bg-hero-card: linear-gradient(140deg, rgba(20, 20, 20, 0.9), rgba(10, 10, 10, 0.95));
    --bg-panel: rgba(15, 15, 15, 0.8);
    --bg-stat: rgba(25, 25, 25, 0.6);
    --bg-quest: rgba(10, 10, 10, 0.9);
    --bg-log: rgba(5, 5, 5, 0.85);
    --bg-combat-log: rgba(0, 0, 0, 0.7);
    --bg-item: rgba(30, 30, 30, 0.5);
    --bg-header: rgba(0, 0, 0, 0.98);
    --bg-modal: rgba(10, 10, 10, 0.98);
    --bg-input: rgba(30, 30, 30, 0.8);
    --bg-select: rgba(20, 20, 20, 0.8);
    --bg-tab: rgba(40, 40, 40, 0.6);
    --bg-tab-hover: rgba(50, 50, 50, 0.7);
    --bg-tab-active: rgba(60, 60, 60, 0.8);
    
    /* Button styles - white/light for dark mode */
    --btn-primary: rgba(255, 255, 255, 0.9);
    --btn-primary-shadow: rgba(255, 255, 255, 0.2);
    --btn-secondary: rgba(230, 230, 230, 0.9);
    --btn-secondary-shadow: rgba(200, 200, 200, 0.2);
    --btn-tertiary: rgba(245, 245, 245, 0.9);
    --btn-tertiary-shadow: rgba(220, 220, 220, 0.2);
    --btn-danger: rgba(255, 200, 200, 0.9);
    --btn-danger-shadow: rgba(255, 150, 150, 0.2);
}

body {
    margin: 0;
    min-height: 100vh;
    padding: 0;
    background: var(--bg-main);
    color: #f3f1ff;
    overflow-x: hidden;
    overflow-y: auto;
    /* Hide scrollbar for Chrome, Safari and Opera */
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none;  /* IE and Edge */
}

body::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}

.app-shell {
    width: 100%;
    min-height: 100vh;
    margin: 0;
    padding: calc(env(safe-area-inset-top) + 60px) 18px calc(32px + env(safe-area-inset-bottom)) 18px;
    border-radius: 0;
    border: none;
    background: var(--bg-shell);
    backdrop-filter: blur(18px);
    box-shadow: none;
    display: flex;
    flex-direction: column;
    gap: 20px;
    box-sizing: border-box;
}

.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100vw;
    display: flex;
    align-items: center;
    justify-content: space-between;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-size: 0.95rem;
    color: rgba(243, 241, 255, 0.78);
    padding: calc(env(safe-area-inset-top) + 12px) 18px 12px 18px;
    background: var(--bg-header);
    backdrop-filter: blur(20px);
    z-index: 1000;
    box-sizing: border-box;
}

.hero-card {
    background: var(--bg-hero-card);
    border-radius: 24px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    border: 1px solid rgba(255, 255, 255, 0.04);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

/* Hero Header - Avatar + Core Stats */
.hero-header {
    display: flex;
    align-items: center;
    gap: 14px;
}

.avatar-compact {
    width: 240px;
    height: 240px;
    border-radius: 50%;
    background: transparent;
    display: grid;
    place-items: center;
    font-size: 4rem;
    font-weight: 700;
    color: #f3f1ff;
    cursor: pointer;
    transition: transform 0.2s ease;
    overflow: hidden;
    flex-shrink: 0;
}

.avatar-compact:hover {
    transform: scale(1.05);
}

.avatar-compact img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.core-stats {
    display: flex;
    gap: 12px;
    flex: 1;
}

.core-stat {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    text-align: center;
    background: var(--bg-stat);
    padding: 8px 10px;
    border-radius: 10px;
}

.core-stat span {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(243, 241, 255, 0.5);
}

.core-stat strong {
    font-size: 1.1rem;
    letter-spacing: 0.02em;
}

/* Meters Compact */
.meters-compact {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.meter-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.meter-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(243, 241, 255, 0.6);
}

.meter {
    width: 100%;
    height: 8px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.08);
    overflow: hidden;
}

.meter-fill {
    height: 100%;
    border-radius: inherit;
    transition: width 0.3s ease;
}

.meter-fill.hp {
    background: linear-gradient(90deg, #ff4d6d, #ff7eb3);
}

.meter-fill.xp {
    background: linear-gradient(90deg, #00c9ff, #92fe9d);
}

.meter-fill.energy {
    background: linear-gradient(90deg, #00c9ff, #845ec2);
}

.meter-fill.fame {
    background: linear-gradient(90deg, #ffd85b, #fbab7e);
}

/* Stats Sections */
.stats-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.section-title {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: rgba(243, 241, 255, 0.4);
    font-weight: 600;
}

.stats-compact {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px;
    background: var(--bg-stat);
    border-radius: 10px;
    text-align: center;
}

.stat-item span {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(243, 241, 255, 0.5);
}

.stat-item strong {
    font-size: 1rem;
    letter-spacing: 0.02em;
}

/* Attributes List */
.attributes-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.attr-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: var(--bg-stat);
    border-radius: 10px;
}

.attr-name {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(243, 241, 255, 0.5);
    min-width: 32px;
}

.attr-row strong {
    font-size: 1rem;
    letter-spacing: 0.02em;
    flex: 1;
}

.attr-controls {
    display: flex;
    gap: 6px;
}

.attr-btn-mini {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    display: grid;
    place-items: center;
}

.attr-btn-mini:hover {
    background: rgba(255, 255, 255, 0.15);
}

.attr-btn-mini:active {
    transform: scale(0.95);
    background: linear-gradient(120deg, #845ec2, #d65db1);
}

#navButtons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.nav-btn {
    flex: 1 1 calc(33.333% - 7px);
    min-width: 100px;
    padding: 12px 14px;
    border-radius: 12px;
    border: none;
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Force specific buttons to appear in second row */
#viewShopBtn,
#viewEnchantBtn {
    flex: 1 1 calc(50% - 5px);
}

.nav-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.2);
}

.nav-btn:active {
    transform: scale(0.98);
}

.nav-btn.active {
    background: var(--btn-primary);
    border-color: rgba(255, 255, 255, 0.3);
}

body:not(.true-dark) .nav-btn.active {
    color: #1d1532;
}

body.true-dark .nav-btn.active {
    color: #000000;
}

.back-btn {
    padding: 12px 18px;
    border-radius: 14px;
    border: none;
    background: rgba(255, 255, 255, 0.12);
    color: #f5f4ff;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 16px;
    transition: transform 0.12s ease, background 0.12s ease;
}

.back-btn:active {
    transform: translateY(2px);
    background: rgba(255, 255, 255, 0.2);
}

.hidden {
    display: none !important;
}

.layout {
    display: flex;
    flex-direction: column;
    gap: 18px;
    flex: 1;
    overflow: hidden;
}

.panel {
    background: var(--bg-panel);
    border-radius: 22px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    border: 1px solid rgba(255, 255, 255, 0.04);
}

.panel h2 {
    margin: 0;
    font-size: 1.05rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.quest-list {
    display: grid;
    gap: 12px;
}

.quest-card {
    border-radius: 16px;
    padding: 12px 14px;
    background: var(--bg-quest);
    border: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.quest-card strong {
    letter-spacing: 0.05em;
}

.quest-card span {
    font-size: 0.8rem;
    color: rgba(243, 241, 255, 0.7);
}

.quest-card button {
    align-self: flex-start;
    margin-top: 6px;
    padding: 10px 14px;
    border-radius: 12px;
    border: none;
    background: var(--btn-tertiary);
    font-weight: 600;
    letter-spacing: 0.06em;
    cursor: pointer;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
    box-shadow: 0 10px 16px var(--btn-tertiary-shadow);
}

body:not(.true-dark) .quest-card button {
    color: #fdf7ff;
}

body.true-dark .quest-card button {
    color: #000000;
}

.quest-card button:active {
    transform: translateY(2px);
    box-shadow: 0 4px 8px rgba(132, 94, 194, 0.3);
}

.log-panel {
    flex: 1;
    overflow: hidden;
}

.log-entries {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column-reverse;
    gap: 12px;
}

.log-line {
    padding: 12px 14px;
    border-radius: 14px;
    background: var(--bg-log);
    border: 1px solid rgba(255, 255, 255, 0.04);
    font-size: 0.92rem;
    line-height: 1.4;
}

.actions-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.action-btn {
    padding: 14px 16px;
    border-radius: 16px;
    border: none;
    font-size: 0.92rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    cursor: pointer;
    background: var(--btn-primary);
    box-shadow: 0 12px 20px var(--btn-primary-shadow);
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

body:not(.true-dark) .action-btn {
    color: #1d1532;
}

body.true-dark .action-btn {
    color: #000000;
}

/* Make adventure/fight buttons white in dark mode */
body.true-dark #startAdventureBtn,
body.true-dark #startCombatBtn,
body.true-dark #enterDungeonBtn,
body.true-dark button[id^="selectDungeon"] {
    background: rgba(255, 255, 255, 0.9) !important;
    color: #000000 !important;
}

.action-btn.secondary {
    background: var(--btn-secondary);
    box-shadow: 0 12px 20px var(--btn-secondary-shadow);
}

body:not(.true-dark) .action-btn.secondary {
    color: #fdf7ff;
}

body.true-dark .action-btn.secondary {
    color: #000000;
}

.action-btn.tertiary {
    background: var(--btn-tertiary);
    box-shadow: 0 12px 20px var(--btn-tertiary-shadow);
}

body:not(.true-dark) .action-btn.tertiary {
    color: #fdf7ff;
}

body.true-dark .action-btn.tertiary {
    color: #000000;
}
    background: linear-gradient(120deg, #845ec2, #54d2ff);
    box-shadow: 0 12px 20px rgba(84, 210, 255, 0.25);
}

.action-btn:active {
    transform: translateY(2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.28);
}

.inventory {
    background: var(--bg-log);
    border-radius: 18px;
    padding: 14px 16px;
    border: 1px solid rgba(255, 255, 255, 0.04);
    display: grid;
    gap: 12px;
}

.inventory h3 {
    margin: 0;
    font-size: 0.95rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.inventory-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.item-slot {
    border-radius: 14px;
    min-height: 140px;
    background: var(--bg-item);
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: flex-start;
    gap: 6px;
    font-size: 0.8rem;
    text-align: left;
    padding: 16px;
}

.item-slot strong {
    font-size: 1rem;
}

.equipment-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.equip-slot {
    border-radius: 14px;
    background: var(--bg-item);
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 70px;
}

.equip-slot span {
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(243, 241, 255, 0.65);
}

.equip-empty {
    font-size: 0.85rem;
    color: rgba(243, 241, 255, 0.4);
    font-style: italic;
}

.shop-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.comparison-panel {
    margin-top: 16px;
    padding: 16px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 0.85rem;
    line-height: 1.6;
}

.comparison-panel.hidden {
    display: none;
}

.comparison-panel h3 {
    margin: 0 0 10px;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.comparison-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.comparison-row:last-child {
    border-bottom: none;
}

.comparison-value {
    font-weight: 600;
}

.comparison-value.better {
    color: #92fe9d;
}

.comparison-value.worse {
    color: #ff7eb3;
}

.shop-item {
    border-radius: 16px;
    padding: 16px;
    background: var(--bg-quest);
    border: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
}

.buy-btn {
    padding: 8px 16px;
    border-radius: 10px;
    border: none;
    background: linear-gradient(120deg, #00c9ff, #845ec2);
    color: #fdf7ff;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 8px 14px rgba(0, 201, 255, 0.22);
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.buy-btn:active {
    transform: translateY(2px);
    box-shadow: 0 4px 8px rgba(0, 201, 255, 0.3);
}

.unequip-btn {
    padding: 6px 12px;
    border-radius: 8px;
    border: none;
    background: rgba(255, 77, 109, 0.2);
    color: #ff7eb3;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 8px;
    transition: transform 0.12s ease, background 0.12s ease;
}

.unequip-btn:active {
    transform: translateY(2px);
    background: rgba(255, 77, 109, 0.35);
}

.player-name-clickable {
    cursor: pointer;
    transition: color 0.2s ease;
}

.player-name-clickable:hover {
    color: #ff7eb3;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    overflow-y: auto;
    padding: 20px;
}

.modal {
    background: var(--bg-modal);
    border-radius: 24px;
    padding: 32px 24px;
    width: min(340px, 90vw);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
    margin: 0;
    max-height: calc(100vh - 20px);
    overflow-y: auto;
}

.modal h2 {
    margin: 0 0 20px 0;
    font-size: 1.3rem;
    text-align: center;
}

.modal input {
    width: 100%;
    padding: 14px 16px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: var(--bg-input);
    color: #f3f1ff;
    font-size: 1rem;
    font-family: inherit;
    margin-bottom: 20px;
    box-sizing: border-box;
}

.modal input:focus {
    outline: none;
    border-color: #ff7eb3;
}

.modal-buttons {
    display: flex;
    gap: 12px;
}

.modal-btn {
    flex: 1;
    padding: 12px;
    border-radius: 12px;
    border: none;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.12s ease;
}

.modal-btn:active {
    transform: translateY(2px);
}

.modal-btn.primary {
    background: var(--btn-tertiary);
}

body:not(.true-dark) .modal-btn.primary {
    color: #fdf7ff;
}

body.true-dark .modal-btn.primary {
    color: #000000;
}

.modal-btn.secondary {
    background: rgba(255, 255, 255, 0.1);
    color: #f3f1ff;
}

.modal-btn.danger {
    background: linear-gradient(120deg, #ff4d6d, #c9184a);
    color: #ffffff;
}

.modal-btn.danger:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.avatar-gallery {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-top: 20px;
}

.avatar-option {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 16px;
    overflow: hidden;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 0.2s ease;
}

.avatar-option:hover {
    transform: scale(1.05);
    border-color: #ff7eb3;
}

.avatar-option.selected {
    border-color: #845ec2;
    box-shadow: 0 0 20px rgba(132, 94, 194, 0.5);
}

.avatar-option img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.shop-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.shop-tab {
    flex: 1;
    padding: 10px;
    border-radius: 10px;
    border: none;
    background: rgba(255, 255, 255, 0.08);
    color: rgba(243, 241, 255, 0.6);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.shop-tab.active {
    background: rgba(255, 255, 255, 0.15);
    color: #fdf7ff;
    border: 1px solid rgba(255, 255, 255, 0.25);
}

.shop-tab:active {
    transform: translateY(1px);
}

.refresh-btn {
    width: 100%;
    padding: 12px;
    border-radius: 12px;
    border: none;
    background: linear-gradient(120deg, #ffd85b, #ff9671);
    color: #1d1532;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 16px;
    transition: all 0.2s ease;
}

.refresh-btn:active {
    transform: translateY(2px);
}

.refresh-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.accordion-section {
    overflow: hidden;
}

.accordion-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    margin: 0;
    padding: 16px;
    font-size: 1.05rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    user-select: none;
    transition: background 0.2s ease;
    border-radius: 12px;
}

.accordion-header:hover {
    background: rgba(255, 255, 255, 0.05);
}

.accordion-header:active {
    background: rgba(255, 255, 255, 0.08);
}

.accordion-icon {
    font-size: 0.9rem;
    transition: transform 0.3s ease;
    color: rgba(255, 255, 255, 0.6);
}

.accordion-header.active .accordion-icon {
    transform: rotate(0deg);
}

.accordion-content {
    max-height: 2000px;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease, padding 0.3s ease;
    opacity: 1;
    padding-top: 14px;
}

.accordion-content.collapsed {
    max-height: 0;
    opacity: 0;
    padding-top: 0;
}

/* Hide navButtonsContainer in portrait mode */
#navButtonsContainer {
    display: none;
}

@media (orientation: landscape) {
    .app-shell {
        flex-direction: row;
        gap: 20px;
        max-width: 100vw;
        padding: calc(env(safe-area-inset-top) + 60px) 20px 20px 20px;
    }

    .header {
        padding: calc(env(safe-area-inset-top) + 12px) 24px 12px 24px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        gap: 12px;
    }

    .header > div:first-child {
        flex: 1;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .header > div:last-child {
        flex-shrink: 0;
        white-space: nowrap;
    }

    .hero-card {
        width: 350px;
        min-width: 350px;
        flex-shrink: 0;
        margin-top: 0;
    }

    /* Always show hero card in landscape */
    .hero-card.hidden {
        display: flex !important;
    }

    /* Hide nav buttons from hero-card in landscape */
    .hero-card #navButtons {
        display: none !important;
    }

    /* Position nav buttons container in landscape */
    #navButtonsContainer {
        display: flex;
        flex-direction: column;
        gap: 12px;
        flex: 1;
        min-width: 0;
    }

    /* Ensure navButtonsContainer shows buttons properly */
    #navButtonsContainer #navButtons {
        display: flex !important;
        flex-wrap: wrap;
        gap: 10px;
        margin-top: 0;
        margin-bottom: 20px;
    }

    #navButtonsContainer .nav-btn {
        flex: 1 1 calc(33.333% - 7px);
        min-width: 100px;
    }

    /* Force specific buttons to appear in second row in landscape */
    #navButtonsContainer #viewShopBtn,
    #navButtonsContainer #viewEnchantBtn {
        flex: 1 1 calc(50% - 5px);
    }

    .layout {
        flex: 1;
        overflow-y: auto;
        max-height: calc(100vh - 40px);
    }

    /* Make sure views take remaining space */
    #characterView,
    #equipmentView,
    #shopView,
    #adventureView {
        width: 100%;
    }

    /* Adjust equipment grid for landscape */
    .equipment-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    /* Adjust inventory grid for landscape */
    .inventory-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    /* Shop grid wider in landscape */
    .shop-grid {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 16px;
    }

    /* Make accordion content scrollable in landscape */
    .accordion-content {
        max-height: calc(100vh - 250px);
        overflow-y: auto;
    }

    /* Equipment and inventory panels */
    .panel {
        max-height: none;
    }
}

/* Dungeon Styles */
.dungeon-select-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: 1fr;
}

.dungeon-card {
    border-radius: 16px;
    padding: 18px;
    background: var(--bg-quest);
    border: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.dungeon-card:hover {
    border-color: rgba(255, 255, 255, 0.15);
}

.dungeon-card.locked {
    opacity: 0.6;
    background: var(--bg-log);
}

.dungeon-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.dungeon-enter-btn {
    padding: 10px 20px;
    border-radius: 10px;
    border: none;
    background: linear-gradient(120deg, #ff4d6d, #ff7eb3);
    color: #fdf7ff;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
    box-shadow: 0 8px 14px rgba(255, 77, 109, 0.3);
}

.dungeon-enter-btn:active {
    transform: translateY(2px);
    box-shadow: 0 4px 8px rgba(255, 77, 109, 0.4);
}

.dungeon-enter-btn.disabled {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.4);
    cursor: not-allowed;
    box-shadow: none;
}

.dungeon-enter-btn.disabled:active {
    transform: none;
}

/* Landscape adjustments for dungeons */
@media (orientation: landscape) {
    .dungeon-select-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* Unified Equipment & Inventory Styles */
.filter-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    overflow-x: auto;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Firefox */
}

.filter-tabs::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Edge */
}

.filter-tab {
    flex-shrink: 0;
    padding: 10px 16px;
    border-radius: 10px;
    border: none;
    background: var(--bg-tab);
    color: rgba(243, 241, 255, 0.6);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    /* Mobile-first touch targets */
    min-width: 80px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.filter-tab:hover {
    background: var(--bg-tab-hover);
    color: rgba(243, 241, 255, 0.8);
}

.filter-tab.active {
    background: var(--bg-tab-active);
    color: #fdf7ff;
    border: 1px solid rgba(255, 255, 255, 0.25);
}

.filter-tab:active {
    transform: scale(0.98);
}

#itemSortSelect {
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: var(--bg-select);
    color: #fff;
    font-size: 0.85rem;
    font-family: inherit;
    cursor: pointer;
    /* Mobile-first touch targets */
    min-height: 44px;
}

#itemSortSelect:focus {
    outline: none;
    border-color: #845ec2;
}

#unifiedItemList {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Item cards within unified list are styled inline in createItemCard() */
/* Additional utility classes for consistent styling */
.item-card-button {
    flex: 1;
    padding: 10px 12px;
    border-radius: 10px;
    border: none;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    /* Mobile-first touch targets */
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.item-card-button:active {
    transform: scale(0.98);
}

@media (orientation: landscape) {
    .filter-tabs {
        justify-content: flex-start;
    }

    #unifiedItemList {
        max-height: calc(100vh - 350px);
        overflow-y: auto;
    }
}

/* Startup Screen / Save Slot Selection */
.startup-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-main);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 2000;
    overflow-y: auto;
    box-sizing: border-box;
}

.startup-container {
    width: min(450px, 100%);
    max-width: 100%;
    margin: 0 auto;
}

.save-slot-card {
    background: var(--bg-hero-card);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: all 0.2s ease;
}

.save-slot-card:hover {
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.save-slot-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.save-slot-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.save-slot-info {
    min-height: 60px;
    display: flex;
    align-items: center;
}

.save-slot-btn {
    width: 100%;
    padding: 12px 20px;
    border-radius: 12px;
    border: none;
    background: var(--btn-tertiary);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 8px 16px var(--btn-tertiary-shadow);
}

body:not(.true-dark) .save-slot-btn {
    color: #fdf7ff;
}

body.true-dark .save-slot-btn {
    color: #000000;
}

.save-slot-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 20px var(--btn-tertiary-shadow);
}

.save-slot-btn:active {
    transform: translateY(1px);
    box-shadow: 0 4px 8px var(--btn-tertiary-shadow);
}

.delete-slot-btn {
    transition: all 0.2s ease;
}

.delete-slot-btn:hover {
    background: rgba(255, 77, 109, 0.3) !important;
    border-color: rgba(255, 77, 109, 0.7) !important;
}

.delete-slot-btn:active {
    transform: scale(0.95);
}

/* Dungeon card and button styles */
.dungeon-card {
    background: rgba(0, 0, 0, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 20px;
    transition: all 0.2s ease;
}

.dungeon-card.locked {
    opacity: 0.6;
}

.dungeon-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.dungeon-enter-btn {
    width: 100%;
    padding: 12px 20px;
    border-radius: 12px;
    border: none;
    background: var(--btn-tertiary);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 8px 16px var(--btn-tertiary-shadow);
}

body:not(.true-dark) .dungeon-enter-btn {
    color: #fdf7ff;
}

body.true-dark .dungeon-enter-btn {
    color: #000000;
}

.dungeon-enter-btn:hover:not(.disabled) {
    transform: translateY(-1px);
    box-shadow: 0 10px 20px var(--btn-tertiary-shadow);
}

.dungeon-enter-btn:active:not(.disabled) {
    transform: translateY(1px);
}

.dungeon-enter-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: rgba(100, 100, 100, 0.3);
    box-shadow: none;
}

/* Low HP avatar pulse animation */
@keyframes lowHpPulse {
    0%, 100% {
        box-shadow: 0 0 20px rgba(255, 77, 109, 0.8);
        border-color: #ff4d6d;
    }
    50% {
        box-shadow: 0 0 40px rgba(255, 77, 109, 1);
        border-color: #ff2d4d;
    }
}
.discord-btn {
    display: block;
    width: fit-content;
    margin: 24px auto 0;
    padding: 10px 24px;
    border-radius: 9999px;
    background: #5865F2;
    color: #ffffff;
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
    box-shadow: 0 10px 20px rgba(88, 101, 242, 0.25);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.discord-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 28px rgba(88, 101, 242, 0.35);
}

.discord-btn:active {
    transform: translateY(1px);
    box-shadow: 0 6px 12px rgba(88, 101, 242, 0.2);
}

.pwa-banner {
    position: fixed;
    left: 50%;
    bottom: calc(env(safe-area-inset-bottom) + 20px);
    transform: translateX(-50%);
    width: min(100% - 32px, 440px);
    padding: 16px 18px;
    border-radius: 18px;
    background: rgba(18, 16, 31, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 24px 48px rgba(10, 8, 20, 0.45);
    display: flex;
    align-items: center;
    gap: 16px;
    z-index: 5000;
    backdrop-filter: blur(20px);
}

.pwa-banner__content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    text-align: left;
}

.pwa-banner__content strong {
    font-size: 0.95rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.88);
}

.pwa-banner__content span {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.65);
}

.pwa-banner__actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.pwa-banner__install {
    padding: 8px 16px;
    border-radius: 999px;
    border: none;
    background: linear-gradient(120deg, #92fe9d, #00c9ff);
    color: #0a0913;
    font-weight: 600;
    font-size: 0.8rem;
    cursor: pointer;
    box-shadow: 0 12px 20px rgba(0, 201, 255, 0.25);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.pwa-banner__install:hover {
    transform: translateY(-1px);
    box-shadow: 0 16px 24px rgba(0, 201, 255, 0.3);
}

.pwa-banner__install:active {
    transform: translateY(1px);
    box-shadow: 0 6px 12px rgba(0, 201, 255, 0.2);
}

.pwa-banner__dismiss {
    background: transparent;
    color: rgba(255, 255, 255, 0.45);
    border: none;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 6px;
}

.pwa-banner__dismiss:hover {
    color: rgba(255, 255, 255, 0.8);
}

.pwa-banner--ios .pwa-banner__dismiss {
    padding: 8px 16px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

@media (max-width: 520px) {
    .pwa-banner {
        bottom: calc(env(safe-area-inset-bottom) + 12px);
        padding: 14px 16px;
        width: min(100% - 16px, 420px);
    }

    .pwa-banner__content strong {
        font-size: 0.9rem;
    }

    .pwa-banner__content span {
        font-size: 0.75rem;
    }
}
