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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #D4A012 0%, #A67C00 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    width: 100%;
}

/* Header with logo and auth */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    flex-wrap: wrap;
    gap: 10px;
}

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

.logo-svg {
    width: 40px;
    height: 46px;
}

.logo-text {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 2.2em;
    font-weight: bold;
    color: #1A1A1A;
}

/* Auth UI */
.auth-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.google-signin-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border: 2px solid #ccc;
    border-radius: 8px;
    background: white;
    color: #333;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.google-signin-btn:hover {
    border-color: #4285f4;
    background: #f8f9fa;
}

.google-signin-btn svg {
    width: 18px;
    height: 18px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid #D4A012;
}

.user-name {
    font-size: 14px;
    color: #333;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.signout-btn {
    padding: 6px 12px;
    font-size: 12px;
    border: 1px solid #ccc;
    border-radius: 6px;
    background: white;
    color: #666;
    cursor: pointer;
    transition: all 0.2s;
}

.signout-btn:hover {
    border-color: #e74c3c;
    color: #e74c3c;
}

.auth-loading {
    font-size: 14px;
    color: #666;
}

/* Hub back link (only shown when ?hub=1) */
.hub-back-link {
    display: none;
    margin-left: auto;
    margin-right: 15px;
}

.hub-back-link a {
    color: #666;
    text-decoration: none;
    font-size: 14px;
    transition: color 0.2s;
}

.hub-back-link a:hover {
    color: #D4A012;
}

h1 {
    text-align: center;
    color: #1A1A1A;
    margin-bottom: 10px;
    font-size: 2.2em;
}

.subtitle {
    text-align: center;
    color: #6b7280;
    margin-bottom: 24px;
    font-size: 0.95em;
}

/* Puzzle selector row */
.puzzle-selector {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
    justify-content: center;
}

select {
    padding: 8px 16px;
    font-size: 14px;
    border: 2px solid #ccc;
    border-radius: 8px;
    background: white;
    color: #333;
    cursor: pointer;
}

select:focus {
    outline: none;
    border-color: #D4A012;
}

/* Puzzle option with completion indicator */
.puzzle-option-completed {
    color: #D4A012;
}

.help-link {
    padding: 8px 16px;
    font-size: 14px;
    border: 2px solid #ccc;
    border-radius: 8px;
    text-decoration: none;
    color: #333;
    transition: all 0.2s;
}

.help-link:hover {
    border-color: #D4A012;
    color: #D4A012;
}

.start-btn {
    padding: 8px 20px;
    font-size: 14px;
    font-weight: 600;
    border: 2px solid #1A1A1A;
    border-radius: 8px;
    background: #D4A012;
    color: #1A1A1A;
    cursor: pointer;
    transition: all 0.2s;
}

.start-btn:hover {
    background: #B8860B;
}

/* Top action buttons */
.top-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
}

.action-btn {
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    border: 2px solid #ccc;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.2s;
    background: white;
    color: #555;
}

.action-btn:hover {
    border-color: #1A1A1A;
    color: #1A1A1A;
}

.action-btn.active {
    border-color: #D4A012;
    background: #FFF8E7;
    color: #1A1A1A;
}

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

.pause-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 3px solid #1A1A1A;
    background: #D4A012;
    color: #1A1A1A;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    padding: 0;
}

.pause-btn:hover {
    background: #B8860B;
}

.pause-btn svg {
    width: 18px;
    height: 18px;
    fill: #1A1A1A;
}

/* Bottom stats bar */
.bottom-stats {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-top: 20px;
    padding: 10px;
    background: #FFF8E7;
    border-radius: 8px;
    font-size: 13px;
}

.bottom-stat {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #666;
}

.bottom-stat-value {
    font-weight: 600;
    color: #333;
}

/* Game area */
.game-area {
    display: flex;
    justify-content: center;
    gap: 30px;
    align-items: flex-start;
}

.grid-wrapper {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

#hexGrid {
    display: block;
}

.start-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #D4A012;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
    border-radius: 10px;
}

.start-overlay h2 {
    color: #1A1A1A;
    margin-bottom: 10px;
}

.start-overlay p {
    color: rgba(26,26,26,0.8);
    margin-bottom: 20px;
    font-size: 14px;
}

.start-overlay button {
    padding: 12px 35px;
    font-size: 16px;
    border: 2px solid #1A1A1A;
    border-radius: 25px;
    background: #1A1A1A;
    color: #FFE082;
    cursor: pointer;
    font-weight: 600;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.start-overlay button:hover {
    background: #333;
}

.pause-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #D4A012;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
    border-radius: 10px;
}

.pause-overlay h2 {
    color: #1A1A1A;
    margin-bottom: 20px;
}

