/* ===== CSS Variables ===== */
:root {
    --bg-primary: #1e1e2e;
    --bg-secondary: #2a2a3e;
    --bg-card: #353548;
    --accent-primary: #ff6b9d;
    --accent-secondary: #ffd166;
    --success: #06d6a0;
    --warning: #ffd166;
    --error: #ff6b6b;
    --text-primary: #ffffff;
    --text-secondary: #b8b8d0;
    --text-muted: #6b6b80;
    --border-color: #3d3d52;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --transition: all 0.3s ease;
}

/* ===== Reset & Base ===== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.5;
    overflow-x: hidden;
}

/* ===== Ad Containers ===== */
.ad-container {
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px dashed var(--border-color);
}

.ad-placeholder {
    color: var(--text-muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.ad-top {
    width: 100%;
    height: 90px;
    max-width: 728px;
    margin: 0 auto;
}

.ad-sidebar {
    display: none;
    position: fixed;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    width: 300px;
    height: 600px;
    background: var(--bg-secondary);
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-md);
}

.ad-bottom {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 100px;
    z-index: 100;
}

.ad-interstitial {
    margin-top: 20px;
    height: 250px;
    width: 100%;
    max-width: 300px;
    border-radius: var(--radius-md);
}

/* ===== App Container ===== */
.app-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 0 16px;
    padding-bottom: 120px;
}

/* ===== Header ===== */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    border-bottom: 1px solid var(--border-color);
}

.logo {
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.logo-accent {
    color: var(--accent-primary);
}

.header-right {
    display: flex;
    gap: 12px;
}

.stat-badge {
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--bg-secondary);
    padding: 6px 12px;
    border-radius: var(--radius-xl);
    font-size: 0.875rem;
    font-weight: 600;
    color: #ffffff !important;
    border: none;
}

button.stat-badge,
button.stat-badge .stat-value,
#energy-display,
#energy-display .stat-value,
#energy-value {
    color: #ffffff !important;
}

.stat-icon {
    font-size: 1rem;
}

.energy-badge {
    border: 1px solid var(--warning);
}

.energy-badge .stat-value {
    color: white !important;
    -webkit-text-fill-color: white !important;
}

.stat-badge.clickable {
    cursor: pointer;
    transition: var(--transition);
}

.stat-badge.clickable:hover {
    transform: scale(1.1);
    box-shadow: 0 0 15px rgba(255, 209, 102, 0.4);
}

.hints-badge {
    border: 1px solid var(--accent-primary);
}

.streak-badge {
    border: 1px solid var(--success);
}

.help-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition);
    font-size: 1rem;
}

.help-btn:hover {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    transform: scale(1.1);
}

/* ===== Navigation Tabs ===== */
.nav-tabs {
    display: flex;
    gap: 4px;
    padding: 16px 0;
    border-bottom: 1px solid var(--border-color);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.nav-tab {
    flex: 1;
    min-width: fit-content;
    padding: 10px 16px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: var(--transition);
    white-space: nowrap;
}

.nav-tab:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.nav-tab.active {
    background: var(--accent-primary);
    color: white;
}

/* ===== Screens ===== */
.screen {
    display: none;
    padding: 20px 0;
}

.screen.active {
    display: block;
}

.screen-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 8px;
    text-align: center;
}

/* ===== Mode Toggle ===== */
.mode-toggle {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}

.mode-btn {
    flex: 1;
    padding: 12px;
    border: 2px solid var(--border-color);
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: var(--transition);
}

.mode-btn:hover {
    border-color: var(--accent-primary);
    color: var(--text-primary);
}

.mode-btn.active {
    background: var(--accent-secondary);
    border-color: var(--accent-primary);
    color: var(--text-primary);
}

/* ===== Daily Progress ===== */
.daily-progress {
    text-align: center;
    margin-bottom: 16px;
}

.progress-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 8px;
}

.progress-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    transition: var(--transition);
}

.progress-dot.active {
    border-color: var(--accent-primary);
    box-shadow: 0 0 10px var(--accent-primary);
}

.progress-dot.completed {
    background: var(--success);
    border-color: var(--success);
}

.progress-dot.skipped {
    background: var(--text-muted);
    border-color: var(--text-muted);
}

