/* Loading State */
.loading-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(to bottom, #f8f9fa 0%, #ffffff 100%);
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 6px solid rgba(102, 126, 234, 0.2);
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Game Page Container - Wraps header and game wrapper */
.game-page-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* Sticky Game Header */
.game-header-sticky {
    position: sticky;
    top: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 999;
    flex-shrink: 0;
}

.game-header-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 10px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 30px;
}

.header-section {
    display: flex;
    align-items: center;
}

.logo-section {
    flex-shrink: 0;
}

.info-section {
    display: flex;
    align-items: center;
    gap: 40px;
    flex-grow: 1;
    justify-content: flex-end;
}

.game-logo {
    display: inline-block;
    text-decoration: none;
    transition: opacity 0.2s ease;
}

.game-logo:hover {
    opacity: 0.85;
}

.header-logo-img {
    height: 120px;
    width: auto;
    display: block;
}

.info-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.info-label {
    color: rgba(255, 255, 255, 0.9);
    font-size: 16px;
    font-weight: 500;
}

.info-value {
    font-size: 22px;
    font-weight: bold;
    color: white;
}

.info-value.target-word {
    font-size: 28px;
    letter-spacing: 3px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.info-value.max-grid {
    color: #ffd700;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

.timer-item {
    background: rgba(255, 255, 255, 0.15);
    padding: 8px 16px;
    border-radius: 8px;
}

.timer-value {
    min-width: 35px;
    text-align: center;
}

.timer-value.timer-warning {
    color: #ff4444;
    animation: pulse-warning 1s infinite;
}

@keyframes pulse-warning {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.08);
    }
}

/* Settings Menu */
.settings-item {
    position: relative;
}

.settings-button {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 20px;
}

.settings-button:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.settings-icon {
    display: block;
    line-height: 1;
}

.settings-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: white;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    min-width: 240px;
    overflow: hidden;
    z-index: 1000;
}

.dropdown-section {
    padding: 8px 0;
}

.dropdown-section-title {
    padding: 8px 16px;
    font-size: 12px;
    font-weight: bold;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.dropdown-divider {
    height: 1px;
    background: #e9ecef;
    margin: 4px 0;
}

.dropdown-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: white;
    border: none;
    text-align: left;
    font-size: 15px;
    color: #333;
    cursor: pointer;
    transition: background 0.2s ease;
    border-bottom: 1px solid #eee;
}

.dropdown-item:last-child {
    border-bottom: none;
}

.dropdown-item:hover {
    background: #f8f9fa;
}

.dropdown-item.active {
    background: #e3f2fd;
    color: #667eea;
    font-weight: 600;
}

.dropdown-item.danger {
    color: #dc3545;
}

.dropdown-item.danger:hover {
    background: #fff5f5;
}

.dropdown-icon {
    font-size: 18px;
    width: 20px;
    text-align: center;
}

.dropdown-stat-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: white;
    border-bottom: 1px solid #eee;
    color: #333;
}

.dropdown-stat-item .dropdown-label {
    font-size: 14px;
    color: #6c757d;
    flex-shrink: 0;
}

.dropdown-stat-item .dropdown-value {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin-left: auto;
}

.dropdown-stat-item .dropdown-value.max-grid {
    color: #ffd700;
}