.pause-overlay button {
    padding: 10px 30px;
    font-size: 16px;
    border: 2px solid #1A1A1A;
    border-radius: 25px;
    background: #1A1A1A;
    color: #FFE082;
    cursor: pointer;
    font-weight: 600;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.pause-overlay button:hover {
    background: #333;
}

/* Number pad - right side on desktop */
.number-panel {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.number-row {
    display: flex;
    gap: 6px;
    align-items: center;
}

.number-btn {
    width: 48px;
    height: 48px;
    font-size: 22px;
    font-weight: bold;
    border: 2px solid #1A1A1A;
    border-radius: 8px;
    background: white;
    color: #1A1A1A;
    cursor: pointer;
    transition: all 0.2s;
    padding: 0;
}

.number-btn:hover {
    background: #1A1A1A;
    color: white;
}

.number-btn.completed {
    border-color: #ccc;
    color: #ccc;
    cursor: default;
}

.number-btn.completed:hover {
    background: white;
    color: #ccc;
}

.pencil-btn-small {
    width: 32px;
    height: 32px;
    font-size: 14px;
    border: 1px solid #ccc;
    border-radius: 6px;
    background: white;
    color: #888;
    cursor: pointer;
    transition: all 0.2s;
    padding: 0;
}

.pencil-btn-small:hover {
    border-color: #1A1A1A;
    color: #1A1A1A;
}

.pencil-btn-small.completed {
    border-color: #e0e0e0;
    color: #ccc;
    cursor: default;
}

.pencil-btn-small.completed:hover {
    border-color: #e0e0e0;
    color: #ccc;
}

.clear-btn, .undo-btn {
    width: 48px;
    height: 48px;
    font-size: 20px;
    border: 2px solid #ccc;
    border-radius: 8px;
    background: white;
    color: #666;
    cursor: pointer;
    transition: all 0.2s;
    padding: 0;
}

.clear-btn:hover {
    border-color: #e74c3c;
    color: #e74c3c;
}

.undo-btn:hover {
    border-color: #1A1A1A;
    color: #1A1A1A;
}

.undo-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.mode-indicator {
    text-align: center;
    font-size: 12px;
    color: #888;
    margin-top: 10px;
    padding: 5px;
    background: #FFF8E7;
    border-radius: 5px;
}

.mode-indicator.pencil-mode {
    background: #FFE082;
    color: #5C4813;
}

/* Modals */
.modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

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

.modal-content h2 {
    color: #1A1A1A;
    margin-bottom: 20px;
}

.modal-content p {
    color: #666;
    margin-bottom: 20px;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.modal-btn {
    padding: 10px 25px;
    font-size: 14px;
    border: 2px solid #ccc;
    border-radius: 25px;
    background: white;
    color: #555;
    cursor: pointer;
    transition: all 0.2s;
}

.modal-btn:hover {
    border-color: #1A1A1A;
    color: #1A1A1A;
}

.modal-btn.primary {
    border-color: #1A1A1A;
    background: #D4A012;
    color: #1A1A1A;
}

.modal-btn.primary:hover {
    background: #B8860B;
}

.modal-btn.danger {
    border-color: #e74c3c;
    color: #e74c3c;
}

.modal-btn.danger:hover {
    background: #e74c3c;
    color: white;
}

/* Share button */
.share-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 25px;
    font-size: 14px;
    border: 2px solid #1A1A1A;
    border-radius: 25px;
    background: #D4A012;
    color: #1A1A1A;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 15px;
}

.share-btn:hover {
    background: #B8860B;
}

/* Sign-in prompt in completion modal */
.sign-in-prompt {
    background: #FFF8E7;
    border: 2px dashed #D4A012;
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 15px;
    text-align: center;
}

.sign-in-prompt p {
    color: #1A1A1A;
    margin-bottom: 12px;
    font-size: 14px;
}

.google-signin-btn-modal {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: 2px solid #4285f4;
    border-radius: 8px;
    background: white;
    color: #333;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.google-signin-btn-modal:hover {
    background: #f8f9fa;
    box-shadow: 0 2px 8px rgba(66, 133, 244, 0.3);
}

/* Assist stats in completion modal */
.assist-stats {
    background: #FFF8E7;
    border-radius: 10px;
    padding: 15px;
    margin: 20px 0;
}

.assist-stat {
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
    font-size: 14px;
}

.assist-label {
    color: #666;
}

.assist-value {
    font-weight: 600;
    color: #333;
}

.assist-value.clean {
    color: #D4A012;
}

.assist-value.used {
    color: #e67e22;
}

.next-puzzle-prefs {
    margin: 20px 0;
    padding-top: 15px;
    border-top: 1px solid #eee;
}

.pref-toggles {
    display: flex;
    gap: 20px;
    justify-content: center;
    flex-wrap: wrap;
}

.pref-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #555;
    cursor: pointer;
}

.pref-toggle input {
    cursor: pointer;
}

/* Highlight toggle */
.highlight-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #666;
    margin-top: 15px;
    justify-content: center;
}

.highlight-toggle input {
    cursor: pointer;
}

.hidden { display: none !important; }

/* Home and Game screen visibility */
.home-screen {
    display: block;
}

.game-screen {
    display: none;
}

.game-screen:not(.hidden) {
    display: block;
}

/* Landscape prompt overlay */
.landscape-prompt {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.landscape-content {
    background: white;
    padding: 30px 40px;
    border-radius: 20px;
    text-align: center;
    max-width: 320px;
    margin: 20px;
}

.landscape-content .rotate-icon {
    font-size: 48px;
    margin-bottom: 15px;
}

.landscape-content h3 {
    color: #1A1A1A;
    margin-bottom: 10px;
    font-size: 1.3em;
}

.landscape-content p {
    color: #666;
    margin-bottom: 20px;
    font-size: 14px;
}

.landscape-content button {
    padding: 10px 25px;
    font-size: 14px;
    border: 2px solid #ccc;
    border-radius: 25px;
    background: white;
    color: #555;
    cursor: pointer;
    transition: all 0.2s;
}

.landscape-content button:hover {
    border-color: #1A1A1A;
    color: #1A1A1A;
}

/* Toast notifications */
.toast-container {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

.toast {
    background: #333;
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    animation: toastSlideUp 0.3s ease-out;
    display: flex;
    align-items: center;
    gap: 8px;
}

.toast.success {
    background: #D4A012;
}

.toast.error {
    background: #e74c3c;
}

.toast.info {
    background: #4285f4;
}

.toast-exit {
    animation: toastSlideDown 0.3s ease-in forwards;
}

@keyframes toastSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes toastSlideDown {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(20px);
    }
}

/* Error cell shake animation */
@keyframes cellShake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-2px); }
    20%, 40%, 60%, 80% { transform: translateX(2px); }
}

.cell-shake {
    animation: cellShake 0.5s ease-in-out;
}

