body {
    font-family: 'Arial', 'Noto Sans JP', sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    background-color: #f0f4f8;
}

.container {
    text-align: center;
    background: #fff;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    max-width: 700px;
    width: 90%;
}

h1 {
    font-size: 28px;
    color: #222;
    margin-bottom: 15px;
}

h2 {
    font-size: 20px;
    color: #333;
    margin-bottom: 10px;
}

#digit-options button {
    font-size: 18px;
    padding: 10px 20px;
    margin: 5px;
    border: 2px solid #007bff;
    background: #fff;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

#digit-options button:hover {
    background: #e7f1ff;
    transform: scale(1.05);
}

p {
    font-size: 18px;
    margin: 10px 0;
    color: #333;
}

#table {
    display: grid;
    gap: 2px;
    margin: 20px auto;
    justify-content: center;
}

.cell {
    width: 50px;
    height: 50px;
    line-height: 50px;
    font-size: 24px;
    border: 1px solid #ccc;
    background: #fff;
    cursor: pointer;
    text-align: center;
    transition: background 0.2s, opacity 0.5s;
}

.cell.selected {
    background: #007bff;
    color: #fff;
}

.cell.hidden {
    opacity: 0;
    pointer-events: none;
    animation: fadeOut 0.5s forwards;
}

.cell:hover:not(.hidden) {
    background: #e7f1ff;
}

#next-button, #mode-button {
    font-size: 18px;
    padding: 12px 24px;
    background: #007bff;
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    margin: 10px;
    transition: background 0.2s, transform 0.1s;
}

#next-button:hover, #mode-button:hover {
    background: #0056b3;
    transform: scale(1.05);
}

#mode-button {
    background: #28a745;
}

#mode-button:hover {
    background: #1e7e34;
}

#overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    z-index: 1000;
}

#countdown, #result {
    font-size: 72px;
    font-weight: bold;
    color: #fff;
    text-shadow: 0 0 10px #000;
    animation: pulse 0.8s infinite;
}

#result.correct {
    color: #28a745;
    animation: zoom 0.5s;
}

#result.wrong {
    color: #d9534f;
}

#result.highscore {
    color: #ffd700;
    animation: zoom 0.5s;
}

#message {
    font-size: 24px;
    font-weight: bold;
    margin: 15px 0;
    min-height: 30px;
}

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

@keyframes zoom {
    0% { transform: scale(0); }
    50% { transform: scale(1.5); }
    100% { transform: scale(1); }
}

@keyframes fadeOut {
    0% { opacity: 1; }
    100% { opacity: 0; }
}

@keyframes sparkle {
    0% { opacity: 0; transform: scale(0); }
    50% { opacity: 1; transform: scale(1.5); }
    100% { opacity: 0; transform: scale(0); }
}

.sparkle {
    position: absolute;
    width: 10px;
    height: 10px;
    background: #ffd700;
    border-radius: 50%;
    pointer-events: none;
    animation: sparkle 0.5s forwards;
}

@media (max-width: 600px) {
    h1 { font-size: 24px; }
    .cell { width: 40px; height: 40px; line-height: 40px; font-size: 20px; }
    #countdown, #result { font-size: 48px; }
    #next-button, #mode-button { font-size: 16px; }
}