@import url('https://fonts.googleapis.com/css2?family=Google+Sans:ital,opsz,wght@0,17..18,400..700;1,17..18,400..700&display=swap');

/* ==========================================================================
   CSS VARIABLES & DESIGN TOKENS
   ========================================================================== */
   :root {
    /* Colors */
    --primary: #FF8800;
    --primary-glow: rgba(255, 136, 0, 0.4);
    --secondary: #2f3542;
    --bg-dark: #121212;
    --bg-dark-surface: #1e1e1e;
    --bg-light: #f8f9fa;
    --bg-light-surface: #ffffff;
    --text-dark: #ffffff;
    --text-dark-muted: #a4b0be;
    --text-light: #2f3542;
    --text-light-muted: #747d8c;
    
    /* Character Colors */
    --gourmet-color: #eccc68;
    --broke-color: #ff7f50;
    --toxic-color: #2ed573;

    /* Typography */
    --font-sans: 'Google Sans', 'Product Sans', 'Plus Jakarta Sans', 'Inter', sans-serif;
    --font-display: 'Google Sans', 'Product Sans', 'Plus Jakarta Sans', 'Outfit', sans-serif;
    
    /* Layout */
    --max-width: 480px;
    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --radius-pill: 9999px;
    
    /* Current Theme Variables (Default Dark) */
    --bg: var(--bg-dark);
    --surface: var(--bg-dark-surface);
    --text: var(--text-dark);
    --text-muted: var(--text-dark-muted);
    --glass-bg: rgba(30, 30, 30, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
}

.light-mode {
    --bg: var(--bg-light);
    --surface: var(--bg-light-surface);
    --text: var(--text-light);
    --text-muted: var(--text-light-muted);
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(0, 0, 0, 0.1);
}

/* ==========================================================================
   RESET & BASE
   ========================================================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.5;
    transition: background-color 0.3s ease, color 0.3s ease;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    overflow: hidden; /* Prevent pull-to-refresh on mobile apps */
}

/* ==========================================================================
   LAYOUT
   ========================================================================== */
.app-container {
    width: 100%;
    max-width: var(--max-width);
    height: 100vh;
    height: 100dvh;
    position: relative;
    overflow: hidden;
    background: var(--bg);
    box-shadow: 0 0 40px rgba(0,0,0,0.1);
}

.view {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 20px;
    padding-top: 80px; /* space for header */
    opacity: 0;
    pointer-events: none;
    transform: translateX(20px);
    transition: opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1), transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

.view.active {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(0);
}

/* ==========================================================================
   HEADER
   ========================================================================== */
.app-header {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    max-width: var(--max-width);
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 100;
    pointer-events: none;
}

.app-header > * {
    pointer-events: auto;
}

