body {
    font-family: Arial, sans-serif;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    background-color: #f7f7f7;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

#game-container {
    text-align: center;
    background-color: #fff;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 600px;
    margin: 20px auto;
    box-sizing: border-box;
}

h1 {
    margin-bottom: 20px;
}

#attempts-container {
    display: flex;
    flex-direction: column-reverse;
    gap: 10px;
    margin-bottom: 20px;
}

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

.slot {
    width: 40px;
    height: 40px;
    margin: 0 5px;
    border: 2px dashed #ccc;
    border-radius: 50%;
    transition: border-color 0.3s, transform 0.3s;
    cursor: pointer;
}

.highlight {
    border-color: blue;
    transform: scale(1.1);
}

.result {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(2, 1fr);
    width: 40px;
    height: 40px;
    background-color: #eee;
    border: 2px solid #ccc;
    margin-left: 10px;
    position: relative;
}

.dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: black;
    justify-self: center;
    align-self: center;
}

.ok-button {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 40px;
    height: 40px;
    background-color: green;
    color: white;
    font-size: 14px;
    line-height: 40px;
    text-align: center;
    border: none;
    cursor: pointer;
    z-index: 10;
}

#solution {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

.solution-slot {
    width: 40px;
    height: 40px;
    margin: 0 5px;
    border-radius: 50%;
    background-color: #eee;
}

#ball-selection {
    display: flex;
    justify-content: center;
    margin-top: 20px;
}

.ball {
    width: 40px;
    height: 40px;
    margin: 0 5px;
    border-radius: 50%;
    cursor: pointer;
}

.ball[data-color="red"] {
    background-color: red;
}

.ball[data-color="blue"] {
    background-color: blue;
}

.ball[data-color="green"] {
    background-color: green;
}

.ball[data-color="yellow"] {
    background-color: yellow;
}

.ball[data-color="purple"] {
    background-color: purple;
}

.ball[data-color="orange"] {
    background-color: orange;
}

.ball[data-color="pink"] {
    background-color: pink;
}

.ball[data-color="cyan"] {
    background-color: cyan;
}

.ball[data-color="lime"] {
    background-color: lime;
}

.ball[data-color="brown"] {
    background-color: brown;
}

/* 凡例スタイル */
.legend {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 20px;
    padding: 12px 20px;
    background-color: #fff8e1;
    border-radius: 8px;
    font-size: 14px;
    color: #333;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.legend-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 1px solid black;
    display: inline-block;
}

.legend-dot.hit {
    background-color: red;
}

.legend-dot.blow {
    background-color: white;
}

/* ポップアップスタイル */
#popup {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: #fff;
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.3);
    text-align: center;
    z-index: 100;
    min-width: 300px;
}

#popup-icon {
    font-size: 60px;
    margin-bottom: 15px;
}

#popup-message {
    margin-bottom: 25px;
    font-size: 20px;
    font-weight: bold;
}

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

.popup-btn {
    padding: 12px 24px;
    font-size: 16px;
    cursor: pointer;
    border: none;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.popup-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.home-btn {
    background-color: #6c757d;
    color: #fff;
}

.retry-btn {
    background-color: #007bff;
    color: #fff;
}

/* ホーム画面スタイル */
#home-screen {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.home-content {
    text-align: center;
    background-color: #fff;
    padding: 40px;
    border-radius: 15px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
    max-width: 800px;
}

.home-title {
    font-size: 3rem;
    margin-bottom: 10px;
    color: #333;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
}

.home-title i {
    width: 50px;
    height: 50px;
    color: #007bff;
}

.home-description {
    font-size: 1.2rem;
    color: #666;
    margin-bottom: 40px;
}

.level-selection h2 {
    font-size: 1.5rem;
    margin-bottom: 30px;
    color: #444;
}

.level-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.level-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 30px 20px;
    cursor: pointer;
    transition: transform 0.3s, box-shadow 0.3s;
    text-align: center;
}

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