/* Game Stats Section */
.game-stats {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 12px;
    flex-shrink: 0;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.stat-label {
    font-size: 14px;
    color: #6c757d;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 20px;
    font-weight: bold;
    color: #2c3e50;
}

/* Game Wrapper - Full viewport management */
.game-wrapper {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

/* Game Container */
.game-container {
    max-width: 100%; /* Allow container to expand with grid */
    width: 100%;
    margin: 0 auto;
    padding: 20px 20px 0 20px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

/* Grid Scroll Container - This allows the grid to scroll */
.grid-scroll-container {
    flex: 1;
    overflow: auto;
    margin-bottom: 0;
    padding: 0;
    background: #f8f9fa;
    border-radius: 12px;
    position: relative;
    min-height: 0;
    text-align: center; /* Center the inline-block child */
}

/* Pan Tooltip */
.pan-tooltip {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(102, 126, 234, 0.7);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.tooltip-icon {
    font-size: 16px;
}

.tooltip-text kbd {
    background: rgba(255, 255, 255, 0.25);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: monospace;
    font-weight: bold;
}

/* Pan cursor when spacebar is held */
.grid-scroll-container.pan-mode-active {
    cursor: grab !important;
    outline: 3px solid rgba(102, 126, 234, 0.5);
    outline-offset: -3px;
}

.grid-scroll-container.pan-mode-active * {
    cursor: grab !important;
}

/* Hide scrollbars when buttons are shown */
.grid-scroll-container.has-scroll-buttons {
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
    padding: 50px; /* Space for scroll buttons */
}

.grid-scroll-container.has-scroll-buttons::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}

.scroll-btn {
    position: absolute;
    background: rgba(102, 126, 234, 0.8);
    color: white;
    border: none;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    transition: background 0.2s ease;
    user-select: none;
}

.scroll-btn:hover {
    background: rgba(102, 126, 234, 0.95);
}

.scroll-btn:active {
    background: rgba(118, 75, 162, 0.95);
}

.scroll-btn-top {
    top: 0;
    left: 0;
    right: 0;
    height: 40px;
    border-radius: 12px 12px 0 0;
}

.scroll-btn-bottom {
    bottom: 0;
    left: 0;
    right: 0;
    height: 40px;
    border-radius: 0 0 12px 12px;
}

.scroll-btn-left {
    top: 40px;
    bottom: 40px;
    left: 0;
    width: 40px;
    border-radius: 0;
}

.scroll-btn-right {
    top: 40px;
    bottom: 40px;
    right: 0;
    width: 40px;
    border-radius: 0;
}

.grid-container {
    padding: 20px;
    display: inline-block; /* inline-block will shrink-wrap to content */
    text-align: left; /* Reset text alignment for content inside */
}

.grid {
    display: grid;
    gap: 4px;
    padding: 10px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.tile {
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: bold;
    background: white;
    border: 2px solid #bdc3c7;
    border-radius: 4px;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
}

.tile:hover {
    transform: scale(1.05);
    border-color: #3498db;
}

.tile-selected {
    background: #3498db;
    color: white;
    border-color: #2980b9;
    transform: scale(1.05);
}

.tile-found {
    background: #2ecc71;
    color: white;
    border-color: #27ae60;
}

.tile-revealed {
    background: #f39c12;
    color: white;
    border-color: #e67e22;
}

.tile-hinted {
    background: rgba(46, 204, 113, 0.25);
    color: white;
    border-color: #2ecc71;
    border-width: 2px;
    box-shadow: 0 0 8px rgba(46, 204, 113, 0.6);
}

.tile-rotating {
    border: 3px solid #764ba2;
    box-shadow: 0 0 10px rgba(118, 75, 162, 0.5);
    animation: rotatePulse 2s ease-in-out infinite;
}

@keyframes rotatePulse {
    0%, 100% {
        box-shadow: 0 0 10px rgba(118, 75, 162, 0.5);
        border-color: #764ba2;
    }
    50% {
        box-shadow: 0 0 20px rgba(118, 75, 162, 0.8);
        border-color: #8c66b8;
    }
}

.game-controls {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 15px;
    flex-shrink: 0;
    flex-wrap: wrap;
}

.btn {
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 600;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.btn-primary {
    background: #3498db;
    color: white;
}

.btn-primary:hover {
    background: #2980b9;
}

.btn-secondary {
    background: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background: #7f8c8d;
}

.btn-success {
    background: #2ecc71;
    color: white;
}

.btn-success:hover {
    background: #27ae60;
}

.btn-warning {
    background: #f39c12;
    color: white;
}

.btn-warning:hover {
    background: #e67e22;
}

.btn-danger {
    background: #e74c3c;
    color: white;
}

.btn-danger:hover {
    background: #c0392b;
}

.message {
    text-align: center;
    padding: 15px;
    border-radius: 6px;
    font-size: 18px;
    font-weight: 600;
    flex-shrink: 0;
}

.message-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.message-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.message-warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeeba;
}

/* Responsive Design */
@media (max-width: 768px) {
    .game-wrapper {
        height: calc(100vh - 120px); /* Account for taller mobile header */
    }

    .game-header-content {
        padding: 12px 15px;
        flex-direction: column;
        gap: 15px;
    }

    .logo-section {
        width: 100%;
        justify-content: center;
    }

    .info-section {
        width: 100%;
        flex-wrap: wrap;
        justify-content: center;
        gap: 20px;
    }

    .header-logo-img {
        height: 96px;
    }

    .info-label {
        font-size: 14px;
    }

    .info-value {
        font-size: 18px;
    }

    .info-value.target-word {
        font-size: 22px;
        letter-spacing: 2px;
    }

    .timer-item {
        padding: 6px 12px;
    }

    .game-stats {
        flex-direction: column;
        gap: 15px;
        padding: 12px;
    }

    .tile {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }

    .game-container {
        padding: 15px;
    }

    .game-controls {
        gap: 8px;
    }

    .btn {
        padding: 10px 18px;
        font-size: 14px;
    }
}
