:root {
    --tile-size: 100px;
    --tile-gap: 10px;
    --grid-width: 450px;
    overscroll-behavior: none;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: #1a1a1a;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    max-height: calc(100vh - 100px);
}

/* Header - Same as games.html */
.main-header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    border-bottom: 1px solid #e2e8f0;
    padding: 1rem 0;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0;
}

.logo {
    font-size: 1.75rem;
    font-weight: 700;
    color: #3b82f6;
    text-decoration: none;
}

.nav-links {
    display: flex;
    list-style: none;
    gap: 2.5rem;
    margin: 0;
}

.nav-links a {
    text-decoration: none;
    color: #374151;
    font-weight: 500;
    font-size: 1rem;
    transition: color 0.3s ease;
}

.nav-links a:hover {
    color: #3b82f6;
}

.header-cta {
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 25px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
}

.header-cta:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(139, 92, 246, 0.4);
}

/* Game Wrapper */
.game-wrapper {
    padding: 120px 20px 40px;
    /* min-height: 100vh; */
    /* max-height: 200px; */
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0;
    box-sizing: border-box;
}

.game-container {
    background: rgba(255, 255, 255, 0.95);
    padding: 30px;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    max-width: 500px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 0;
    box-sizing: border-box;
}


.game-header {
    text-align: center;
    margin-bottom: 10px;
    position: relative;
}

.help-toggle {
    display: none;
    background: transparent;
    color: #6b7280;
    border: 1px solid #d1d5db;
    padding: 12px 24px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
    max-width: 200px;
}

.help-toggle:hover {
    background: #f9fafb;
    color: #374151;
    border-color: #9ca3af;
    transform: translateY(-1px);
}

.game-header h1 {
    font-size: 2.5em;
    color: #333;
    margin-bottom: 15px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.score-container {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 20px;
}

.score-box {
    background: #bbada0;
    padding: 10px 20px;
    border-radius: 10px;
    text-align: center;
    min-width: 80px;
}

.score-label {
    color: #eee4da;
    font-size: 0.8em;
    font-weight: bold;
    text-transform: uppercase;
}

.score {
    color: white;
    font-size: 1.2em;
    font-weight: bold;
}

.progress-section {
    text-align: center;
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f8f8;
    border-radius: 10px;
}

.progress-label {
    font-size: 1em;
    color: #333;
    margin-bottom: 5px;
    font-weight: bold;
}

.goal {
    font-size: 0.8em;
    color: #666;
    font-style: italic;
}

.game-grid {
    position: relative;
    background: #bbada0;
    border-radius: 15px;
    padding: var(--tile-gap);
    margin-bottom: 20px;
    width: var(--grid-width);
    margin-left: 0;
    margin-right: 0;
    box-sizing: border-box;
}

.grid-container {
    display: grid;
    grid-template-rows: repeat(4, 1fr);
    gap: var(--tile-gap);
}

.grid-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--tile-gap);
}

.grid-cell {
    background: rgba(238, 228, 218, 0.35);
    border-radius: 8px;
    width: var(--tile-size);
    height: var(--tile-size);
}

.tile-container {
    position: absolute;
    top: var(--tile-gap);
    left: var(--tile-gap);
    right: var(--tile-gap);
    bottom: var(--tile-gap);
}

.tile {
    position: absolute;
    background: #eee4da;
    border-radius: 8px;
    width: var(--tile-size);
    height: var(--tile-size);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.8em;
    text-align: center;
    transition: all 0.15s ease-in-out;
    border: 2px solid #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    padding: 5px;
    word-wrap: break-word;
    overflow-wrap: break-word;
    line-height: 1.1;
    z-index: 10;
}

.tile-animating {
    transition: transform 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    z-index: 100;
}

.tile-merged {
    animation: mergeEffect 0.2s ease-out;
}

.tile-merging {
    z-index: 200;
    animation: fadeOut 0.15s ease-out forwards;
}