.level-card:nth-child(1) {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.level-card:nth-child(2) {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.level-card:nth-child(3) {
    background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
}

.level-card:nth-child(4) {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.level-card:nth-child(5) {
    background: linear-gradient(135deg, #ff9a56 0%, #ff6a00 100%);
}

.level-card:nth-child(6) {
    background: linear-gradient(135deg, #ffd89b 0%, #19547b 100%);
}

.level-icon {
    margin-bottom: 15px;
}

.level-icon i {
    width: 48px;
    height: 48px;
}

.level-card h3 {
    font-size: 1.5rem;
    margin: 10px 0;
}

.level-desc {
    font-size: 1rem;
    margin: 10px 0;
    opacity: 0.9;
}

.level-info {
    font-size: 0.9rem;
    opacity: 0.8;
    margin: 5px 0 0 0;
}

/* ホームに戻るボタンスタイル */
.back-home-btn {
    position: absolute;
    top: 20px;
    left: 20px;
    padding: 10px 20px;
    background-color: #6c757d;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    transition: background-color 0.3s, transform 0.2s;
}

.back-home-btn:hover {
    background-color: #5a6268;
    transform: translateY(-2px);
}

.back-home-btn i {
    width: 18px;
    height: 18px;
}

#game-container {
    position: relative;
}

#game-container h1 {
    display: flex;
    align-items: center;
    justify-content: center;
}

#current-level {
    font-size: 0.8em;
    color: #666;
}

/* 確認ポップアップスタイル */
#confirm-popup {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: #fff;
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.3);
    text-align: center;
    z-index: 101;
    min-width: 300px;
}

#confirm-message {
    margin-bottom: 25px;
    font-size: 18px;
    font-weight: bold;
    color: #333;
}

.confirm-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.confirm-btn {
    padding: 12px 30px;
    font-size: 16px;
    cursor: pointer;
    border: none;
    border-radius: 8px;
    transition: transform 0.2s, box-shadow 0.2s;
    font-weight: bold;
}

.confirm-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.yes-btn {
    background-color: #dc3545;
    color: #fff;
}

.yes-btn:hover {
    background-color: #c82333;
}

.no-btn {
    background-color: #6c757d;
    color: #fff;
}

.no-btn:hover {
    background-color: #5a6268;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .home-title {
        font-size: 2rem;
    }

    .level-cards {
        grid-template-columns: 1fr;
    }

    #game-container {
        padding: 15px;
        margin: 10px auto;
        border-radius: 8px;
    }

    #game-container h1 {
        font-size: 1.3rem;
        margin-bottom: 15px;
        flex-wrap: wrap;
    }

    .back-home-btn {
        position: static;
        margin-bottom: 15px;
        font-size: 13px;
        padding: 8px 16px;
    }

    .back-home-btn i {
        width: 16px;
        height: 16px;
    }

    #current-level {
        font-size: 0.75em;
    }

    .legend {
        flex-direction: column;
        gap: 10px;
        padding: 10px 15px;
        font-size: 12px;
    }

    .legend-item {
        justify-content: flex-start;
    }

    #attempts-container {
        gap: 8px;
        margin-bottom: 15px;
    }

    .attempt {
        gap: 3px;
    }

    #ball-selection {
        margin-top: 15px;
        flex-wrap: wrap;
        gap: 5px;
    }

    .ball {
        width: 35px;
        height: 35px;
        margin: 2px;
    }

    .slot {
        width: 35px;
        height: 35px;
        margin: 0 3px;
    }

    #popup,
    #confirm-popup {
        padding: 20px;
        min-width: 280px;
        max-width: 90%;
    }

    #popup-message,
    #confirm-message {
        font-size: 16px;
    }

    .popup-btn,
    .confirm-btn {
        padding: 10px 20px;
        font-size: 14px;
    }

    .popup-buttons,
    .confirm-buttons {
        flex-direction: column;
        gap: 8px;
    }

    .popup-btn,
    .confirm-btn {
        width: 100%;
        justify-content: center;
    }

    #solution {
        margin-bottom: 15px;
    }

    .solution-slot {
        width: 35px;
        height: 35px;
        margin: 0 3px;
    }
}

/* 小型スマホ対応 */
@media (max-width: 480px) {
    #game-container {
        padding: 10px;
        margin: 5px;
    }

    #game-container h1 {
        font-size: 1.1rem;
        margin-bottom: 10px;
    }

    .legend {
        font-size: 11px;
        padding: 8px 10px;
    }

    .ball {
        width: 30px;
        height: 30px;
    }

    .slot {
        width: 30px;
        height: 30px;
        margin: 0 2px;
    }

    .solution-slot {
        width: 30px;
        height: 30px;
        margin: 0 2px;
    }

    #attempts-container {
        gap: 6px;
    }
}