.progress-text {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* ===== Category Selector ===== */
.category-selector {
    margin-bottom: 20px;
    text-align: center;
}

.selector-label {
    display: block;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.category-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.category-btn {
    padding: 8px 14px;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-xl);
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.category-btn:hover {
    border-color: var(--accent-primary);
    color: var(--text-primary);
}

.category-btn.active {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
}

/* ===== Category Badge ===== */
.category-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-secondary);
    padding: 8px 16px;
    border-radius: var(--radius-xl);
    margin-bottom: 24px;
}

.category-icon {
    font-size: 1.25rem;
}

.category-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* ===== Emoji Display ===== */
.emoji-display {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    min-height: 120px;
    padding: 24px;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.emoji {
    font-size: 3rem;
    line-height: 1;
    animation: emojiEntrance 0.5s ease-out backwards;
}

.emoji:nth-child(1) { animation-delay: 0.1s; }
.emoji:nth-child(2) { animation-delay: 0.2s; }
.emoji:nth-child(3) { animation-delay: 0.3s; }
.emoji:nth-child(4) { animation-delay: 0.4s; }
.emoji:nth-child(5) { animation-delay: 0.5s; }
.emoji:nth-child(6) { animation-delay: 0.6s; }

/* ===== Timer ===== */
.timer-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
    font-size: 1.25rem;
    color: var(--text-secondary);
}

.timer-value {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

/* ===== Answer Input ===== */
.input-container {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.answer-input {
    flex: 1;
    padding: 16px 20px;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
    transition: var(--transition);
}

.answer-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(233, 69, 96, 0.2);
}

.answer-input::placeholder {
    color: var(--text-muted);
}

.answer-input.correct {
    border-color: var(--success);
    background: rgba(78, 204, 163, 0.1);
}

.answer-input.incorrect {
    border-color: var(--error);
    animation: shake 0.5s ease;
}

.submit-btn {
    width: 56px;
    height: 56px;
    background: var(--accent-primary);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    transition: var(--transition);
}

.submit-btn:hover {
    background: #ff5286;
    transform: scale(1.05);
}

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

/* ===== Hint Display ===== */
.hint-display {
    min-height: 40px;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    text-align: center;
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: 4px;
    display: none;
}

.hint-display.visible {
    display: block;
}

.hint-letter {
    display: inline-block;
    width: 24px;
    color: var(--success);
}

.hint-blank {
    display: inline-block;
    width: 24px;
    color: var(--text-muted);
}

/* ===== Action Buttons ===== */
.action-buttons {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: 24px;
}

.action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.action-btn:hover {
    background: var(--bg-card);
    border-color: var(--accent-primary);
}

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

.btn-icon {
    font-size: 1.5rem;
}

/* ===== Score Bar ===== */
.score-bar {
    display: flex;
    justify-content: space-around;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.score-item {
    text-align: center;
}

.score-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 4px;
}

.score-value {
    font-size: 1.25rem;
    font-weight: 700;
}

/* ===== Leaderboard ===== */
.leaderboard-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}

.lb-tab {
    flex: 1;
    padding: 10px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.lb-tab:hover {
    border-color: var(--accent-primary);
}

.lb-tab.active {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
}

.leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 400px;
    overflow-y: auto;
}