.tile-merged-appear {
    z-index: 150;
    opacity: 0;
    animation: mergeAppear 0.1s ease-out forwards;
}

@keyframes mergeEffect {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes fadeOut {
    0% {
        opacity: 1;
    }
    100% {
        opacity: 0;
    }
}

@keyframes mergeAppear {
    0% {
        opacity: 0;
    }
    50% {
        opacity: 0.8;
    }
    100% {
        opacity: 1;
    }
}

.tile-sliding {
    transition: transform 0.1s ease-out;
    z-index: 20;
}

.sliding-left {
    transform: translateX(-2px);
    transition: transform 0.1s ease-out;
}

.sliding-right {
    transform: translateX(2px);
    transition: transform 0.1s ease-out;
}

.sliding-up {
    transform: translateY(-2px);
    transition: transform 0.1s ease-out;
}

.sliding-down {
    transform: translateY(2px);
    transition: transform 0.1s ease-out;
}

.combinations-display {
    margin-top: 10px;
    padding: 8px;
    background: rgba(139, 92, 246, 0.1);
    border-radius: 5px;
    font-size: 0.8em;
    text-align: center;
    color: #333;
    min-height: 20px;
}

.mode-selector {
    text-align: left;
    margin-bottom: 15px;
    margin-top: 10px;
}

.mode-selector label {
    font-weight: bold;
    margin-right: 10px;
    display: inline-block;
}

.mode-selector select {
    padding: 10px 16px;
    border-radius: 8px;
    border: 1px solid #d1d5db;
    font-size: 16px;
    font-weight: 500;
    background: white;
    color: #374151;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 140px;
    display: inline-block;
}

.mode-selector select:hover {
    border-color: #9ca3af;
    background: #f9fafb;
}

.mode-selector select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Mobile Mode Selector Optimizations */
@media (max-width: 600px) {
    .mode-selector {
        margin-bottom: 10px;
        margin-top: 8px;
    }
    
    .mode-selector label {
        font-size: 14px;
        margin-right: 8px;
        display: inline-block;
    }
    
    .mode-selector select {
        padding: 8px 12px;
        font-size: 15px;
        margin: 0 5px;
        min-width: 120px;
        display: inline-block;
    }
    
    /* Ensure inline layout on mobile */
    .mode-selector > div {
        display: flex !important;
        flex-wrap: wrap;
        justify-content: flex-start;
        align-items: center;
        gap: 10px;
    }
    
    /* Keep label and select on same line - target only Mode selector div (not goal-selector) */
    .mode-selector > div > div:not(#goal-selector) {
        display: flex !important;
        align-items: center;
        gap: 8px;
        white-space: nowrap;
    }
    
    /* Goal selector should respect JS display logic and use flex when visible */
    .mode-selector #goal-selector {
        align-items: center;
        gap: 8px;
        white-space: nowrap;
    }
    
    /* Ensure goal selector uses flex when it's supposed to be shown */
    .mode-selector #goal-selector[style*="display: flex"] {
        display: flex !important;
    }
    
    /* Challenge hint adjustments for mobile */
    #challenge-hint {
        font-size: 0.75em !important;
        margin-top: 5px !important;
        margin-bottom: 8px !important;
        padding: 0 5px;
        text-align: center;
    }
    
    /* Ensure challenge hint respects JS display logic on mobile */
    #challenge-hint[style*="display: none"] {
        display: none !important;
    }
    
    #challenge-hint[style*="display: block"] {
        display: block !important;
    }
}

