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

body {
    font-family: 'Segoe UI', Tahoma, Arial, sans-serif;
    background-color: #f0f0f0;
    color: #333;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding-top: 20px;
}

/* 広告を下部に配置 */
body > div[style*="adsbygoogle"],
body > div:has(.adsbygoogle) {
    order: 10;
    width: 100%;
    max-width: 1200px;
    margin-top: 20px;
}

.container {
    background-color: white;
    border: 1px solid #ccc;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    padding: 20px;
    width: 95%;
    max-width: 1200px;
}

header {
    border-bottom: 2px solid #ddd;
    padding-bottom: 10px;
    margin-bottom: 20px;
}

.error-message {
    margin-top: 10px;
    padding: 8px 12px;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 3px;
    color: #666;
    font-size: 0.9em;
    min-height: 20px;
    display: block;
    animation: fadeIn 0.3s ease;
}

.error-message.error {
    background-color: #fff3cd;
    border-color: #ffeaa7;
    color: #856404;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

h1 {
    font-size: 1.5em;
    color: #2c3e50;
    font-weight: normal;
}

.status-bar {
    display: flex;
    justify-content: space-between;
    margin-top: 10px;
    font-size: 0.9em;
    color: #666;
}

.game-area {
    min-height: 600px;
}

.top-section {
    display: flex;
    justify-content: space-between;
    margin-bottom: 30px;
}

.free-cells, .foundations {
    width: 48%;
}

h3 {
    font-size: 1em;
    color: #555;
    margin-bottom: 10px;
    font-weight: normal;
}

.cells {
    display: flex;
    gap: 10px;
}

.free-cell, .foundation-cell {
    width: 80px;
    height: 40px;
    border: 1px dashed #ddd;
    border-radius: 2px;
    background-color: #fafafa;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    font-size: 1em;
}

.foundation-cell {
    border-style: solid;
    background-color: #f0f8ff;
}

.free-cell:hover, .foundation-cell:hover {
    border-color: #aaa;
}

.tableau-section {
    margin-top: 30px;
}

.columns {
    display: flex;
    gap: 2px;
    justify-content: space-between;
}

.column {
    width: 80px;
    min-height: 350px;
    background-color: #fafafa;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 5px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

.card {
    width: 100%;
    height: 30px;
    background-color: #f8f9fa;
    border: 1px solid #d1d3d4;
    border-radius: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1em;
    font-family: 'Consolas', 'Courier New', monospace;
    cursor: pointer;
    position: relative;
    margin-bottom: 2px;
    transition: all 0.3s ease;
    user-select: none;
    box-shadow: 0 1px 1px rgba(0,0,0,0.05);
}

.card.moving {
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    z-index: 100;
}

.card.red {
    background-color: #fef7f7;
    border-color: #e8d4d4;
    color: #8b4545;
}

.card.black {
    background-color: #f7f7f7;
    border-color: #d4d4d4;
    color: #4a4a4a;
}

/* Card type patterns */
.card[data-suit="SPA"] {
    background-image: radial-gradient(circle at 20% 20%, rgba(0,0,0,0.03) 2px, transparent 2px),
                      radial-gradient(circle at 80% 80%, rgba(0,0,0,0.03) 2px, transparent 2px);
    background-size: 15px 15px;
}

.card[data-suit="CLU"] {
    background-image: repeating-linear-gradient(45deg, transparent, transparent 8px, rgba(0,0,0,0.02) 8px, rgba(0,0,0,0.02) 10px);
}

.card[data-suit="HEA"] {
    background-image: radial-gradient(circle at 50% 50%, rgba(139,69,69,0.04) 3px, transparent 3px);
    background-size: 20px 20px;
}

.card[data-suit="DIA"] {
    background-image: linear-gradient(45deg, rgba(139,69,69,0.02) 25%, transparent 25%, transparent 75%, rgba(139,69,69,0.02) 75%),
                      linear-gradient(-45deg, rgba(139,69,69,0.02) 25%, transparent 25%, transparent 75%, rgba(139,69,69,0.02) 75%);
    background-size: 12px 12px;
}

.card:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.card.selected {
    box-shadow: 0 0 0 3px #3498db;
}

.card.multi-selected {
    background-color: #e3f2fd;
    border-color: #2196f3;
}

.card.dragging {
    opacity: 0.5;
}

.controls {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #ddd;
    display: flex;
    gap: 10px;
}

button {
    padding: 8px 16px;
    background-color: #ecf0f1;
    border: 1px solid #bdc3c7;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.9em;
    color: #2c3e50;
}

button:hover {
    background-color: #d5dbdb;
}

button:active {
    background-color: #bdc3c7;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: white;
    padding: 30px;
    border-radius: 5px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    max-width: 500px;
}

.modal-content h2 {
    margin-bottom: 20px;
    color: #2c3e50;
}

.modal-content ul {
    margin-left: 20px;
    margin-bottom: 20px;
}

.modal-content li {
    margin-bottom: 10px;
}

.highlight-valid {
    border: 2px solid #27ae60 !important;
    background-color: #d5f4e6 !important;
}

.highlight-invalid {
    border: 2px solid #e74c3c !important;
}

.emergency-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #2c3e50;
    color: white;
    z-index: 9999;
    justify-content: center;
    align-items: center;
}

.emergency-content {
    text-align: center;
    max-width: 500px;
    padding: 40px;
}

.emergency-content h2 {
    font-size: 2em;
    margin-bottom: 20px;
    color: #ecf0f1;
}

.emergency-content p {
    font-size: 1.1em;
    margin-bottom: 30px;
    color: #bdc3c7;
}

.processing-animation {
    margin-bottom: 30px;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 4px solid #34495e;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

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

.progress-bar {
    width: 100%;
    height: 8px;
    background-color: #34495e;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 30px;
}

.progress-fill {
    height: 100%;
    background-color: #3498db;
    width: 0%;
    animation: progress 3s ease-in-out infinite;
}

@keyframes progress {
    0% { width: 0%; }
    50% { width: 75%; }
    100% { width: 100%; }
}

.emergency-hint {
    font-size: 0.9em;
    color: #7f8c8d;
    font-style: italic;
}

.win-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
}

.win-buttons button {
    flex: 1;
    min-width: 120px;
}

#twitter-share {
    background-color: #1da1f2;
    color: white;
    border: none;
}