.lb-entry {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.lb-entry.top-3 {
    border-color: var(--warning);
}

.lb-entry.you {
    border-color: var(--accent-primary);
    background: rgba(233, 69, 96, 0.1);
}

.lb-rank {
    font-size: 1rem;
    font-weight: 700;
    width: 40px;
    text-align: center;
}

.lb-rank.gold { color: #ffd700; }
.lb-rank.silver { color: #c0c0c0; }
.lb-rank.bronze { color: #cd7f32; }

.lb-name {
    flex: 1;
    font-weight: 500;
}

.lb-score {
    font-weight: 700;
    color: var(--accent-primary);
}

.your-rank {
    margin-top: 16px;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    border: 2px solid var(--accent-primary);
    text-align: center;
}

.rank-label {
    color: var(--text-secondary);
    margin-right: 8px;
}

.rank-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-primary);
}

/* ===== Rewards Calendar ===== */
.rewards-subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.rewards-calendar {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
    margin-bottom: 24px;
}

.reward-day {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
}

.reward-day:hover:not(.claimed):not(.locked) {
    border-color: var(--accent-primary);
    transform: scale(1.05);
}

.reward-day.available {
    border-color: var(--success);
    animation: pulse 2s infinite;
}

.reward-day.claimed {
    background: rgba(78, 204, 163, 0.2);
    border-color: var(--success);
    cursor: default;
}

.reward-day.locked {
    opacity: 0.5;
    cursor: not-allowed;
}

.reward-day-number {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.reward-day-icon {
    font-size: 1.5rem;
}

.reward-day-label {
    font-size: 0.625rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.streak-info {
    text-align: center;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
}

.streak-icon {
    font-size: 2rem;
    margin-right: 8px;
}

.streak-text {
    font-size: 1rem;
}

/* ===== Stats ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.stat-card {
    padding: 20px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    text-align: center;
}

.stat-number {
    display: block;
    font-size: 2rem;
    font-weight: 800;
    color: var(--accent-primary);
    margin-bottom: 4px;
}

.stat-card .stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.category-stats h3 {
    font-size: 1rem;
    margin-bottom: 16px;
}

.category-bars {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.category-bar {
    display: flex;
    align-items: center;
    gap: 12px;
}

.category-bar-label {
    width: 80px;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.category-bar-track {
    flex: 1;
    height: 8px;
    background: var(--bg-secondary);
    border-radius: 4px;
    overflow: hidden;
}

.category-bar-fill {
    height: 100%;
    background: var(--accent-primary);
    border-radius: 4px;
    transition: width 0.5s ease;
}

.category-bar-value {
    width: 40px;
    text-align: right;
    font-size: 0.875rem;
    font-weight: 600;
}

/* ===== Modals ===== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal.active {
    display: flex;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 32px;
    max-width: 400px;
    width: 100%;
    text-align: center;
    animation: modalSlideIn 0.3s ease;
}

.result-icon {
    font-size: 4rem;
    margin-bottom: 16px;
}

.result-title {
    font-size: 1.5rem;
    margin-bottom: 16px;
}

.result-answer {
    margin-bottom: 24px;
}

.answer-label {
    display: block;
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 4px;
}

.answer-text {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--success);
}

.score-breakdown {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 24px;
}

.score-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 0.875rem;
}

.score-row.subtotal {
    border-top: 1px solid var(--border-color);
    margin-top: 8px;
    padding-top: 8px;
    color: var(--text-secondary);
}

.score-row.total {
    border-top: 1px solid var(--border-color);
    margin-top: 8px;
    padding-top: 12px;
    font-size: 1rem;
    font-weight: 700;
}

.score-row span:last-child {
    color: var(--success);
}

.score-row .bonus {
    color: var(--success);
}

.score-row .penalty {
    color: var(--error);
}

.score-row .multiplier {
    color: var(--accent-secondary);
    font-weight: 700;
}

.result-actions {
    display: flex;
    gap: 12px;
}

.result-btn {
    flex: 1;
    padding: 14px 20px;
    background: var(--accent-primary);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.result-btn:hover {
    background: #ff5286;
    transform: translateY(-2px);
}

.result-btn.secondary {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
}

.result-btn.secondary:hover {
    background: var(--bg-secondary);
    border-color: var(--accent-primary);
}

/* Daily Complete Modal */
.complete-icon {
    font-size: 4rem;
    margin-bottom: 16px;
}

.daily-summary {
    margin: 24px 0;
}

.summary-puzzles {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.summary-puzzle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
}

.summary-puzzle-stars {
    color: var(--warning);
}

.summary-total, .summary-streak {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 1rem;
    font-weight: 600;
}

.share-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 20px;
    text-align: left;
}

.share-card pre {
    font-family: inherit;
    font-size: 0.75rem;
    white-space: pre-wrap;
    color: var(--text-secondary);
}

.complete-actions {
    display: flex;
    gap: 12px;
}

/* Tutorial Modal */
.tutorial-steps {
    text-align: left;
    margin: 24px 0;
}

.tutorial-step {
    display: flex;
    gap: 16px;
    padding: 16px 0;
    border-bottom: 1px solid var(--border-color);
}

.tutorial-step:last-child {
    border-bottom: none;
}

.step-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.tutorial-step p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Reward Modal */
.reward-icon {
    font-size: 4rem;
    margin-bottom: 16px;
}

.reward-description {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--success);
    margin-bottom: 24px;
}

/* Bonus Energy Modal */
.bonus-icon {
    font-size: 4rem;
    margin-bottom: 16px;
}

.bonus-energy-content p {
    color: var(--text-secondary);
    margin-bottom: 24px;
}

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

.watch-ad-btn {
    background: var(--success);
}

.watch-ad-btn:hover {
    background: #3db891;
}

/* ===== Confetti Canvas ===== */
#confetti-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ===== Selection ===== */
::selection {
    background: var(--accent-primary);
    color: white;
}

/* ===== Focus Visible ===== */
:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}