/* Mobile layout */
@media (max-width: 700px) {
    body {
        padding: 5px;
    }
    
    /* Remove green background on mobile when game is active */
    body.game-active {
        background: white;
        padding: 0;
    }
    
    body.game-active .container {
        box-shadow: none;
        border-radius: 0;
        padding: 10px;
    }
    
    /* Hide puzzle selector and minimize header during active game */
    body.game-active .puzzle-selector {
        display: none;
    }
    
    body.game-active h1 {
        font-size: 1.2em;
        margin-bottom: 5px;
    }
    
    body.game-active .subtitle {
        display: none;
    }
    
    body.game-active .header {
        justify-content: center;
    }
    
    body.game-active .auth-container,
    body.game-active .hub-back-link {
        display: none;
    }
    
    .container {
        padding: 12px;
        border-radius: 8px;
    }
    
    .header {
        flex-direction: column;
        gap: 6px;
        margin-bottom: 6px;
    }
    
    .logo-container {
        justify-content: center;
    }
    
    .logo-text {
        font-size: 1.6em;
    }
    
    .logo-svg {
        width: 32px;
        height: 37px;
    }
    
    .auth-container {
        justify-content: center;
    }
    
    .hub-back-link {
        width: 100%;
        text-align: center;
        margin-left: 0;
        margin-right: 0;
    }
    
    .hub-back-link a {
        font-size: 13px;
    }
    
    .subtitle {
        font-size: 0.85em;
        margin-bottom: 10px;
    }
    
    .game-area {
        flex-direction: column;
        align-items: center;
    }
    
    .start-overlay h2 {
        font-size: 1.4em;
    }
    
    .start-overlay p {
        font-size: 13px;
    }
    
    .start-overlay button {
        padding: 10px 25px;
        font-size: 14px;
    }
    
    .number-panel {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        gap: 4px;
        margin-top: 15px;
    }
    
    .number-row {
        flex-direction: column;
        gap: 3px;
    }
    
    .number-btn {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }
    
    .pencil-btn-small {
        width: 26px;
        height: 26px;
        font-size: 11px;
    }
    
    .clear-btn, .undo-btn {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
    
    .top-buttons {
        gap: 6px;
    }
    
    .action-btn {
        padding: 6px 12px;
        font-size: 12px;
    }
    
    .pause-btn {
        width: 38px;
        height: 38px;
    }
    
    .puzzle-selector {
        gap: 6px;
    }
    
    select, .start-btn, .help-link {
        padding: 6px 10px;
        font-size: 12px;
    }
    
    .bottom-stats {
        gap: 15px;
        font-size: 12px;
        padding: 8px;
    }
    
    .mode-indicator {
        font-size: 11px;
    }
}

/* Hide pencil mode indicator only on mobile */
@media (max-width: 700px) {
    body .mode-indicator {
        display: none;
    }
    
    .highlight-toggle {
        font-size: 11px;
    }
    
    .user-name {
        display: none;
    }
}

@media (max-width: 400px) {
    .number-btn {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }
    
    .pencil-btn-small {
        width: 22px;
        height: 22px;
        font-size: 10px;
    }
    
    .clear-btn, .undo-btn {
        width: 36px;
        height: 36px;
        font-size: 14px;
    }
    
    .action-btn {
        padding: 5px 10px;
        font-size: 11px;
    }
}

/* Landscape controls (bottom-left in landscape mode) */
.landscape-controls {
    position: fixed;
    bottom: 5px;
    left: 5px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    z-index: 100;
}

.landscape-timer-bottom {
    background: rgba(255,255,255,0.95);
    border: 1px solid #ccc;
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 14px;
    font-weight: 600;
    color: #333;
    text-align: center;
}

.landscape-buttons {
    display: flex;
    gap: 4px;
}

.landscape-btn {
    width: 32px;
    height: 32px;
    font-size: 16px;
    border: 1px solid #ccc;
    border-radius: 6px;
    background: rgba(255,255,255,0.95);
    color: #555;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.landscape-btn:hover {
    border-color: #1A1A1A;
    color: #1A1A1A;
}

.landscape-pause {
    border-color: #1A1A1A;
}

/* Controls wrapper (for landscape layout) */
.controls-wrapper {
    display: contents; /* By default, doesn't affect layout */
}

/* Settings popup */
.settings-popup {
    display: none;
    position: fixed;
    bottom: 75px;
    left: 5px;
    background: white;
    border: 1px solid #ccc;
    border-radius: 8px;
    padding: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    z-index: 101;
}

.settings-content {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.settings-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #333;
    cursor: pointer;
    white-space: nowrap;
}

.settings-toggle input {
    cursor: pointer;
}

.settings-hint {
    font-size: 12px;
    color: #888;
    font-style: italic;
}

/* Compact/landscape layout - used for large puzzles (>5) on desktop or mobile landscape */
body.landscape-layout.game-active {
    padding: 0;
    background: white;
}

body.landscape-layout.game-active .container {
    padding: 20px;
    border-radius: 0;
    box-shadow: none;
    max-width: 100%;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    min-height: 100dvh;
}

/* Hide non-essential elements in landscape layout */
body.landscape-layout.game-active h1,
body.landscape-layout.game-active .subtitle,
body.landscape-layout.game-active .puzzle-selector,
body.landscape-layout.game-active .top-buttons,
body.landscape-layout.game-active .bottom-stats,
body.landscape-layout.game-active .header {
    display: none;
}

/* Show landscape controls */
body.landscape-layout.game-active .landscape-controls {
    display: flex;
}

/* Game area - grid left, number panel right */
body.landscape-layout.game-active .game-area {
    flex: 0 1 auto;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 20px;
    padding: 10px;
}

/* Grid wrapper - center vertically */
body.landscape-layout.game-active .grid-wrapper {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Controls wrapper - contains number panel */
body.landscape-layout.game-active .controls-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-shrink: 0;
    min-width: 100px;
}

/* Number panel - vertical column layout */
body.landscape-layout.game-active .number-panel {
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    margin: 0;
    padding: 0;
}

body.landscape-layout.game-active .number-row {
    flex-direction: row;
    gap: 4px;
    align-items: center;
    justify-content: center;
}

/* Fixed size buttons on desktop */
body.landscape-layout.game-active .number-btn {
    width: 44px;
    height: 44px;
    font-size: 16px;
    border-width: 2px;
    border-radius: 6px;
}

body.landscape-layout.game-active .pencil-btn-small {
    width: 30px;
    height: 30px;
    font-size: 12px;
    border-radius: 4px;
}

body.landscape-layout.game-active .clear-btn,
body.landscape-layout.game-active .undo-btn {
    width: 44px;
    height: 44px;
    font-size: 16px;
    border-width: 2px;
    border-radius: 6px;
}

/* Hide Undo from top (we have it in number panel) */
body.landscape-layout.game-active .landscape-hide {
    display: none;
}

/* Overlays in landscape layout */
body.landscape-layout .start-overlay,
body.landscape-layout .pause-overlay {
    border-radius: 0;
}

body.landscape-layout .start-overlay h2 {
    font-size: 1.4em;
}

body.landscape-layout .start-overlay p {
    font-size: 13px;
    margin-bottom: 15px;
}

body.landscape-layout .start-overlay button {
    padding: 10px 25px;
    font-size: 14px;
}

/* Desktop landscape controls - larger buttons */
body.landscape-layout.game-active .landscape-controls {
    bottom: 15px;
    left: 15px;
    gap: 8px;
}

body.landscape-layout.game-active .landscape-timer-bottom {
    font-size: 16px;
    padding: 8px 16px;
    border-radius: 8px;
}

body.landscape-layout.game-active .landscape-buttons {
    gap: 6px;
}

body.landscape-layout.game-active .landscape-btn {
    width: 40px;
    height: 40px;
    font-size: 18px;
    border-radius: 8px;
}

/* Settings always visible on desktop (not a popup) */
body.landscape-layout.game-active .settings-popup {
    display: block !important;
    position: fixed;
    bottom: 15px;
    left: 200px;
    background: rgba(255,255,255,0.95);
    border: 1px solid #ccc;
    border-radius: 8px;
    padding: 12px 16px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

body.landscape-layout.game-active .settings-content {
    flex-direction: row;
    gap: 20px;
}

body.landscape-layout.game-active .settings-toggle {
    font-size: 14px;
}

/* Hide settings button on desktop since settings are always visible */
body.landscape-layout.game-active #settingsBtn {
    display: none;
}

/* Mobile landscape - stretch to fill height */
@media (max-height: 500px) {
    /* Hide mode indicator, toggles, and keyboard hints on mobile landscape */
    body.landscape-layout.game-active .mode-indicator,
    body.landscape-layout.game-active .highlight-toggle,
    body.landscape-layout.game-active .settings-hint {
        display: none;
    }
    
    body.landscape-layout.game-active .container {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        padding: 0;
        height: auto;
        min-height: auto;
        align-items: stretch;
        overflow: hidden;
    }
    
    /* Prevent any scrolling in landscape game mode */
    body.landscape-layout.game-active {
        overflow: hidden;
        height: 100vh;
        height: 100svh;
    }
    
    html:has(body.landscape-layout.game-active) {
        overflow: hidden;
    }
    
    body.landscape-layout.game-active .game-area {
        flex: 1;
        align-items: flex-start;
        justify-content: flex-start;
        gap: 10px;
        padding: 0;
        min-height: 0;
        height: 100%;
        overflow: hidden;
    }
    
    body.landscape-layout.game-active .grid-wrapper {
        flex-shrink: 0;
        display: flex;
        align-items: flex-start;
        justify-content: flex-start;
    }
    
    body.landscape-layout.game-active .controls-wrapper {
        height: 100%;
        flex-shrink: 0;
        min-width: 80px;
    }
    
    body.landscape-layout.game-active .number-panel {
        height: 100%;
        flex: 1;
        justify-content: stretch;
        gap: 0;
    }
    
    body.landscape-layout.game-active .number-row {
        flex: 1;
        align-items: stretch;
        gap: 2px;
        min-height: 0;
    }
    
    /* Buttons fill row height on mobile landscape */
    body.landscape-layout.game-active .number-btn,
    body.landscape-layout.game-active .pencil-btn-small {
        flex: 0 0 auto;
        aspect-ratio: 1;
        height: 100%;
        width: auto;
        font-size: 12px;
        border-width: 1px;
        border-radius: 3px;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    body.landscape-layout.game-active .clear-btn,
    body.landscape-layout.game-active .undo-btn {
        flex: 0 0 auto;
        aspect-ratio: 1;
        height: 100%;
        width: auto;
        font-size: 12px;
        border-width: 1px;
        border-radius: 3px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    body.landscape-layout .start-overlay h2 {
        font-size: 1.2em;
    }
    
    body.landscape-layout .start-overlay p {
        font-size: 11px;
        margin-bottom: 12px;
    }
    
    body.landscape-layout .start-overlay button {
        padding: 8px 20px;
        font-size: 13px;
    }
    
    /* Mobile landscape controls - smaller */
    body.landscape-layout.game-active .landscape-controls {
        bottom: 5px;
        left: 5px;
        gap: 4px;
    }
    
    body.landscape-layout.game-active .landscape-timer-bottom {
        font-size: 14px;
        padding: 4px 10px;
        border-radius: 6px;
    }
    
    body.landscape-layout.game-active .landscape-buttons {
        gap: 4px;
    }
    
    body.landscape-layout.game-active .landscape-btn {
        width: 32px;
        height: 32px;
        font-size: 16px;
        border-radius: 6px;
    }
    
    /* Settings popup on mobile - show settings button, hide permanent settings */
    body.landscape-layout.game-active .settings-popup {
        display: none !important;
        position: fixed;
        bottom: 75px;
        left: 5px;
        padding: 8px;
    }
    
    body.landscape-layout.game-active .settings-popup.visible {
        display: block !important;
    }
    
    body.landscape-layout.game-active .settings-content {
        flex-direction: column;
        gap: 6px;
    }
    
    body.landscape-layout.game-active .settings-toggle {
        font-size: 12px;
    }
    
    body.landscape-layout.game-active #settingsBtn {
        display: flex;
    }
}

/* Even more compact for very short screens */
@media (max-height: 380px) {
    body.landscape-layout.game-active .landscape-btn {
        width: 26px;
        height: 26px;
        font-size: 14px;
    }
    
    body.landscape-layout.game-active .settings-popup {
        bottom: 65px;
    }
    
    body.landscape-layout.game-active .number-btn,
    body.landscape-layout.game-active .pencil-btn-small {
        font-size: 10px;
    }
    
    body.landscape-layout.game-active .clear-btn,
    body.landscape-layout.game-active .undo-btn {
        font-size: 10px;
    }
    
    body.landscape-layout.game-active .landscape-timer-bottom {
        font-size: 12px;
        padding: 3px 8px;
    }
}

/* Best time indicator in dropdown */
.best-time {
    color: #D4A012;
    font-weight: 600;
}

/* ============================================================================
   HOME SCREEN - Card-based puzzle selection
   ============================================================================ */
.home-screen {
    display: block;
}

body.game-active .home-screen {
    display: none;
}

.game-screen {
    display: none;
}

body.game-active .game-screen {
    display: block;
}

/* ============================================
   HOME SCREEN STYLES - Clean Card Design
   ============================================ */

.home-screen {
    max-width: 480px;
    margin: 0 auto;
    padding: 0 10px;
}

/* Random puzzle button */
.random-puzzle-btn {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 16px 20px;
    background: linear-gradient(to right, #D4A012, #B8860B);
    border: none;
    border-radius: 16px;
    color: #1A1A1A;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(180, 134, 11, 0.3);
    text-align: left;
}

.random-puzzle-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(180, 134, 11, 0.4);
}

.random-puzzle-btn .dice {
    font-size: 1.5em;
    margin-right: 14px;
}

.random-puzzle-btn .random-text {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.random-puzzle-btn .random-title {
    font-size: 1.1em;
    font-weight: 700;
}

.random-puzzle-btn .random-subtitle {
    font-size: 0.8em;
    color: #5C4813;
    margin-top: 2px;
}

.random-puzzle-btn .arrow {
    font-size: 1.2em;
    color: #5C4813;
    margin-left: 10px;
}

/* Divider */
.divider {
    display: flex;
    align-items: center;
    gap: 16px;
    margin: 28px 0 24px 0;
}

.divider-line {
    flex: 1;
    height: 1px;
    background: #e5e7eb;
}

.divider-text {
    color: #9ca3af;
    font-size: 0.85em;
    font-weight: 400;
}

/* Difficulty cards */
.difficulty-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 24px;
}

.difficulty-card {
    padding: 16px 10px 14px 10px;
    border-radius: 14px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    background: #f3f4f6;
}

.difficulty-card:hover:not(.selected) {
    background: #e5e7eb;
    transform: scale(1.02);
}

.difficulty-card.selected {
    background: #D4A012;
    color: #1A1A1A;
    box-shadow: 0 4px 12px rgba(180, 134, 11, 0.3), 0 0 0 2px #FFE082;
}

.difficulty-card .diff-name {
    font-weight: 700;
    font-size: 0.95em;
    margin-bottom: 3px;
    color: #4b5563;
}

.difficulty-card.selected .diff-name {
    color: #1A1A1A;
}

.difficulty-card .diff-stars {
    font-size: 0.65em;
    margin-bottom: 8px;
    letter-spacing: 0.5px;
    color: #eab308;
}

.difficulty-card.selected .diff-stars {
    color: #fde047;
}

.difficulty-card .diff-progress {
    font-size: 0.75em;
    color: #9ca3af;
    font-weight: 500;
}

.difficulty-card.selected .diff-progress {
    color: #5C4813;
}

.difficulty-card .progress-bar {
    height: 3px;
    background: #d1d5db;
    border-radius: 2px;
    margin-top: 8px;
    overflow: hidden;
}

.difficulty-card.selected .progress-bar {
    background: #8B6914;
}

.difficulty-card .progress-fill {
    height: 100%;
    background: #D4A012;
    border-radius: 2px;
    transition: width 0.3s;
}

.difficulty-card.selected .progress-fill {
    background: #1A1A1A;
}

/* Size selector */
.size-selector {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-bottom: 4px;
    flex-wrap: wrap;
}

.size-btn {
    padding: 8px 12px;
    border: none;
    border-radius: 8px;
    background: #f3f4f6;
    color: #4b5563;
    font-size: 0.85em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

.size-btn:hover:not(.selected) {
    background: #e5e7eb;
}

.size-btn.selected {
    background: #D4A012;
    color: #1A1A1A;
}

/* How to Play link (prominent) */
.how-to-play-link {
    display: block;
    text-align: center;
    margin-top: 12px;
    margin-bottom: 4px;
}

.how-to-play-link a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #1A1A1A;
    text-decoration: none;
    font-size: 0.95em;
    font-weight: 500;
    padding: 8px 16px;
    border: 2px solid #FFE082;
    border-radius: 20px;
    background: #FFF8E7;
    transition: all 0.2s;
}

.how-to-play-link a:hover {
    background: #FFE082;
    border-color: #D4A012;
}

/* Section label */
.section-label {
    text-align: center;
    color: #6b7280;
    font-size: 0.85em;
    font-weight: 500;
    margin-bottom: 8px;
}

/* Puzzle number grid */
.puzzle-grid {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
    max-width: 380px;
    margin-left: auto;
    margin-right: auto;
    padding-top: 8px;
}

.puzzle-num-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 10px;
    background: #f3f4f6;
    color: #9ca3af;
    font-size: 0.95em;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s;
    position: relative;
}

.puzzle-num-btn:hover:not(.selected) {
    background: #e5e7eb;
    color: #6b7280;
}

.puzzle-num-btn.completed {
    background: #FFF8E7;
    color: #D4A012;
}

.puzzle-num-btn.completed:hover:not(.selected) {
    background: #FFE082;
}

.puzzle-num-btn.completed .check {
    position: absolute;
    top: -4px;
    right: -4px;
    font-size: 0.6em;
    color: #D4A012;
}

.puzzle-num-btn.selected {
    background: #D4A012;
    color: #1A1A1A;
    box-shadow: 0 4px 12px rgba(180, 134, 11, 0.3), 0 0 0 2px #FFE082;
}

.puzzle-num-btn.selected.completed .check {
    color: #5C4813;
}

.puzzle-num-btn.coming-soon {
    background: #f9fafb;
    color: #d1d5db;
    cursor: default;
    position: relative;
}

.puzzle-num-btn.coming-soon:hover {
    background: #f9fafb;
    color: #d1d5db;
}

.puzzle-num-btn.coming-soon::after {
    content: 'Coming Soon';
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: #374151;
    color: white;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 0.7em;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 10;
}

.puzzle-num-btn.coming-soon::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #374151;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 10;
}