.tile-letter-1 { background: #eee4da; color: #776e65; font-size: 1.4em; }
.tile-letter-2 { background: #ede0c8; color: #776e65; font-size: 1.4em; }
.tile-letter-3 { background: #f2b179; color: #f9f6f2; font-size: 1.4em; }
.tile-letter-4 { background: #f59563; color: #f9f6f2; font-size: 1.4em; }
.tile-letter-5 { background: #f67c5f; color: #f9f6f2; font-size: 1.4em; }
.tile-letter-6 { background: linear-gradient(45deg, #667eea, #764ba2); color: white; font-weight: bold; font-size: 1.0em; }

/* Concept Mode - Wealth-themed progression */
.tile-concept-1 { background: #2d5a27; color: white; font-size: 1.2em; } /* 💵 CASH - Dark green */
.tile-concept-2 { background: #ffd700; color: #333; font-size: 1.2em; } /* 💡 IDEA - Gold */
.tile-concept-3 { background: #ff6b35; color: white; font-size: 1.1em; } /* 🚀 STARTUP - Orange */
.tile-concept-4 { background: #4ecdc4; color: white; font-size: 1.0em; } /* 💼 BUSINESS - Teal */
.tile-concept-5 { background: #45b7d1; color: white; font-size: 1.0em; } /* 🏢 COMPANY - Blue */
.tile-concept-6 { background: #6c5ce7; color: white; font-size: 0.9em; } /* 🏭 CORPORATION - Purple */
.tile-concept-7 { background: #a29bfe; color: white; font-size: 0.8em; } /* 🌍 GLOBAL EMPIRE - Light purple */
.tile-concept-8 { background: #fd79a8; color: white; font-size: 1.0em; } /* 💎 WEALTH - Pink */
.tile-concept-9 { background: #fdcb6e; color: #333; font-size: 1.0em; } /* 🎯 FORTUNE - Yellow */
.tile-concept-10 { background: #e17055; color: white; font-size: 1.0em; } /* 👑 MOGUL - Red-orange */
.tile-concept-11 { background: linear-gradient(45deg, #ffd700, #ffb347, #ff6b35); color: white; font-weight: bold; font-size: 0.9em; animation: billionaire-glow 2s infinite; } /* 💰 BILLIONAIRE - Gold gradient */

@keyframes billionaire-glow {
    0%, 100% { box-shadow: 0 0 10px rgba(255, 215, 0, 0.5); }
    50% { box-shadow: 0 0 20px rgba(255, 215, 0, 0.8); }
}

.tile-new {
    animation: tileAppear 0.2s ease-out;
}

.tile-combinable {
    border: 3px solid #f67c5f;
    box-shadow: 0 0 10px rgba(246, 124, 95, 0.5);
    animation: pulse 1s infinite;
}

@keyframes tileAppear {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.tile-2 { background: #eee4da; color: #776e65; font-size: 1.4em; }
.tile-4 { background: #ede0c8; color: #776e65; font-size: 1.4em; }
.tile-8 { background: #f2b179; color: #f9f6f2; font-size: 1.4em; }
.tile-16 { background: #f59563; color: #f9f6f2; font-size: 1.2em; }
.tile-32 { background: #f67c5f; color: #f9f6f2; font-size: 1.2em; }
.tile-64 { background: #f65e3b; color: #f9f6f2; font-size: 1.2em; }
.tile-128 { background: #edcf72; color: #f9f6f2; font-size: 1.0em; }
.tile-256 { background: #edcc61; color: #f9f6f2; font-size: 1.0em; }
.tile-512 { background: #edc850; color: #f9f6f2; font-size: 1.0em; }
.tile-1024 { background: #edc53f; color: #f9f6f2; font-size: 0.9em; }
.tile-2048 { background: #edc22e; color: #f9f6f2; font-size: 0.9em; }
.tile-super { background: #3c3a32; color: #f9f6f2; font-size: 0.8em; }

.tile-simple {
    background: #eee4da;
    color: #776e65;
    border: 2px solid #8f7a66;
    font-size: 1.2em;
}

.tile-second {
    background: #ede0c8;
    color: #776e65;
    border: 2px solid #f2b179;
    font-size: 1.2em;
}

.tile-compound {
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    border: 3px solid #ffd700;
    font-weight: bold;
    font-size: 1.0em;
}

.tile-long {
    font-size: 0.6em;
}

.tile-super-long {
    font-size: 0.5em;
}

.game-controls {
    text-align: center;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 15px;
    margin-top: 15px;
}

.restart-button {
    background: #8f7a66;
    color: #f9f6f2;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 1em;
    font-weight: bold;
    cursor: pointer;
    /* margin-bottom: 15px; */
    transition: background 0.2s;
    min-width: 180px;
}

.restart-button:hover {
    background: #9f8a76;
}

.instructions {
    font-size: 0.9em;
    color: #666;
    line-height: 1.4;
    margin-bottom: 15px;
}

.help-section {
    background: #f8f8f8;
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 20px;
    font-size: 0.85em;
}

.help-title {
    font-weight: bold;
    margin-bottom: 10px;
    color: #333;
}

.help-rules {
    list-style: none;
    padding: 0;
}

.help-rules li {
    margin-bottom: 8px;
    padding-left: 15px;
    position: relative;
}

.help-rules li:before {
    content: "•";
    color: #8f7a66;
    font-weight: bold;
    position: absolute;
    left: 0;
}

.example-combo {
    background: rgba(139, 92, 246, 0.1);
    padding: 8px;
    border-radius: 5px;
    margin: 5px 0;
    font-family: monospace;
    text-align: center;
}

/* Concept mode - consistent sizing with other modes */
.concept-mode-emojis {
    font-size: 1.2em; /* Consistent with other modes */
    line-height: 1.4;
}

/* Other modes - consistent text font */
.other-modes-text {
    font-size: 1.2em; /* Larger text for readability */
    line-height: 1.4;
}

.hint-container {
    margin-top: 10px;
    text-align: center;
}

.hint-button {
    background: #8f7a66;
    color: #f9f6f2;
    border: none;
    padding: 8px 16px;
    border-radius: 5px;
    font-size: 0.9em;
    cursor: pointer;
    margin-bottom: 10px;
    transition: background 0.2s;
}

.hint-button:hover {
    background: #9f8a76;
}

.combinations-display.hidden {
    display: none;
}

.game-message {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.message-content {
    background: white;
    padding: 40px;
    border-radius: 15px;
    text-align: center;
    max-width: 400px;
    margin: 20px;
}

.message-text {
    font-size: 1.5em;
    margin-bottom: 20px;
    color: #333;
}

.try-again-btn {
    background: #8f7a66;
    color: #f9f6f2;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 1em;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
}

.try-again-btn:hover {
    background: #9f8a76;
}

/* Mobile Help Modal */
.help-modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
}

.help-modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 0;
    border-radius: 15px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

/* Desktop modal styling */
@media (min-width: 601px) {
    .help-modal-content {
        margin: 8% auto;
        width: 60%;
        max-width: 600px;
    }
}

.help-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #e2e8f0;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-radius: 15px 15px 0 0;
}

.help-modal-header h3 {
    margin: 0;
    color: #1a1a1a;
    font-size: 1.2rem;
    font-weight: 600;
}

.help-modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #6b7280;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.help-modal-close:hover {
    background: #f3f4f6;
    color: #374151;
}

.help-modal-body {
    padding: 20px;
}

.help-modal-rules {
    margin-bottom: 15px;
}

.help-modal-rules ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.help-modal-rules li {
    margin-bottom: 10px;
    padding-left: 20px;
    position: relative;
    line-height: 1.4;
}

.help-modal-rules li:before {
    content: "•";
    color: #3b82f6;
    position: absolute;
    left: 0;
    font-weight: bold;
}

.help-modal-example {
    background: #f8f9fa;
    padding: 12px;
    border-radius: 8px;
    font-size: 0.9rem;
    color: #495057;
    line-height: 1.3;
}

/* Desktop: Hide inline help section since we're using modal, show help button */
@media (min-width: 601px) {
    .help-section {
        display: none !important;
    }
    
    .help-toggle {
        display: block;
        /* padding: 8px 16px; */
        font-size: 0.9rem;
        max-width: 160px;
    }
}

@media (max-width: 600px) {
    :root {
        --tile-size: 85px;
        --tile-gap: 12px;
        --grid-width: 400px; /* 4 * 85px + 5 * 12px = 340 + 60 = 400px */
    }
    
    /* Move game to top on mobile */
    .game-wrapper {
        align-items: flex-start;
        padding: 120px 10px 20px;
    }
    
    /* Mobile tile font size scaling - maintain consistency */
    .tile {
        font-size: 0.85em; /* Slightly reduce from desktop but keep readable */
    }
    
    /* Show help toggle button on mobile */
    .help-toggle {
        display: block;
        /* padding: 6px 12px; */
        font-size: 0.8rem;
        max-width: 140px;
    }
    
    /* Hide help section by default on mobile */
    .help-section {
        display: none;
    }
    
    /* Show help section when active */
    .help-section.active {
        display: block;
    }
}

/* Header Responsive Design */
@media (max-width: 768px) {
    .game-wrapper {
        padding: 100px 10px 20px;
    }
    
    .game-container {
        padding: 20px;
        max-width: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
    }
    
    .game-header h1 {
        font-size: 2em;
    }
}

@media (max-width: 480px) {
    :root {
        --tile-size: 80px;
        --tile-gap: 10px;
        --grid-width: 370px; /* 4 * 80px + 5 * 10px = 320 + 50 = 370px */
    }

    .game-wrapper {
        padding: 100px 5px 15px;
        align-items: flex-start;
    }
    
    .game-container {
        padding: 10px;
        max-width: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
    }
    
    .game-header h1 {
        font-size: 1.8em;
    }
    
    /* Smaller mobile selector adjustments */
    .mode-selector label {
        font-size: 13px;
        display: inline-block;
    }
    
    .mode-selector select {
        padding: 5px 6px;
        font-size: 13px;
        display: inline-block;
    }
    
    /* Keep consistent tile sizing */
    .tile {
        font-size: 0.8em;
    }
    
    .tile-long {
        font-size: 0.6em;
    }
    
    .tile-super-long {
        font-size: 0.5em;
    }
}

@media (max-width: 360px) {
    :root {
        --tile-size: 75px;
        --tile-gap: 8px;
        --grid-width: 340px; /* 4 * 75px + 5 * 8px = 300 + 40 = 340px */
    }
    
    .game-container {
        padding: 8px;
        display: flex;
        flex-direction: column;
        align-items: center;
    }
    
    .game-wrapper {
        padding: 95px 10px 10px;
        display: flex;
        justify-content: center;
        align-items: flex-start;
    }
    
    /* Extra small mobile selector adjustments */
    .mode-selector label {
        font-size: 12px;
        display: inline-block;
    }
    
    .mode-selector select {
        padding: 4px 5px;
        font-size: 12px;
        display: inline-block;
    }
    
    #challenge-hint {
        font-size: 0.7em !important;
    }
}

@media (max-width: 320px) {
    :root {
        --tile-size: 70px;
        --tile-gap: 8px;
        --grid-width: 320px; /* 4 * 70px + 5 * 8px = 280 + 40 = 320px */
    }
    
    .game-container {
        padding: 5px;
        display: flex;
        flex-direction: column;
        align-items: center;
    }
    
    .game-wrapper {
        padding: 90px 10px 8px;
        display: flex;
        justify-content: center;
        align-items: flex-start;
    }
    
    /* Tiny mobile selector adjustments */
    .mode-selector label {
        font-size: 11px;
        margin-right: 5px;
        display: inline-block;
    }
    
    .mode-selector select {
        padding: 3px 4px;
        font-size: 11px;
        margin: 0 3px;
        display: inline-block;
    }
    
    #challenge-hint {
        font-size: 0.65em !important;
        padding: 0 2px;
    }
    
    /* Consistent smallest screen tile sizing */
    .tile {
        font-size: 0.75em;
    }
    
    .tile-long {
        font-size: 0.55em;
    }
    
    .tile-super-long {
        font-size: 0.45em;
    }
}