/* Strands Game - Studio Ghibli Style */

/* ===== ARCHIVE NOTICE ===== */
.archive-notice {
    background: linear-gradient(135deg, var(--ghibli-sunset-orange), var(--ghibli-cherry-blossom));
    color: var(--ghibli-paper-white);
    text-align: center;
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(212, 151, 90, 0.3);
}

.archive-notice a {
    color: var(--ghibli-paper-white);
    text-decoration: underline;
    font-weight: bold;
}

.archive-notice a:hover {
    text-decoration: none;
}

/* ===== STRANDS-SPECIFIC LAYOUT ===== */
.game-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    background: linear-gradient(135deg, var(--ghibli-paper-white) 0%, var(--ghibli-warm-cream) 100%);
    min-height: calc(100vh - 200px);
    border-radius: 15px;
    box-shadow: 0 8px 32px var(--ghibli-soft-shadow);
    margin-top: 20px;
    margin-bottom: 20px;
}

/* ===== GAME HEADER ===== */
.game-header {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px;
    background: #e596ac;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(229, 150, 172, 0.3);
}

.game-title {
    font-size: 2.5rem;
    color: var(--ghibli-charcoal);
    margin: 0 0 10px 0;
    text-shadow: 2px 2px 4px rgba(255, 255, 255, 0.5);
    font-weight: bold;
}

.game-subtitle {
    font-size: 1.2rem;
    color: var(--ghibli-deep-green);
    margin: 0 0 20px 0;
    font-style: italic;
}

/* ===== PUZZLE INFO ===== */
.puzzle-info {
    margin-top: 20px;
    padding: 15px;
    background: rgba(250, 248, 244, 0.8);
    border-radius: 8px;
    backdrop-filter: blur(5px);
}

.puzzle-clue {
    padding: 15px;
    background: #f8e7ed;
    border-radius: 6px;
    border: 2px solid #e596ac;
    font-weight: 600;
    color: var(--ghibli-charcoal);
    text-align: center;
    font-size: 1.1rem;
}


/* ===== GAME BOARD SECTION ===== */
.game-board-section {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 30px;
    margin-bottom: 30px;
}

.game-board-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

/* ===== LETTER GRID ===== */
.letter-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    grid-template-rows: repeat(8, 1fr);
    gap: min(12px, 2vw);
    padding: min(30px, 4vw);
    background: linear-gradient(135deg, #f8e7ed, #f0d4dc);
    border-radius: 15px;
    box-shadow: inset 0 4px 12px rgba(229, 150, 172, 0.3);
    border: 3px solid #e596ac;
    width: calc(100vw - 40px);
    max-width: 480px;
    height: auto;
    box-sizing: border-box;
    margin: 0 auto;
}

.letter-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 8px;
    font-size: 1.5rem;
    font-weight: bold;
    color: #1a1a1a;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    position: relative;
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    text-shadow: 
        2px 2px 4px rgba(255, 255, 255, 0.9), 
        -1px -1px 2px rgba(255, 255, 255, 0.7),
        0 0 3px rgba(255, 255, 255, 0.8);
}

.letter-cell:hover {
    background: rgba(229, 150, 172, 0.3);
    border: 2px solid #a84467;
    transform: scale(1.05);
    z-index: 10;
    text-shadow: none;
}

.letter-cell.selected {
    background: rgba(244, 208, 63, 0.8);
    border: 2px solid var(--ghibli-sunset-orange);
    color: var(--ghibli-ink-black);
    transform: scale(1.1);
    z-index: 15;
    box-shadow: 0 4px 12px var(--ghibli-magic-glow);
    text-shadow: none;
}