.puzzle-num-btn.coming-soon:hover::after,
.puzzle-num-btn.coming-soon:hover::before {
    opacity: 1;
}

/* Puzzle info line */
.puzzle-info {
    text-align: center;
    color: #9ca3af;
    font-size: 0.85em;
    margin-bottom: 20px;
    min-height: 18px;
}

.puzzle-info .completed-count {
    color: #D4A012;
    font-weight: 600;
}

.puzzle-info .best-time-info {
    color: #B8860B;
    font-weight: 500;
}

/* Play button */
.play-selected-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 180px;
    margin: 0 auto 15px;
    padding: 12px 24px;
    background: #D4A012;
    border: none;
    border-radius: 12px;
    color: #1A1A1A;
    font-size: 0.95em;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(180, 134, 11, 0.3);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.play-selected-btn:hover:not(:disabled) {
    background: #B8860B;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(180, 134, 11, 0.4);
}

.play-selected-btn:disabled {
    background: #e0e0e0;
    color: #aaa;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.play-selected-btn .play-icon {
    font-size: 0.85em;
}

/* Home footer */
.home-footer {
    text-align: center;
    padding: 20px 0 10px;
    border-top: 1px solid #e5e7eb;
    margin-top: 10px;
}

.feedback-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: #f3f4f6;
    border-radius: 20px;
    color: #4b5563;
    text-decoration: none;
    font-size: 0.85em;
    font-weight: 500;
    transition: all 0.2s;
    margin-bottom: 12px;
}