#twitter-share:hover {
    background-color: #0d8bd9;
}

.widget-container {
    position: fixed;
    top: 50%;
    right: 30px;
    transform: translateY(-50%);
    z-index: 1000;
}

.widget-close {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background-color: #333;
    color: white;
    border: 1px solid white;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1001;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
    line-height: 1;
    padding: 0;
}

.widget-close:hover {
    background-color: #555;
}

/* Win animation */
@keyframes celebrate {
    0% { transform: scale(1); }
    25% { transform: scale(1.1); }
    50% { transform: scale(1); }
    75% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.7; }
    100% { opacity: 1; }
}

.celebrate-card {
    animation: celebrate 0.6s ease-in-out;
}

.foundation-complete {
    animation: pulse 0.8s ease-in-out;
    background-color: #d4edda !important;
    border-color: #c3e6cb !important;
}

/* Mobile optimizations */
@media (max-width: 768px) {
    .container {
        width: 100%;
        padding: 10px;
    }
    
    .columns {
        gap: 1px;
    }
    
    .column {
        width: 70px;
        min-height: 300px;
    }
    
    .card {
        font-size: 0.9em;
        height: 25px;
    }
    
    .free-cell, .foundation-cell {
        width: 60px;
        height: 30px;
        font-size: 0.8em;
    }
    
    .controls {
        flex-wrap: wrap;
        gap: 5px;
    }
    
    button {
        font-size: 0.8em;
        padding: 6px 12px;
    }
    
    .widget-container {
        right: 10px;
        transform: scale(0.8) translateY(-50%);
    }
}