body {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 0;
    padding: 10px;
    min-height: 100vh;
    position: relative;
}

button {
    margin: 10px 0;
    padding: 10px 20px;
    font-size: 16px;
    cursor: pointer;
    border-radius: 5px;
    border: 1px solid #ccc;
    background-color: #f0f0f0;
}

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

#deck {
    max-width: 500px;
    margin: 0 auto;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(14, auto);
    gap: 2px;
    width: 100%;
    margin-bottom: 20px;
}

.card {
    aspect-ratio: 3/4;
    position: relative;
    cursor: pointer;
}

.card img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: filter 0.3s ease;
}

.used img {
    filter: grayscale(100%) brightness(70%);
}

/* スマートフォン向けの調整 */
@media screen and (max-width: 768px) {
    #deck {
        max-width: 100%;
    }

    .card-grid {
        gap: 1px;
    }
}

.subtitle {
    text-align: center;
    color: #666;
    margin-bottom: 20px;
}

.how-to-use {
    max-width: 500px;
    margin: 60px auto 30px;
    padding: 20px;
    background: #f9f9f9;
    border-radius: 8px;
    position: relative;
    z-index: 1;
}

.how-to-use h2 {
    color: #333;
    margin-bottom: 15px;
}

.how-to-use ol {
    padding-left: 20px;
}

.how-to-use li {
    margin-bottom: 10px;
    line-height: 1.6;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

footer {
    width: 100%;
    text-align: center;
    padding: 20px 0;
    margin-top: auto;
    background-color: #f9f9f9;
    border-top: 1px solid #eee;
}

/* メインコンテンツとサイドバー広告のコンテナ */
.content-wrapper {
    display: flex;
    flex-direction: row;
    justify-content: center;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    position: relative;
}

main {
    width: 100%;
    max-width: 500px;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    margin: 0 auto;
    left: 0;
    right: 0;
}

.card-counter {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 10px 15px;
    border-radius: 20px;
    font-size: 16px;
    z-index: 1000;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

@media screen and (max-width: 768px) {
    .card-counter {
        bottom: 10px;
        right: 10px;
        font-size: 14px;
        padding: 8px 12px;
    }
}

.ad-container-top-right {
    position: absolute;
    top: 0;
    right: 20px;
    z-index: 1000;
    width: 300px;
    height: 300px;
    margin-top: 50px;
    overflow: hidden;
}

.ad-container-top-right ins {
    display: block;
    width: 300px;
    height: 300px;
}

@media screen and (max-width: 900px) {
    .content-wrapper {
        flex-direction: column;
        align-items: center;
        padding: 0 10px;
    }
    
    .ad-container-top-right {
        width: 300px;
        height: 300px;
        max-width: 300px;
        margin: 20px auto;
        order: 2;
        position: relative;
    }
    
    main {
        left: 0;
        order: 1;
    }
    
    footer {
        margin-top: 20px;
    }
    
    header h1 {
        font-size: 24px;
        margin: 10px 0;
    }
    
    .subtitle {
        font-size: 14px;
        margin-bottom: 10px;
    }
    
    button {
        padding: 8px 16px;
        font-size: 14px;
    }
    
    .how-to-use {
        margin: 30px auto 20px;
        padding: 15px;
    }
    
    .how-to-use h2 {
        font-size: 18px;
        margin-bottom: 10px;
    }
    
    .how-to-use li {
        font-size: 14px;
        margin-bottom: 8px;
    }
}

/* さらに小さい画面向けの調整 */
@media screen and (max-width: 480px) {
    .card-grid {
        gap: 1px;
    }
    
    header h1 {
        font-size: 20px;
    }
    
    .ad-container-top-right {
        width: 100%;
        height: auto;
        max-width: 100%;
    }
    
    .ad-container-top-right ins {
        width: 100%;
        height: auto;
    }
    
    footer {
        padding: 15px 0;
        font-size: 12px;
    }
}