.feedback-link:hover {
    background: #e5e7eb;
    color: #1f2937;
}

.credits {
    color: #9ca3af;
    font-size: 0.8em;
}

.credits a {
    color: #D4A012;
    text-decoration: none;
    font-weight: 500;
}

.credits a:hover {
    text-decoration: underline;
}

/* Mobile adjustments for home screen */
@media (max-width: 600px) {
    .home-screen {
        padding: 0 5px;
    }
    
    /* Reduce vertical spacing to fit content on screen */
    .how-to-play-link {
        margin: 10px 0;
    }
    
    .divider {
        margin: 12px 0;
    }
    
    .section-label {
        margin: 10px 0 8px;
    }
    
    .puzzle-info {
        margin: 8px 0;
    }
    
    .difficulty-cards {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        margin-bottom: 12px;
    }
    
    .difficulty-card {
        padding: 14px 10px 12px 10px;
    }
    
    .difficulty-card .diff-name {
        font-size: 0.9em;
    }
    
    .difficulty-card .diff-stars {
        font-size: 0.6em;
    }
    
    .random-puzzle-btn {
        padding: 14px 16px;
    }
    
    .random-puzzle-btn .random-title {
        font-size: 1em;
    }
    
    .random-puzzle-btn .random-subtitle {
        font-size: 0.75em;
    }
    
    .random-puzzle-btn .dice {
        font-size: 1.3em;
        margin-right: 12px;
    }
    
    .size-btn {
        padding: 6px 10px;
        font-size: 0.75em;
    }
    
    .puzzle-num-btn {
        width: 38px;
        height: 38px;
        font-size: 0.85em;
    }
    
    .puzzle-grid {
        gap: 6px;
        max-width: 320px;
    }
    
    .play-selected-btn {
        width: 160px;
        padding: 10px 20px;
        font-size: 0.9em;
    }
    
    .home-footer {
        padding: 15px 0 8px;
        margin-top: 8px;
    }
    
    .feedback-link {
        padding: 6px 12px;
        font-size: 0.8em;
        margin-bottom: 8px;
    }
    
    .credits {
        font-size: 0.75em;
    }
}

