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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    flex-direction: column; /* 縦並び */
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: pan-x pan-y;  /* シングルタッチのスクロールのみ許可、マルチタッチ禁止 */
}

/* ここで縦並び */
.page {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.window {
    background: linear-gradient(to bottom, #f8f9fa, #e9ecef);
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    min-width: 900px;
    overflow: hidden;
}

.title-bar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 20px;
    font-weight: 600;
    font-size: 18px;
    letter-spacing: 0.5px;
}

.title-bar-text {
    flex: 1;
    text-align: center;
}

.timer {
    font-size: 20px;
    font-weight: 700;
    font-family: 'Courier New', monospace;
    background: rgba(255, 255, 255, 0.2);
    padding: 6px 14px;
    border-radius: 8px;
    min-width: 80px;
    text-align: center;
    flex-shrink: 0;
}

.game-container {
    background: linear-gradient(135deg, #1a5f3f 0%, #0d4028 100%);
    padding: 30px 15px;
    min-height: 600px;
    display: flex;
    flex-direction: column;
    align-items: center;
    touch-action: none;  /* マルチタッチ完全禁止 */
}

.top-section {
    display: flex;
    justify-content: center;
    gap: 80px;
    margin-bottom: 30px;
}

.free-cells, .foundations {
    display: flex;
    gap: 10px;
}

.card-slot {
    width: 95px;
    height: 125px;
    border: 3px dashed rgba(255, 255, 255, 0.25);
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.15);
    position: relative;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-slot.highlight {
    background: rgba(255, 215, 0, 0.3);
    border-color: #ffd700;
    border-style: solid;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
    transform: scale(1.05);
}

.tableau {
    display: flex;
    gap: 45px;
    justify-content: center;
    width: 100%;
    max-width: fit-content;
    margin: 0 auto;
}

.cascade {
    width: 85px;
    min-height: 115px;
    position: relative;
    padding: 20px 15px;
    margin: -20px -15px;
}

.card {
    width: 85px;
    height: 115px;
    background: linear-gradient(to bottom, #ffffff, #f8f9fa);
    border: 2px solid #dee2e6;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    cursor: pointer;
    position: absolute;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    user-select: none;
    transition: all 0.2s;
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
}

.card.dragging {
    opacity: 0.4;
    cursor: grabbing;
}

.card.red {
    color: #e63946;
}

.card.black {
    color: #1d3557;
}

.card-header {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 6px 8px;
    font-weight: 700;
}

.card-header-value {
    font-size: 18px;
    line-height: 1;
}

.card-header-suit {
    font-size: 20px;
    line-height: 1;
}

.card-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    flex: 1;
}

.card-value {
    font-size: 28px;
    font-weight: 700;
    line-height: 1;
}

.card-suit {
    font-size: 32px;
    line-height: 1;
}

.toolbar {
    background: rgba(255, 255, 255, 0.9);
    padding: 16px 20px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    display: flex;
    gap: 16px;
    align-items: center;
    font-size: 15px;
    font-weight: 500;
}

.toolbar input {
    width: 100px;
    padding: 10px 14px;
    font-size: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    transition: all 0.2s;
}

.toolbar input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.toolbar button {
    padding: 10px 20px;
    font-size: 15px;
    font-weight: 600;
    border: none;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.toolbar button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.toolbar button:active {
    transform: translateY(0);
}

.toolbar input[type="file"] {
    display: none;
}

.status-bar {
    background: rgba(255, 255, 255, 0.95);
    padding: 14px 20px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    font-size: 15px;
    font-weight: 500;
    color: #495057;
}

.foundation[data-suit="hearts"]::before,
.foundation[data-suit="diamonds"]::before,
.foundation[data-suit="clubs"]::before,
.foundation[data-suit="spades"]::before {
    content: '';
    position: absolute;
    font-size: 48px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0.25;
}

.foundation[data-suit="hearts"]::before { content: '♥'; color: #e63946; }
.foundation[data-suit="diamonds"]::before { content: '♦'; color: #e63946; }
.foundation[data-suit="clubs"]::before { content: '♣'; color: #1d3557; }
.foundation[data-suit="spades"]::before { content: '♠'; color: #1d3557; }

/* 勝利アニメーション */
.win-animation {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
}

.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    top: -10px;
    animation: confetti-fall linear forwards;
}

@keyframes confetti-fall {
    to {
        transform: translateY(100vh) rotate(360deg);
        opacity: 0;
    }
}

/* ゲーム一覧パネル */
.game-list-panel {
    background: rgba(255, 255, 255, 0.98);
    max-height: 500px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    transition: max-height 0.3s ease;
}

.game-list-panel.hidden {
    max-height: 0;
    border-top: none;
}

.game-list-header {
    padding: 16px 20px;
    border-bottom: 2px solid rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.game-list-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin: 0;
}

.game-list-stats {
    display: flex;
    gap: 16px;
    align-items: center;
    font-size: 14px;
}

.game-list-stats button {
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 600;
    border: none;
    background: #e9ecef;
    color: #495057;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.game-list-stats button:hover {
    background: #dee2e6;
    transform: translateY(-1px);
}

.game-list-stats button:active {
    transform: translateY(0);
}

.game-list-grid {
    padding: 16px;
    overflow-y: auto;
    max-height: 400px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
    gap: 4px;
}

.game-number-cell {
    padding: 8px 4px;
    text-align: center;
    font-size: 13px;
    font-weight: 500;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    background: #f8f9fa;
    color: #495057;
    border: 1px solid transparent;
}

.game-number-cell:hover {
    background: #e9ecef;
    transform: scale(1.05);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.game-number-cell.cleared {
    background: linear-gradient(135deg, #51cf66, #37b24d);
    color: white;
    font-weight: 700;
    border: 1px solid #2f9e44;
}

.game-number-cell.cleared:hover {
    background: linear-gradient(135deg, #69db7c, #51cf66);
    box-shadow: 0 2px 8px rgba(55, 178, 77, 0.4);
}

.game-number-cell.current {
    border: 2px solid #667eea;
    background: #e7f5ff;
    font-weight: 700;
}

.game-number-cell.selected {
    border: 3px solid #ff6b6b;
    background: #fff3cd;
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(255, 107, 107, 0.4);
    z-index: 10;
}

.game-number-cell.cleared.selected {
    border: 3px solid #ff6b6b;
    background: linear-gradient(135deg, #51cf66, #37b24d);
}

/* ゲーム情報表示エリア */
.game-info-display {
    padding: 16px 20px;
    background: #f8f9fa;
    border-bottom: 2px solid #dee2e6;
    transition: all 0.3s;
}

.game-info-display.hidden {
    display: none;
}

.game-info-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.game-info-number {
    font-size: 18px;
    font-weight: 700;
    color: #495057;
}

.game-info-status {
    font-size: 16px;
    font-weight: 600;
    padding: 4px 0;
}

.game-info-status.cleared {
    color: #37b24d;
}

.game-info-status.not-cleared {
    color: #868e96;
}

.game-info-details {
    font-size: 14px;
    color: #495057;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.game-info-action {
    font-size: 13px;
    color: #ff6b6b;
    font-weight: 600;
    margin-top: 4px;
    animation: pulse 2s infinite;
}

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