:root {
    --bg-dark: #1a120b;
    --bg-surface: #3c2a21;
    --bg-card: rgba(60, 42, 33, 0.85);
    --primary: #e0a64e;
    --primary-glow: rgba(224, 166, 78, 0.4);
    --secondary: #d5cea3;
    --text-main: #f5ebe0;
    --text-muted: #d5cea3;
    --danger: #ff4b4b;
    --success: #4bffb0;
    --exp-color: #a855f7;
    --hp-color: #ef4444;
    --energy-color: #3b82f6;
    --border: rgba(224, 166, 78, 0.3);
    --radius: 12px;
}

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

body {
    margin: 0;
    padding: 0;
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    overflow: hidden;
    height: 100vh;
    height: 100dvh;
    width: 100vw;
}

#game-container {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 500px;
    margin: 0 auto;
    background: radial-gradient(circle at center, #2c1e14 0%, #1a120b 100%);
    overflow: hidden;
}

/* Base View Styles */
.view {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    padding: 20px;
    /* Top Padding for Status Bar */
    padding-top: max(30px, env(safe-area-inset-top));
    /* Bottom Padding for Home Indicator */
    padding-bottom: max(20px, env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.3s ease-out;
}

.hidden {
    display: none !important;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Overlays */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(5px);
}

.loader {
    width: 48px;
    height: 48px;
    border: 5px solid var(--primary);
    border-bottom-color: transparent;
    border-radius: 50%;
    animation: rotation 1s linear infinite;
    margin-bottom: 15px;
}

@keyframes rotation {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

@keyframes popIn {
    from {
        opacity: 0;
        transform: translate(-50%, -40%) scale(0.9);
    }

    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

#notification-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) !important;
    z-index: 5000;
    width: 90%;
    max-width: 400px;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

h1 {
    font-size: 24px;
    margin: 0;
    font-weight: 700;
    color: var(--primary);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.badge {
    padding: 4px 12px;
    background: var(--bg-surface);
    border: 1px solid var(--primary);
    border-radius: 20px;
    font-weight: 600;
    font-size: 14px;
}

/* Pet Visuals */
.pet-visual-container {
    position: relative;
    flex: 1;
    min-height: 180px;
    max-height: 250px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
}

.pet-aura {
    position: absolute;
    width: 200px;
    height: 200px;
    background: var(--primary-glow);
    filter: blur(40px);
    border-radius: 50%;
    animation: pulse 2s ease-in-out infinite;
}

#pet-image {
    max-width: 80%;
    max-height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.5));
    z-index: 1;
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 0.4;
    }

    50% {
        transform: scale(1.1);
        opacity: 0.6;
    }
}

/* Stats Card */
.stats-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    margin-bottom: 10px;
}

.stat-row {
    margin-bottom: 12px;
}

.stat-row:last-child {
    margin-bottom: 0;
}

.label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 5px;
    color: var(--text-muted);
}

.progress-container {
    height: 20px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.progress-bar {
    height: 100%;
    width: 0%;
    transition: width 0.5s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

.progress-bar.exp {
    background: var(--exp-color);
}

.progress-bar.hp {
    background: var(--hp-color);
}

.progress-bar.energy {
    background: var(--energy-color);
}

.progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 11px;
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

.aura-info {
    text-align: center;
    font-size: 13px;
    color: var(--primary);
    font-weight: 600;
    margin-bottom: 15px;
}

/* Action Buttons */
.action-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.lane-choice-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    width: 100%;
}

.btn {
    padding: 14px;
    border: none;
    border-radius: var(--radius);
    font-family: inherit;
    font-weight: 700;
    font-size: 15px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

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

.primary {
    background: var(--primary);
    color: #1a120b;
    grid-column: span 2;
    box-shadow: 0 4px 15px rgba(224, 166, 78, 0.3);
}

.secondary {
    background: var(--bg-surface);
    color: var(--text-main);
    border: 1px solid var(--border);
}

.danger {
    background: var(--danger);
    color: white;
}

.success {
    background: var(--success);
    color: #1a120b;
}

.full-width {
    grid-column: span 2;
    width: 100%;
}

/* Scene & Logs (Lane/Battle) */
.scene-container {
    position: relative;
    height: 200px;
    background: #000;
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 15px;
    border: 2px solid var(--border);
}

.scene-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.log-container {
    flex: 1;
    background: rgba(0, 0, 0, 0.4);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 10px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    margin-bottom: 15px;
}

.log-header {
    font-size: 11px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 8px;
    opacity: 0.7;
}

.log-content {
    flex: 1;
    overflow-y: auto;
    font-size: 13px;
    line-height: 1.5;
}

.log-entry {
    margin-bottom: 6px;
    animation: slideIn 0.2s ease-out;
}

@keyframes slideIn {
    from {
        transform: translateX(-10px);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Battle Specifics */
.battle-header {
    text-align: center;
    font-weight: 800;
    color: var(--danger);
    font-size: 20px;
    margin-bottom: 15px;
}

.combatants {
    display: flex;
    justify-content: space-between;
    gap: 15px;
    margin-bottom: 15px;
}

.combatant {
    flex: 1;
}

.hp-tag {
    font-size: 11px;
    font-weight: 700;
    margin-bottom: 4px;
}

.hp-bar-outer {
    height: 8px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 4px;
    overflow: hidden;
}

.hp-bar-inner {
    height: 100%;
    width: 100%;
    background: var(--success);
    transition: width 0.3s;
}

.hp-bar-inner.danger {
    background: var(--danger);
}

.battle-scene {
    position: relative;
    height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 15px;
}

#enemy-image {
    max-height: 100%;
    max-width: 100%;
    filter: drop-shadow(0 0 15px var(--danger));
}

.atk-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 10px;
}

.action-btn {
    background: var(--bg-surface);
    border: 1px solid var(--primary);
    color: var(--text-main);
    padding: 12px;
}

.action-btn:disabled {
    opacity: 0.5;
    filter: grayscale(1);
    cursor: not-allowed;
}

/* Damage Numbers */
.dmg-popup {
    position: absolute;
    font-weight: 800;
    font-size: 24px;
    color: var(--danger);
    pointer-events: none;
    animation: floatUp 0.8s ease-out forwards;
    text-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
    z-index: 10;
}

@keyframes floatUp {
    0% {
        transform: translateY(0);
        opacity: 1;
    }

    100% {
        transform: translateY(-50px);
        opacity: 0;
    }
}

/* Modals */
.modal {
    background: var(--bg-surface);
    width: 90%;
    max-width: 400px;
    border-radius: var(--radius);
    border: 2px solid var(--primary);
    padding: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
}

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

.modal h2 {
    margin: 0;
    color: var(--primary);
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 28px;
    cursor: pointer;
}

.item-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.item-card {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
    padding: 12px;
    border-radius: 8px;
    text-align: center;
}

.item-card img {
    width: 40px;
    height: 40px;
    margin-bottom: 8px;
}

.item-card .name {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 4px;
}

.item-card .qty {
    font-size: 11px;
    color: var(--text-muted);
    display: block;
    margin-bottom: 8px;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 5px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 10px;
}