@media (max-width: 400px) {
    .difficulty-cards {
        gap: 6px;
    }
    
    .difficulty-card {
        padding: 12px 8px 10px 8px;
    }
    
    .difficulty-card .diff-name {
        font-size: 0.85em;
    }
    
    .difficulty-card .diff-stars {
        font-size: 0.55em;
    }
    
    .difficulty-card .diff-progress {
        font-size: 0.7em;
    }
    
    .size-selector {
        gap: 4px;
    }
    
    .size-btn {
        padding: 5px 8px;
        font-size: 0.7em;
    }
    
    .puzzle-num-btn {
        width: 32px;
        height: 32px;
        font-size: 0.8em;
        border-radius: 6px;
    }
    
    .puzzle-grid {
        gap: 4px;
    }
}

/* ============================================================================
   PORTRAIT COMPACT LAYOUT - Mobile portrait for 7x7+ puzzles
   ============================================================================ */
body.portrait-compact.game-active {
    padding: 0;
    background: white;
}

body.portrait-compact.game-active .container {
    padding: 5px 5px 115px 5px;
    padding-top: max(5px, env(safe-area-inset-top));
    border-radius: 0;
    box-shadow: none;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
}

/* Show header but make it compact */
body.portrait-compact.game-active .header {
    display: flex !important;
    padding: 8px 10px;
    margin-bottom: 10px;
    justify-content: center;
    flex-shrink: 0;
}

