/* Flutter & Material 3 Mobile Application Styling */
:root {
    --primary: #6C5CE7;
    --primary-light: #A29BFE;
    --primary-dark: #5844E3;
    --accent: #00CEC9;
    --gold: #FDCB6E;
    --gold-dark: #E1B12C;
    --bg-main: #0B0C18;
    --bg-surface: #15172C;
    --bg-card: #1D2140;
    --text-color: #FFFFFF;
    --text-sub: #8D93A8;
    --success: #00B894;
    --danger: #FF7675;
    --safe-area-top: env(safe-area-inset-top, 0px);
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    width: 100%;
    height: 100%;
    height: 100dvh;
    overflow: hidden;
    background-color: var(--bg-main);
    color: var(--text-color);
    touch-action: none;
}

#appRoot {
    width: 100%;
    max-width: 480px;
    height: 100%;
    height: 100dvh;
    margin: 0 auto;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.8);
    background: radial-gradient(circle at 50% 15%, #1A1D36 0%, #0B0C18 100%);
}

/* Screen Transitions */
.app-screen {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    z-index: 10;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.app-screen.active {
    display: flex;
    opacity: 1;
    z-index: 20;
}

/* Top App Bar */
.app-header {
    height: 60px;
    padding: 0 14px;
    padding-top: var(--safe-area-top);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(21, 23, 44, 0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    z-index: 30;
}

.header-title {
    font-size: 16px;
    font-weight: 800;
    background: linear-gradient(135deg, #FFF, var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.header-stats {
    display: flex;
    align-items: center;
    gap: 8px;
}

.stat-pill {
    display: flex;
    align-items: center;
    gap: 5px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    padding: 4px 9px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    transition: transform 0.15s;
}

.stat-pill:active {
    transform: scale(0.94);
}

.stat-pill.gold {
    color: var(--gold);
    border-color: rgba(253, 203, 110, 0.35);
    background: rgba(253, 203, 110, 0.08);
}

.stat-pill.star {
    color: #FFA502;
    border-color: rgba(255, 165, 2, 0.3);
}

.icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.15s, background 0.15s;
}

.icon-btn:active {
    transform: scale(0.9);
    background: rgba(255, 255, 255, 0.15);
}

/* Side-by-Side 100-Level Grid View */
.saga-scroll-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    padding: 14px 12px 40px 12px;
    scroll-behavior: smooth;
    touch-action: pan-y;
}

.saga-path {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.chapter-container {
    background: rgba(26, 29, 54, 0.5);
    border-radius: 18px;
    padding: 12px 10px;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.chapter-header {
    margin-bottom: 10px;
    padding-left: 4px;
}

.chapter-header h4 {
    font-size: 12px;
    font-weight: 700;
    color: var(--primary-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* 5 Column Clean Side-by-Side Grid */
.level-grid-box {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
}

.level-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
}

.level-btn {
    width: 100%;
    aspect-ratio: 1 / 1;
    max-width: 56px;
    max-height: 56px;
    border-radius: 15px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    background: #181B33;
    color: var(--text-sub);
    font-size: 15px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.level-btn.active {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-color: rgba(255, 255, 255, 0.6);
    color: #fff;
    box-shadow: 0 5px 14px rgba(108, 92, 231, 0.5);
}

.level-btn.pulse {
    animation: levelPulse 1.8s infinite;
    border-color: var(--gold);
    background: linear-gradient(135deg, #FF7675, #6C5CE7);
}

@keyframes levelPulse {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(108, 92, 231, 0.7); }
    70% { transform: scale(1.08); box-shadow: 0 0 0 10px rgba(108, 92, 231, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(108, 92, 231, 0); }
}

.level-btn:active {
    transform: scale(0.92);
}

.level-card-stars {
    display: flex;
    gap: 1px;
}

.level-card-stars .star {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.2);
}

.level-card-stars .star.filled {
    color: var(--gold);
    text-shadow: 0 0 5px rgba(253, 203, 110, 0.8);
}

.star-placeholder {
    font-size: 9px;
    color: rgba(255, 255, 255, 0.1);
}

/* Reward Cards in Daily Modal */
.reward-card {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(253, 203, 110, 0.25);
    border-radius: 16px;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.reward-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.reward-icon {
    font-size: 26px;
}

.reward-info h4 {
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 2px;
}

.reward-sub {
    font-size: 12px;
    color: var(--gold);
}

/* Modals & Dialogs (Flutter Style) */
.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.modal-overlay.active {
    display: flex;
    opacity: 1;
}

.flutter-dialog {
    width: 100%;
    max-width: 360px;
    background: var(--bg-card);
    border-radius: 28px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7);
    padding: 24px 20px;
    text-align: center;
    transform: scale(0.88);
    transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-overlay.active .flutter-dialog {
    transform: scale(1);
}

.dialog-badge {
    font-size: 42px;
    margin-bottom: 6px;
}

.dialog-title {
    font-size: 19px;
    font-weight: 800;
    margin-bottom: 5px;
    background: linear-gradient(135deg, #FFF, var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.dialog-desc {
    font-size: 13px;
    color: var(--text-sub);
    margin-bottom: 16px;
}

.dialog-stats-box {
    background: rgba(0, 0, 0, 0.25);
    border-radius: 16px;
    padding: 12px;
    display: flex;
    justify-content: space-around;
    margin-bottom: 18px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.stat-item h5 {
    font-size: 11px;
    color: var(--text-sub);
    text-transform: uppercase;
    margin-bottom: 4px;
}

.stat-item span {
    font-size: 16px;
    font-weight: 800;
    color: #fff;
}

/* Flutter Elevated Buttons */
.flutter-btn {
    width: 100%;
    padding: 13px 18px;
    border-radius: 15px;
    font-size: 14px;
    font-weight: 700;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 5px 16px rgba(0, 0, 0, 0.3);
    transition: transform 0.15s, opacity 0.2s;
    margin-bottom: 8px;
}

.flutter-btn:active {
    transform: scale(0.96);
}

.flutter-btn.primary {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff;
    box-shadow: 0 6px 18px rgba(108, 92, 231, 0.45);
}

.flutter-btn.success {
    background: linear-gradient(135deg, var(--success), #00CEC9);
    color: #fff;
}

.flutter-btn.secondary {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.flutter-btn.danger {
    background: var(--danger);
    color: #fff;
}

/* Bottom Sheets */
.bottom-sheet-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.65);
    display: none;
    z-index: 100;
    align-items: flex-end;
}

.bottom-sheet-overlay.active {
    display: flex;
}

.bottom-sheet {
    width: 100%;
    background: var(--bg-surface);
    border-radius: 26px 26px 0 0;
    padding: 18px 20px;
    padding-bottom: calc(20px + var(--safe-area-bottom));
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    max-height: 85vh;
    overflow-y: auto;
}

.bottom-sheet-overlay.active .bottom-sheet {
    transform: translateY(0);
}

.sheet-handle {
    width: 40px;
    height: 4px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.2);
    margin: 0 auto 14px auto;
}

.sheet-title {
    font-size: 17px;
    font-weight: 800;
    margin-bottom: 14px;
    text-align: center;
}

.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.setting-label {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    font-weight: 600;
}

.developer-card {
    background: rgba(255, 255, 255, 0.04);
    border-radius: 14px;
    padding: 12px 14px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    margin: 14px 0 6px 0;
    text-align: center;
}

.developer-card h5 {
    font-size: 13px;
    color: var(--primary-light);
    margin-bottom: 4px;
}

.developer-card a {
    color: var(--accent);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    display: block;
    margin-bottom: 2px;
}

.developer-card small {
    color: var(--text-sub);
    font-size: 12px;
}

/* Switch Toggles */
.switch {
    position: relative;
    display: inline-block;
    width: 46px;
    height: 26px;
}

.switch input { opacity: 0; width: 0; height: 0; }

.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(255, 255, 255, 0.15);
    transition: .3s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--primary);
}

input:checked + .slider:before {
    transform: translateX(20px);
}

/* Toast */
.app-toast {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(50px);
    background: rgba(26, 29, 54, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #fff;
    padding: 12px 24px;
    border-radius: 30px;
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 200;
    white-space: nowrap;
}

.app-toast.active {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}