.app-header.hidden {
    transform: translateY(-100%);
    opacity: 0;
    pointer-events: none;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.logo-img {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    object-fit: cover;
    box-shadow: 0 4px 15px var(--primary-glow);
}

.logo-text {
    font-family: var(--font-display);
    font-weight: 900;
    font-size: 24px;
    letter-spacing: -0.5px;
}

.theme-toggle {
    background: var(--surface);
    border: 1px solid var(--glass-border);
    color: var(--text);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.theme-toggle:hover {
    transform: scale(1.05);
}

.theme-toggle .icon-moon { display: none; }
.light-mode .theme-toggle .icon-sun { display: none; }
.light-mode .theme-toggle .icon-moon { display: block; }

/* ==========================================================================
   TYPOGRAPHY & UTILITIES
   ========================================================================== */
h2, h3, h4 {
    font-family: var(--font-display);
    font-weight: 700;
}

.text-gradient {
    background: linear-gradient(135deg, var(--primary), #FFD200);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.w-full { width: 100%; }
.mt-4 { margin-top: 16px; }
.mt-2 { margin-top: 8px; }
.flex-col { display: flex; flex-direction: column; }

/* ==========================================================================
   BUTTONS
   ========================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px 24px;
    border-radius: var(--radius-pill);
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 16px;
    border: none;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    text-decoration: none;
}

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

.btn.disabled {
    opacity: 0.5;
    pointer-events: none;
}

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

.btn-primary.btn-glow {
    box-shadow: 0 8px 24px var(--primary-glow);
}

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

.btn-outline {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--glass-border);
}
.btn-outline:hover {
    background: var(--surface);
}

.btn-text {
    background: transparent;
    color: var(--text-muted);
}

.btn-large {
    padding: 20px 32px;
    font-size: 18px;
}

.btn-back {
    background: transparent;
    border: none;
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    cursor: pointer;
    border-radius: 50%;
    margin-left: -10px;
}

.btn-back:hover {
    background: var(--surface);
}

/* ==========================================================================
   LANDING PAGE (VIEW 1)
   ========================================================================== */
#view-landing {
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
#view-landing::-webkit-scrollbar {
    display: none;
}

.hero {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: min-content;
    position: relative;
    z-index: 2;
    padding-bottom: 40px;
}

.hero-badge {
    display: inline-block;
    padding: 6px 12px;
    background: var(--surface);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-pill);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    width: fit-content;
    margin-bottom: 16px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.hero-title {
    font-size: 48px;
    line-height: 1.1;
    margin-bottom: 16px;
    letter-spacing: -1px;
}

.hero-subtitle {
    font-size: 16px;
    color: var(--text-muted);
    margin-bottom: 32px;
    max-width: 80%;
}

.cta-group {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.mockup-cards {
    position: absolute;
    right: -25px;
    top: 10%;
    z-index: 3;
    opacity: 0.8;
    pointer-events: none;
}

.floating-card {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    padding: 12px 20px;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 18px;
    position: absolute;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    white-space: nowrap;
}

.c1 { top: 0; right: 0; animation: float 6s ease-in-out infinite; transform: rotate(5deg); }
.c2 { top: 70px; right: 40px; animation: float 7s ease-in-out infinite 1s; transform: rotate(-5deg); }
.c3 { top: 140px; right: 10px; animation: float 5s ease-in-out infinite 2s; transform: rotate(10deg); }

@keyframes float {
    0% { transform: translateY(0) rotate(5deg); }
    50% { transform: translateY(-10px) rotate(8deg); }
    100% { transform: translateY(0) rotate(5deg); }
}

/* ==========================================================================
   COMMON VIEW ELEMENTS
   ========================================================================== */
.view-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 24px;
}

.view-header h3 {
    font-size: 24px;
}

.action-footer {
    margin-top: auto;
    padding-bottom: 20px;
}

/* ==========================================================================
   SOLO MODE: CHARACTER SELECT (VIEW 2)
   ========================================================================== */
.character-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 4px;
    padding-bottom: 20px;
}

.character-card {
    background: var(--surface);
    border: 2px solid transparent;
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    cursor: pointer;
    transition: all 0.2s;
}

.character-card.selected {
    border-color: var(--char-color, var(--primary));
    background: rgba(255,255,255,0.02);
    transform: scale(1.02);
}

.char-icon {
    font-size: 32px;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--glass-border);
    border-radius: 50%;
}

.char-info h4 {
    font-size: 18px;
    margin-bottom: 4px;
}

.char-info p {
    font-size: 13px;
    color: var(--text-muted);
}

/* ==========================================================================
   SOLO MODE: ROULETTE (VIEW 3)
   ========================================================================== */
.slot-machine-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.slot-window {
    width: 100%;
    height: 180px;
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--glass-border);
    position: relative;
    overflow: hidden;
    box-shadow: inset 0 10px 20px rgba(0,0,0,0.2);
}

.slot-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom, 
        var(--surface) 0%, 
        rgba(30,30,30,0) 20%, 
        rgba(30,30,30,0) 80%, 
        var(--surface) 100%);
    pointer-events: none;
    border-radius: var(--radius-lg);
}

.fast-spin-transition {
    transition: transform 2.0s cubic-bezier(0.15, 0.95, 0.25, 1);
}

.slot-reel {
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: transform 3s cubic-bezier(0.15, 0.85, 0.15, 1);
}

.slot-item {
    height: 180px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 700;
    font-family: var(--font-display);
    gap: 10px;
}

.slot-item .icon {
    font-size: 64px;
}

/* ==========================================================================
   DUO MODE: ROOM (VIEW 4)
   ========================================================================== */