body.portrait-compact.game-active .logo-text {
    font-size: 1.4em;
}

body.portrait-compact.game-active .logo-svg {
    width: 28px;
    height: 32px;
}

body.portrait-compact.game-active .auth-container {
    display: none;
}

/* Hide non-essential elements in portrait compact */
body.portrait-compact.game-active .subtitle,
body.portrait-compact.game-active .puzzle-selector,
body.portrait-compact.game-active .top-buttons,
body.portrait-compact.game-active .bottom-stats,
body.portrait-compact.game-active .mode-indicator,
body.portrait-compact.game-active .highlight-toggle {
    display: none;
}

/* Game area - vertical stack */
body.portrait-compact.game-active .game-area {
    flex: 1;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    padding: 60px 10px 5px 10px;
    overflow: visible;
}

/* Grid wrapper - centered horizontally */
body.portrait-compact.game-active .grid-wrapper {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Controls wrapper - holds numbers */
body.portrait-compact.game-active .controls-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

/* Number panel - horizontal rows */
body.portrait-compact.game-active .number-panel {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: 3px;
    margin: 0;
    padding: 0 5px;
    width: 100%;
}

body.portrait-compact.game-active .number-row {
    flex-direction: column;
    gap: 2px;
    align-items: center;
}

/* Compact buttons for portrait */
body.portrait-compact.game-active .number-btn {
    width: 36px;
    height: 36px;
    font-size: 16px;
    border-width: 2px;
    border-radius: 6px;
}

body.portrait-compact.game-active .pencil-btn-small {
    width: 24px;
    height: 24px;
    font-size: 10px;
    border-radius: 4px;
}

body.portrait-compact.game-active .clear-btn,
body.portrait-compact.game-active .undo-btn {
    width: 36px;
    height: 36px;
    font-size: 14px;
    border-width: 2px;
    border-radius: 6px;
}

/* Hide Undo from top (we have it in number panel) */
body.portrait-compact.game-active .landscape-hide {
    display: none;
}

/* Overlays in portrait compact */
body.portrait-compact .start-overlay,
body.portrait-compact .pause-overlay {
    border-radius: 0;
}

body.portrait-compact .start-overlay h2 {
    font-size: 1.3em;
}

body.portrait-compact .start-overlay p {
    font-size: 12px;
    margin-bottom: 12px;
}

body.portrait-compact .start-overlay button {
    padding: 10px 25px;
    font-size: 14px;
}

/* Bottom bar - two rows: controls on top, settings below */
body.portrait-compact.game-active::after {
    content: '';
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 105px;
    background: #FFF8E7;
    z-index: 99;
}

/* Landscape controls - first row of bottom bar */
body.portrait-compact.game-active .landscape-controls {
    display: flex;
    position: fixed;
    bottom: 55px;
    left: 10px;
    right: 10px;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 8px;
    z-index: 100;
}

body.portrait-compact.game-active .landscape-timer-bottom {
    font-size: 14px;
    padding: 6px 10px;
    border-radius: 6px;
    background: white;
    min-width: 50px;
    text-align: center;
}

body.portrait-compact.game-active .landscape-buttons {
    gap: 6px;
}

body.portrait-compact.game-active .landscape-btn {
    width: 36px;
    height: 36px;
    font-size: 16px;
    border-radius: 6px;
}

/* Settings - second row of bottom bar, centered */
body.portrait-compact.game-active .settings-popup {
    display: flex !important;
    position: fixed;
    bottom: 12px;
    left: 10px;
    right: 10px;
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0;
    z-index: 100;
    justify-content: center;
}

body.portrait-compact.game-active .settings-content {
    flex-direction: row;
    gap: 10px;
    align-items: center;
}

body.portrait-compact.game-active .settings-toggle {
    font-size: 12px;
    gap: 4px;
    white-space: nowrap;
    background: white;
    padding: 8px 10px;
    border-radius: 6px;
    border: 1px solid #ccc;
}

body.portrait-compact.game-active .settings-toggle input {
    width: 16px;
    height: 16px;
}

body.portrait-compact.game-active .settings-hint {
    display: none;
}

/* Hide settings button since settings are visible */
body.portrait-compact.game-active #settingsBtn {
    display: none;
}

/* Small screen portrait adjustments */
@media (max-width: 380px) {
    body.portrait-compact.game-active .number-btn {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }
    
    body.portrait-compact.game-active .pencil-btn-small {
        width: 20px;
        height: 20px;
        font-size: 9px;
    }
    
    body.portrait-compact.game-active .clear-btn,
    body.portrait-compact.game-active .undo-btn {
        width: 32px;
        height: 32px;
        font-size: 12px;
    }
    
    body.portrait-compact.game-active .landscape-btn {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }
    
    body.portrait-compact.game-active .landscape-timer-bottom {
        font-size: 12px;
        padding: 5px 8px;
        min-width: 44px;
    }
    
    body.portrait-compact.game-active .settings-toggle {
        font-size: 11px;
        padding: 6px 8px;
    }
    
    body.portrait-compact.game-active .settings-content {
        gap: 6px;
    }
}

/* Very small screens */
@media (max-width: 340px) {
    body.portrait-compact.game-active .number-btn {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }
    
    body.portrait-compact.game-active .pencil-btn-small {
        width: 18px;
        height: 18px;
        font-size: 8px;
    }
    
    body.portrait-compact.game-active .clear-btn,
    body.portrait-compact.game-active .undo-btn {
        width: 28px;
        height: 28px;
        font-size: 11px;
    }
    
    body.portrait-compact.game-active .settings-toggle {
        font-size: 10px;
        padding: 5px 6px;
    }
    
    body.portrait-compact.game-active .settings-content {
        gap: 4px;
    }
    
    body.portrait-compact.game-active .landscape-btn {
        width: 28px;
        height: 28px;
        font-size: 13px;
    }
    
    body.portrait-compact.game-active .landscape-controls {
        gap: 5px;
        bottom: 52px;
    }
    
    body.portrait-compact.game-active .settings-popup {
        bottom: 10px;
    }
}