.letter-cell.found-theme {
    background: linear-gradient(135deg, #d17a99, #e596ac);
    color: var(--ghibli-paper-white);
    border: 2px solid #a84467;
    text-shadow: none;
}

.letter-cell.found-spangram {
    background: linear-gradient(135deg, var(--ghibli-magic-gold), var(--ghibli-sunset-orange));
    color: var(--ghibli-ink-black);
    border: 2px solid var(--ghibli-sunset-orange);
    animation: spangramGlow 2s ease-in-out infinite alternate;
    text-shadow: none;
}

@keyframes spangramGlow {
    0% { box-shadow: 0 4px 12px var(--ghibli-magic-glow); }
    100% { box-shadow: 0 6px 20px rgba(244, 208, 63, 0.6); }
}

.letter-cell.path-highlight {
    background: rgba(244, 208, 63, 0.5);
    border: 2px solid var(--ghibli-sunset-orange);
    text-shadow: none;
}

/* ===== GAME CONTROLS ===== */
.game-controls {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.control-btn {
    padding: 10px 20px;
    background: #e596ac;
    color: var(--ghibli-paper-white);
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(229, 150, 172, 0.3);
}

.control-btn:hover {
    background: #d17a99;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(209, 122, 153, 0.4);
}

.control-btn:active {
    transform: translateY(0);
}

.control-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* ===== START FRESH BUTTON ===== */
.start-fresh-btn {
    background: #a84467 !important;
    color: var(--ghibli-paper-white) !important;
    box-shadow: 0 4px 12px rgba(168, 68, 103, 0.3) !important;
}

.start-fresh-btn:hover {
    background: #954060 !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 6px 16px rgba(240, 163, 176, 0.4) !important;
}

.start-fresh-btn:active {
    transform: translateY(0) !important;
    background: var(--ghibli-deep-green) !important;
}

/* ===== HINT PROGRESS BUTTON ===== */
.hint-progress-button {
    position: relative;
    padding: 10px 20px;
    background: var(--ghibli-twilight-purple);
    color: var(--ghibli-paper-white);
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(139, 124, 163, 0.3);
    overflow: hidden;
    min-width: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.hint-progress-button:hover {
    background: var(--ghibli-cherry-blossom);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(240, 163, 176, 0.4);
}

.hint-progress-button.can-hint {
    background: var(--ghibli-forest-green);
    cursor: pointer;
}

.hint-progress-button.can-hint:hover {
    background: var(--ghibli-deep-green);
}

.hint-progress-fill {
    position: absolute;
    left: 0;
    bottom: 0;
    height: 4px;
    background: var(--ghibli-magic-gold);
    transition: width 0.5s ease;
    width: 0%;
}

.hint-button-text {
    position: relative;
    z-index: 2;
}

.hint-counter {
    position: relative;
    z-index: 2;
    font-size: 0.9rem;
    opacity: 0.9;
}

/* ===== WORD LISTS SIDEBAR ===== */
.word-lists {
    background: linear-gradient(135deg, #faf2f6, #f0d4dc);
    border-radius: 12px;
    padding: 20px;
    border: 2px solid #e596ac;
    box-shadow: 0 4px 16px rgba(229, 150, 172, 0.3);
    height: fit-content;
}

.word-category {
    margin-bottom: 25px;
}

.word-category h3 {
    color: #a84467;
    margin: 0 0 10px 0;
    font-size: 1.2rem;
    border-bottom: 2px solid #e596ac;
    padding-bottom: 5px;
}

.word-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Theme Word Card Container */
.theme-word-card {
    perspective: 1000px;
    height: 40px;
    margin-bottom: 8px;
}

.theme-word-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform-style: preserve-3d;
}

.theme-word-card.flipped .theme-word-inner {
    transform: rotateY(180deg);
}

/* Success pulse animation when card flips */
.theme-word-card.flipped {
    animation: card-success-pulse 0.6s ease-in-out;
}

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

.theme-word-front, .theme-word-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    padding: 8px 12px;
    box-sizing: border-box;
}

.theme-word-front {
    background: linear-gradient(135deg, #f8e7ed, #f0d4dc);
    border: 2px solid #e596ac;
    color: var(--ghibli-charcoal);
    box-shadow: 0 2px 8px rgba(229, 150, 172, 0.2);
}

.theme-word-back {
    background: linear-gradient(135deg, #d17a99, #e596ac);
    color: var(--ghibli-paper-white);
    border: 2px solid #a84467;
    transform: rotateY(180deg);
    box-shadow: 0 4px 12px rgba(209, 122, 153, 0.3);
}

/* Hover effect for unrevealed cards */
.theme-word-card:not(.flipped):hover .theme-word-inner {
    transform: rotateY(5deg);
}

.theme-word-card:not(.flipped):hover .theme-word-front {
    border-color: #d17a99;
    box-shadow: 0 4px 12px rgba(209, 122, 153, 0.3);
}

/* Placeholder dots animation */
.theme-word-dots {
    display: inline-block;
    letter-spacing: 2px;
    font-size: 0.8em;
    animation: dots-pulse 2s ease-in-out infinite;
    color: var(--ghibli-twilight-purple);
}

@keyframes dots-pulse {
    0%, 70%, 100% {
        opacity: 0.3;
        transform: scale(0.9);
    }
    35% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Legacy word item styles for backward compatibility */
.word-item {
    padding: 8px 12px;
    background: #f8e7ed;
    border-radius: 6px;
    border: 1px solid #e596ac;
    font-weight: 600;
    color: var(--ghibli-charcoal);
    transition: all 0.2s ease;
}

.word-item.found {
    background: #e596ac;
    color: var(--ghibli-paper-white);
    border-color: #a84467;
}

.word-item.spangram {
    background: linear-gradient(135deg, var(--ghibli-magic-gold), var(--ghibli-sunset-orange));
    color: var(--ghibli-ink-black);
    border-color: var(--ghibli-sunset-orange);
    font-size: 1.1rem;
    font-weight: bold;
}

.progress-indicator {
    margin-top: 10px;
    padding: 8px;
    background: #e596ac;
    border-radius: 6px;
    text-align: center;
    color: var(--ghibli-paper-white);
    font-weight: bold;
}

.spangram-placeholder {
    color: #a84467;
    font-style: italic;
    text-align: center;
    display: block;
    padding: 15px;
}

/* ===== GAME STATUS ===== */
.game-status {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: var(--ghibli-soft-gray);
    border-radius: 10px;
    border: 2px solid var(--ghibli-forest-green);
    margin-bottom: 20px;
}

.status-message {
    font-weight: 600;
    color: var(--ghibli-charcoal);
}

/* ===== TIMER ABOVE GAME BOARD ===== */
.timer {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: bold;
    color: var(--ghibli-deep-green);
    font-size: 1.3rem;
}

#timer-display {
    font-family: 'Courier New', monospace;
    font-weight: bold;
    color: var(--ghibli-deep-green);
}

.pause-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.3s ease;
    color: var(--ghibli-deep-green);
}

.pause-btn:hover {
    background: rgba(125, 155, 95, 0.2);
    transform: scale(1.1);
}

.pause-btn.paused {
    color: var(--ghibli-cherry-blossom);
}

/* ===== MODAL STYLES ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(45, 41, 37, 0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.modal-overlay.show {
    display: flex;
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideIn {
    from { 
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to { 
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Success Modal Styles */
.success-modal {
    background: white;
    padding: 32px;
    border-radius: 16px;
    box-shadow: rgba(0, 0, 0, 0.3) 0px 20px 50px;
    text-align: center;
    max-width: 400px;
    margin: 20px;
    animation: slideIn 0.3s ease-in-out;
}

.success-emoji {
    font-size: 48px;
    margin-bottom: 16px;
}

.success-title {
    font-size: 1.5em;
    font-weight: bold;
    margin-bottom: 8px;
    color: #1f2937;
}

.success-subtitle {
    font-size: 1.1em;
    margin-bottom: 8px;
    color: #4b5563;
}

.success-time {
    font-size: 0.9em;
    margin-bottom: 20px;
    color: #6b7280;
}

.success-share-section {
    margin-bottom: 20px;
}

.share-label {
    font-size: 0.9em;
    margin-bottom: 12px;
    color: #4b5563;
    font-weight: 500;
}

.share-buttons {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.share-btn {
    border: none;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.85em;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    color: white;
}

.share-facebook {
    background: #1877f2;
}

.share-facebook:hover {
    background: #166fe5;
    transform: translateY(-1px);
}

.share-reddit {
    background: #ff4500;
}

.share-reddit:hover {
    background: #e63e00;
    transform: translateY(-1px);
}

.share-discord {
    background: #5865f2;
}

.share-discord:hover {
    background: #4752c4;
    transform: translateY(-1px);
}

.success-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.success-btn {
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.success-btn-primary {
    background: #10b981;
    color: white;
}

.success-btn-primary:hover {
    background: #0d9668;
    transform: translateY(-1px);
}

.success-btn-secondary {
    background: #6b7280;
    color: white;
}

.success-btn-secondary:hover {
    background: #555e6e;
    transform: translateY(-1px);
}

/* Legacy modal styles for backward compatibility */
.modal-content {
    background: linear-gradient(135deg, var(--ghibli-paper-white), var(--ghibli-warm-cream));
    padding: 30px;
    border-radius: 15px;
    border: 3px solid var(--ghibli-forest-green);
    box-shadow: 0 12px 40px var(--ghibli-soft-shadow);
    text-align: center;
    max-width: 400px;
    width: 90%;
}

.modal-content h2 {
    color: var(--ghibli-deep-green);
    margin: 0 0 15px 0;
    font-size: 2rem;
}

.game-stats {
    margin: 20px 0;
    padding: 15px;
    background: var(--ghibli-spirit-blue);
    border-radius: 8px;
}

.stat {
    margin: 8px 0;
    font-weight: 600;
    color: var(--ghibli-charcoal);
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 20px;
}

.action-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
}

.action-btn.primary {
    background: var(--ghibli-forest-green);
    color: var(--ghibli-paper-white);
}

.action-btn.primary:hover {
    background: var(--ghibli-deep-green);
}

.action-btn.secondary {
    background: var(--ghibli-soft-gray);
    color: var(--ghibli-charcoal);
}

.action-btn.secondary:hover {
    background: var(--ghibli-twilight-purple);
    color: var(--ghibli-paper-white);
}

.action-btn:not(.secondary):not(.primary) {
    background: var(--ghibli-cherry-blossom);
    color: var(--ghibli-paper-white);
}

.action-btn:not(.secondary):not(.primary):hover {
    background: var(--ghibli-sunset-orange);
}

/* ===== LOADING OVERLAY ===== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--ghibli-paper-white), var(--ghibli-warm-cream));
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    z-index: 2000;
}

.loading-overlay.show {
    display: flex;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--ghibli-soft-gray);
    border-top: 4px solid var(--ghibli-forest-green);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-overlay p {
    color: var(--ghibli-charcoal);
    font-size: 1.2rem;
    font-weight: 600;
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 768px) {
    .game-container {
        padding: 15px;
        margin: 10px;
        box-sizing: border-box;
        width: calc(100% - 20px);
        max-width: calc(100vw - 20px);
    }
    
    .game-board-section {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .word-lists {
        order: -1;
        padding: 15px;
        max-width: 100%;
        box-sizing: border-box;
        margin: 0 auto;
    }
    
    .letter-grid {
        width: calc(100vw - 30px);
        max-width: 320px;
        padding: 10px;
        gap: 4px;
        margin: 0 auto;
    }
    
    .letter-cell {
        font-size: min(12px, calc(((100vw - 30px - 20px - 20px) / 6) * 0.6));
        width: calc((100vw - 30px - 20px - 20px) / 6);
        height: 18px;
        min-height: 18px;
        max-height: 18px;
        aspect-ratio: unset;
    }
    
    .game-title {
        font-size: 2rem;
    }
    
    
    .game-controls {
        gap: 10px;
    }
    
    .control-btn {
        padding: 8px 16px;
        font-size: 0.9rem;
    }
    
    .modal-content {
        padding: 20px;
        margin: 20px;
    }
    
    .modal-actions {
        flex-direction: column;
    }
    
    .action-btn {
        width: 100%;
        margin: 5px 0;
    }
}

@media (max-width: 480px) {
    .letter-grid {
        width: calc(100vw - 25px);
        max-width: 280px;
        padding: 8px;
        gap: 3px;
        margin: 0 auto;
    }
    
    .letter-cell {
        font-size: min(10px, calc(((100vw - 25px - 16px - 15px) / 6) * 0.6));
        width: calc((100vw - 25px - 16px - 15px) / 6);
        height: 15px;
        min-height: 15px;
        max-height: 15px;
        aspect-ratio: unset;
    }
}

@media (max-width: 360px) {
    .letter-grid {
        width: calc(100vw - 20px);
        max-width: 240px;
        padding: 6px;
        gap: 2px;
        margin: 0 auto;
    }
    
    .letter-cell {
        font-size: 12px !important;
        width: 33px !important;
        max-width: 33px !important;
        height: 34px !important;
        min-height: 34px !important;
        max-height: 34px !important;
        aspect-ratio: unset !important;
    }
    
    .game-title {
        font-size: 1.5rem;
    }
    
    .game-subtitle {
        font-size: 1rem;
    }
    
    .word-lists {
        padding: 10px;
    }
    
    .game-status {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
}

/* ===== TOUCH OPTIMIZATION ===== */
@media (hover: none) and (pointer: coarse) {
    .letter-cell {
        min-height: 55px;
        font-size: 1.4rem;
    }
    
    .letter-cell:hover {
        transform: none;
    }
    
    .letter-cell:active {
        background: var(--ghibli-spirit-blue);
        transform: scale(0.95);
    }
    
    .control-btn {
        min-height: 44px;
        padding: 12px 24px;
    }
    
    .mode-btn {
        min-height: 44px;
        padding: 10px 18px;
    }
}

/* ===== ACCESSIBILITY ===== */
/* ===== GAME INSTRUCTIONS ===== */
.game-instructions {
    max-width: 800px;
    margin: 40px auto;
    padding: 30px;
    background: linear-gradient(135deg, #faf2f6, #f0d4dc);
    border: 2px solid #e596ac;
    border-radius: 15px;
    box-shadow: 0 6px 20px rgba(229, 150, 172, 0.3);
}

.game-instructions h2 {
    color: #a84467;
    font-size: 1.8rem;
    margin-bottom: 25px;
    text-align: center;
    text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.5);
}

.instruction-step {
    margin-bottom: 30px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 12px;
    border-left: 4px solid #e596ac;
    transition: all 0.3s ease;
}

.instruction-step:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(229, 150, 172, 0.3);
}

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

.instruction-step h3 {
    color: var(--ghibli-charcoal);
    font-size: 1.3rem;
    margin-bottom: 15px;
    font-weight: bold;
}

.instruction-step ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.instruction-step li {
    margin-bottom: 10px;
    padding-left: 25px;
    position: relative;
    color: var(--ghibli-charcoal);
    line-height: 1.5;
}

.instruction-step li:before {
    content: '•';
    color: #e596ac;
    font-weight: bold;
    font-size: 1.2rem;
    position: absolute;
    left: 0;
    top: -2px;
}

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

/* Word examples styling */
.theme-word-example {
    background: #e596ac;
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: bold;
    font-size: 0.9rem;
}

.spangram-example {
    background: var(--ghibli-magic-gold);
    color: var(--ghibli-charcoal);
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: bold;
    font-size: 0.9rem;
}

/* ===== INSTRUCTION DEMOS ===== */
.instruction-demo {
    margin-bottom: 20px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 8px;
    text-align: center;
}

.demo-grid {
    display: grid;
    gap: 3px;
    margin: 0 auto 10px auto;
    justify-content: center;
}

.step1-demo {
    grid-template-columns: repeat(6, 1fr);
    max-width: 240px;
}

.step2-demo {
    grid-template-columns: repeat(4, 1fr);
    max-width: 160px;
}

.step3-demo {
    grid-template-columns: repeat(6, 1fr);
    max-width: 240px;
}

.demo-cell {
    width: 35px;
    height: 35px;
    background: var(--ghibli-paper-white);
    border: 2px solid var(--ghibli-soft-gray);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.1rem;
    color: var(--ghibli-charcoal);
    transition: all 0.3s ease;
    cursor: default;
    user-select: none;
    -webkit-user-select: none;
    pointer-events: none;
}

.demo-cell:hover {
    transform: none;
}

/* Step 1: Drag path animation */
.demo-cell.selecting {
    background: var(--ghibli-spirit-blue);
    color: white;
    border-color: var(--ghibli-sky-blue);
    position: relative;
}

.demo-cell.dragging {
    animation: drag-pulse 0.6s ease-in-out;
    box-shadow: 0 0 15px var(--ghibli-magic-glow);
}

.demo-cell.selecting::after {
    content: '';
    position: absolute;
    top: 50%;
    right: -6px;
    width: 0;
    height: 0;
    border-left: 6px solid var(--ghibli-spirit-blue);
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
    transform: translateY(-50%);
    opacity: 0.8;
}

.demo-cell.selecting:last-of-type::after {
    display: none;
}

.demo-cell.theme-found {
    background: var(--ghibli-sky-blue);
    color: white;
    border-color: var(--ghibli-spirit-blue);
    animation: found-word 0.8s ease-in-out;
}

.demo-cell.theme-found::after {
    display: none;
}

/* Step 2: Spangram and theme cells */
.demo-cell.spangram-cell {
    background: var(--ghibli-magic-gold);
    color: var(--ghibli-charcoal);
    border-color: var(--ghibli-sunset-orange);
    font-weight: bold;
}

.demo-cell.theme-cell {
    background: var(--ghibli-sky-blue);
    color: white;
    border-color: var(--ghibli-spirit-blue);
}

/* Step 3: Hint cells */
.demo-cell.hint-cell {
    background: var(--ghibli-nature-moss);
    color: white;
    border-color: var(--ghibli-forest-green);
    animation: hint-reveal 2s ease-in-out infinite;
}

.demo-caption {
    font-size: 0.9rem;
    color: var(--ghibli-deep-green);
    font-style: italic;
    margin-bottom: 8px;
}

.drag-instruction {
    font-size: 0.8rem;
    color: var(--ghibli-cherry-blossom);
    font-weight: bold;
    background: rgba(240, 163, 176, 0.1);
    padding: 6px 12px;
    border-radius: 15px;
    margin-top: 8px;
    border: 1px solid var(--ghibli-cherry-blossom);
}

.hint-counter {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 10px;
    font-size: 0.8rem;
}

.hint-progress {
    background: var(--ghibli-soft-peach);
    padding: 4px 8px;
    border-radius: 12px;
    color: var(--ghibli-charcoal);
}

.hint-earned {
    background: var(--ghibli-nature-moss);
    color: white;
    padding: 4px 8px;
    border-radius: 12px;
    animation: hint-earned 1.5s ease-in-out infinite;
}

/* ===== DEMO ANIMATIONS ===== */
@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

@keyframes drag-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

@keyframes found-word {
    0% { transform: scale(1); }
    50% { transform: scale(1.15); box-shadow: 0 0 20px var(--ghibli-magic-glow); }
    100% { transform: scale(1); }
}

@keyframes hint-reveal {
    0%, 60% { opacity: 0.4; transform: scale(0.9); }
    80%, 100% { opacity: 1; transform: scale(1); }
}

@keyframes hint-earned {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.05); opacity: 0.8; }
}

/* Theme Word Cards Responsive */
@media (max-width: 768px) {
    .theme-word-card {
        height: 36px;
        margin-bottom: 6px;
    }
    
    .theme-word-front, .theme-word-back {
        padding: 6px 10px;
        font-size: 0.9em;
    }
    
    .theme-word-dots {
        letter-spacing: 1px;
        font-size: 0.75em;
    }
    
    /* Reduce hover effects on mobile */
    .theme-word-card:not(.flipped):hover .theme-word-inner {
        transform: none;
    }
}

/* Success Modal Responsive */
@media (max-width: 768px) {
    .success-modal {
        padding: 24px;
        margin: 16px;
        max-width: 350px;
    }
    
    .success-emoji {
        font-size: 40px;
        margin-bottom: 12px;
    }
    
    .success-title {
        font-size: 1.3em;
        margin-bottom: 6px;
    }
    
    .success-subtitle {
        font-size: 1em;
        margin-bottom: 6px;
    }
    
    .success-time {
        font-size: 0.85em;
        margin-bottom: 16px;
    }
    
    .share-buttons {
        flex-direction: column;
        gap: 6px;
    }
    
    .share-btn {
        width: 100%;
        justify-content: center;
        padding: 10px 16px;
        font-size: 0.9em;
    }
    
    .success-actions {
        flex-direction: column;
        gap: 8px;
    }
    
    .success-btn {
        width: 100%;
        padding: 12px 20px;
    }
}

/* Responsive instructions */
@media (max-width: 768px) {
    .game-instructions {
        margin: 20px auto;
        padding: 20px;
        width: calc(100% - 40px);
        max-width: calc(100vw - 40px);
        box-sizing: border-box;
    }
    
    .game-instructions h2 {
        font-size: 1.5rem;
    }
    
    .instruction-step {
        padding: 15px;
    }
    
    .instruction-step h3 {
        font-size: 1.1rem;
    }
    
    .demo-cell {
        width: 28px;
        height: 28px;
        font-size: 0.9rem;
    }
    
    .step1-demo {
        max-width: 180px;
    }
    
    .step2-demo {
        max-width: 120px;
    }
    
    .step3-demo {
        max-width: 180px;
    }
    
    .hint-counter {
        flex-direction: column;
        gap: 8px;
    }
    
    .demo-caption {
        font-size: 0.8rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .letter-cell:hover,
    .letter-cell.selected {
        transform: none;
    }
    
    .control-btn:hover {
        transform: none;
    }
    
    .mode-btn:hover {
        transform: none;
    }
    
    .instruction-step:hover {
        transform: none;
    }
}

/* ===== AD CONTAINER STYLING ===== */
.ad-container {
    width: 100%;
    max-width: 728px;
    min-height: 90px;
    margin: 20px auto;
    padding: 10px;
    box-sizing: border-box;
    display: flex;
    justify-content: center;
    align-items: center;
}

.ad-container .adsbygoogle {
    width: 100%;
    min-width: 320px;
    min-height: 90px;
    display: block !important;
}

/* Responsive ad sizing */
@media (max-width: 768px) {
    .ad-container {
        max-width: 320px;
        min-height: 50px;
    }
    
    .ad-container .adsbygoogle {
        min-width: 300px;
        min-height: 50px;
    }
}