#view-duo-room {
    overflow-y: auto;
    padding-bottom: 40px;
}

.room-invite-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 32px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    border: 1px solid var(--glass-border);
}

.qr-placeholder {
    width: 150px;
    height: 150px;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    color: black;
    margin-bottom: 24px;
    position: relative;
}

.qr-placeholder svg {
    width: 100px;
    height: 100px;
}

.room-invite-card h4 {
    font-size: 20px;
    margin-bottom: 8px;
}

.room-invite-card p {
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 16px;
}

.link-box {
    display: flex;
    align-items: center;
    background: var(--bg);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    width: 100%;
    justify-content: space-between;
    font-family: monospace;
    font-size: 14px;
    color: var(--primary);
    margin-bottom: 32px;
}

.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-muted);
    font-size: 14px;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--glass-border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ==========================================================================
   DUO MODE: SWIPE (VIEW 5)
   ========================================================================== */
.swipe-progress {
    flex: 1;
    height: 6px;
    background: var(--surface);
    border-radius: var(--radius-pill);
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--primary);
    width: 0%;
    transition: width 0.3s ease;
}

.swipe-container {
    flex: 1;
    position: relative;
    width: 100%;
    perspective: 1000px;
}

.swipe-card {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    user-select: none;
    touch-action: none; /* Crucial for touch dragging */
    transform-origin: 50% 100%;
    will-change: transform;
}

.swipe-card .icon {
    font-size: 80px;
    margin-bottom: 24px;
}

.swipe-card h2 {
    font-size: 26px;
    margin-bottom: 12px;
    text-align: center;
    padding: 0 20px;
    line-height: 1.3;
}

.swipe-card .category {
    font-size: 16px;
    color: var(--text-muted);
    margin-bottom: 16px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.swipe-card .tags {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
    padding: 0 16px;
}

.swipe-controls {
    display: flex;
    justify-content: center;
    gap: 32px;
    padding: 20px 0;
    position: relative;
    z-index: 100;
}

.btn-swipe {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    transition: transform 0.2s;
}

.btn-swipe:active {
    transform: scale(0.9);
}

.btn-swipe svg {
    width: 32px;
    height: 32px;
}

.btn-nope {
    background: var(--surface);
    color: #ff4757;
    border: 1px solid var(--glass-border);
}

.btn-like {
    background: var(--surface);
    color: #2ed573;
    border: 1px solid var(--glass-border);
}

/* ==========================================================================
   MODALS
   ========================================================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    width: 90%;
    max-width: 360px;
    background: var(--surface);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 32px;
    text-align: center;
    transform: scale(0.9) translateY(20px);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.active .modal-content {
    transform: scale(1) translateY(0);
}

.result-icon {
    font-size: 80px;
    margin-bottom: 16px;
    animation: bounce 2s infinite;
}

.result-title {
    font-size: 32px;
    margin-bottom: 8px;
}

.result-tags {
    margin-bottom: 32px;
}

.tag {
    display: inline-block;
    padding: 4px 10px;
    background: var(--glass-border);
    border-radius: var(--radius-sm);
    font-size: 12px;
    color: var(--text-muted);
    margin: 0 4px;
}

.modal-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Match Panel Specific */
.match-panel {
    background: linear-gradient(to bottom, var(--surface), rgba(255, 71, 87, 0.1));
    border: 2px solid var(--primary);
}

.match-badge {
    background: var(--primary);
    color: white;
    font-weight: 800;
    font-size: 14px;
    padding: 8px 16px;
    border-radius: var(--radius-pill);
    display: inline-block;
    margin-bottom: 24px;
    letter-spacing: 1px;
}

.match-animation {
    animation: heartbeat 1.5s infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

@keyframes heartbeat {
    0% { transform: scale(1); }
    14% { transform: scale(1.1); }
    28% { transform: scale(1); }
    42% { transform: scale(1.1); }
    70% { transform: scale(1); }
}

#confetti-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 999;
}

/* ==========================================================================
   FRIDGE MODE (VIEW 6)
   ========================================================================== */
.ingredient-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 10px 12px;
    margin: 0 -12px;
    overflow-y: auto;
    flex: 1;
    align-content: flex-start;
}