/* ============================================================================
   BEEWISE COMPLETION ANIMATION
   ============================================================================ */
.bee-celebration-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #D4A012 0%, #B8860B 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

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

.bee-celebration-overlay .bee-container {
    animation: bounceIn 1s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.bee-celebration-overlay.floating .bee-container {
    animation: float 2s ease-in-out infinite;
}

.bee-celebration-overlay h1 {
    color: #1A1A1A;
    font-size: 42px;
    font-weight: bold;
    margin-top: 25px;
    text-shadow: 0 2px 10px rgba(0,0,0,0.1);
    opacity: 0;
    animation: fadeInUp 0.6s ease 0.4s forwards;
}

.bee-celebration-overlay .tagline {
    color: #1A1A1A;
    font-size: 20px;
    margin-top: 12px;
    opacity: 0;
    font-weight: 500;
}

.bee-celebration-overlay .tagline.visible {
    animation: fadeInUp 0.6s ease forwards;
}

/* Sparkle particles */
.sparkle {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    opacity: 0.6;
    animation: sparkle 2s ease-in-out infinite;
}

@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale(0.3) translateY(-150px);
    }
    50% {
        transform: scale(1.1) translateY(0);
    }
    70% {
        transform: scale(0.9);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes float {
    0%, 100% {
        transform: translateY(0) rotate(-2deg);
    }
    50% {
        transform: translateY(-15px) rotate(2deg);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes sparkle {
    0%, 100% {
        opacity: 0.3;
        transform: scale(1);
    }
    50% {
        opacity: 0.8;
        transform: scale(1.5);
    }
}

@keyframes wingFlutter {
    0%, 100% { ry: 7; }
    50% { ry: 8; }
}

/* Mobile adjustments for celebration */
@media (max-width: 600px) {
    .bee-celebration-overlay h1 {
        font-size: 32px;
    }
    
    .bee-celebration-overlay .tagline {
        font-size: 16px;
        margin-top: 8px;
    }
    
    .bee-celebration-overlay .bee-container svg {
        width: 140px;
        height: 161px;
    }
    
    /* Move sparkles higher to avoid overlapping text */
    .bee-celebration-overlay .sparkle {
        top: auto !important;
    }
    
    .bee-celebration-overlay .sparkle:nth-child(1) { top: 8% !important; }
    .bee-celebration-overlay .sparkle:nth-child(2) { top: 18% !important; }
    .bee-celebration-overlay .sparkle:nth-child(3) { top: 28% !important; }
    .bee-celebration-overlay .sparkle:nth-child(4) { top: 12% !important; }
    .bee-celebration-overlay .sparkle:nth-child(5) { top: 22% !important; }
    .bee-celebration-overlay .sparkle:nth-child(6) { top: 32% !important; }
    .bee-celebration-overlay .sparkle:nth-child(7) { top: 15% !important; }
    .bee-celebration-overlay .sparkle:nth-child(8) { top: 25% !important; }
}

/* Mobile adjustments for completion modal */
@media (max-width: 600px) {
    #completionModal .modal-content {
        max-width: calc(100% - 40px);
        margin: 20px;
        padding: 25px 20px;
        max-height: calc(100vh - 40px);
        overflow-y: auto;
    }
    
    #completionModal .modal-content h2 {
        font-size: 1.3em;
        margin-bottom: 10px;
    }
    
    #completionModal .modal-content svg {
        width: 60px;
        height: 69px;
    }
    
    #completionModal .assist-stats {
        padding: 10px;
        margin: 12px 0;
    }
    
    #completionModal .assist-stat {
        font-size: 13px;
        padding: 3px 0;
    }
    
    #completionModal .next-puzzle-prefs {
        margin: 12px 0;
        padding-top: 10px;
    }
    
    #completionModal .share-btn {
        padding: 8px 18px;
        font-size: 13px;
        margin-bottom: 10px;
    }
    
    #completionModal .sign-in-prompt {
        padding: 10px;
        margin-bottom: 10px;
    }
    
    #completionModal .sign-in-prompt p {
        font-size: 13px;
        margin-bottom: 8px;
    }
    
    #completionModal .modal-btn {
        padding: 8px 18px;
        font-size: 13px;
    }
    
    #completionModal .google-signin-btn-modal {
        padding: 8px 14px;
        font-size: 12px;
        gap: 6px;
    }
    
    #completionModal .google-signin-btn-modal svg {
        width: 14px;
        height: 14px;
    }
}

/* Portrait rotation prompt for celebration screen on mobile landscape */
.portrait-prompt-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #D4A012 0%, #B8860B 100%);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2500;
    text-align: center;
    padding: 20px;
}

.portrait-prompt-overlay .rotate-icon {
    font-size: 64px;
    margin-bottom: 20px;
    animation: rotateHint 2s ease-in-out infinite;
}

@keyframes rotateHint {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-20deg); }
    75% { transform: rotate(20deg); }
}

.portrait-prompt-overlay h2 {
    color: #1A1A1A;
    font-size: 1.5em;
    margin-bottom: 10px;
}

.portrait-prompt-overlay p {
    color: rgba(26, 26, 26, 0.8);
    font-size: 14px;
}

/* Show portrait prompt when in landscape on mobile during celebration/completion */
@media (max-width: 900px) and (orientation: landscape) {
    body.showing-completion .portrait-prompt-overlay {
        display: flex;
    }
    
    body.showing-completion .bee-celebration-overlay.active,
    body.showing-completion #completionModal {
        display: none !important;
    }
}