.btn-mode {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    width: 100%;
    padding: 12px 24px;
    background: var(--surface);
    border: 1px solid var(--glass-border);
    border-radius: 50px;
    color: var(--text-color);
    text-align: left;
    transition: var(--transition);
    cursor: pointer;
    font-family: inherit;
    user-select: none;
}

.btn-mode:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

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

.btn-mode-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.btn-mode-icon svg {
    stroke: url(#brandGradient);
    transition: var(--transition);
}

#btn-solo-mode .btn-mode-icon svg {
    stroke: #ffffff;
}

.btn-mode-text {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
}

.btn-mode-title {
    font-size: 16px;
    font-weight: 600;
}

.btn-mode-desc {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 400;
    line-height: 1.2;
}

.ingredient-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--surface);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-pill);
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}

.ingredient-chip:hover {
    transform: scale(1.05);
}

.ingredient-chip.selected {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 4px 15px var(--primary-glow);
    transform: scale(1.05);
}

.recipe-instructions {
    text-align: left;
    background: rgba(0,0,0,0.2);
    padding: 16px;
    border-radius: var(--radius-md);
    margin-top: 16px;
}

.light-mode .recipe-instructions {
    background: rgba(0,0,0,0.05);
}

.recipe-step {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 8px;
    line-height: 1.4;
}

.recipe-step:last-child {
    margin-bottom: 0;
}

/* ==========================================================================
   GLOBAL LOADER
   ========================================================================== */
.loader-question {
    font-size: 80px;
    margin-top: 16px;
    margin-bottom: 16px;
    animation: question-bounce 1.5s infinite ease-in-out;
    filter: drop-shadow(0 0 10px var(--primary-glow));
    user-select: none;
    display: none;
}

@keyframes question-bounce {
    0%, 100% { 
        transform: translateY(0) scale(1) rotate(0deg); 
    }
    50% { 
        transform: translateY(-10px) scale(1.1) rotate(360deg); 
    }
}

.food-loader {
    display: flex;
    gap: 20px;
    justify-content: center;
    align-items: center;
    margin-bottom: 24px;
    height: 80px;
}

.food-bounce {
    font-size: 48px;
    animation: food-jump 1s ease-in-out infinite;
    filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.15));
    user-select: none;
}

.food-bounce.item-1 { animation-delay: 0s; }
.food-bounce.item-2 { animation-delay: 0.15s; }
.food-bounce.item-3 { animation-delay: 0.3s; }
.food-bounce.item-4 { animation-delay: 0.45s; }

@keyframes food-jump {
    0%, 100% {
        transform: translateY(0) scale(1);
    }
    50% {
        transform: translateY(-30px) scale(1.15);
        filter: drop-shadow(0 15px 12px rgba(0, 0, 0, 0.2));
    }
}

.btn-spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 3px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: loader-spin 1s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}

@keyframes loader-spin {
    to { transform: rotate(360deg); }
}

.duo-mode-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    transition: var(--transition);
}

.duo-mode-group.has-resume {
    gap: 0;
    background: var(--surface);
    border: 1px solid var(--glass-border);
    border-radius: 32px;
    padding: 0;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.duo-mode-group.has-resume .btn-mode {
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 16px 24px;
}

.duo-mode-group.has-resume #btn-duo-mode {
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.duo-mode-group.has-resume .btn-mode:hover {
    background: rgba(255, 255, 255, 0.05);
    transform: none;
    box-shadow: none;
}

.duo-mode-group.has-resume .btn-mode:active {
    transform: none;
    background: rgba(255, 255, 255, 0.1);
}

/* Cooking Active Animation */
.cooking-active {
    animation: cookActive 0.8s ease infinite !important;
}

@keyframes cookActive {
    0% { transform: scale(1) translateY(0) rotate(0deg); }
    25% { transform: scale(1.15) translateY(-15px) rotate(-15deg); }
    50% { transform: scale(1) translateY(0) rotate(0deg); }
    75% { transform: scale(1.15) translateY(-15px) rotate(15deg); }
    100% { transform: scale(1) translateY(0) rotate(0deg); }
}
