body {
    font-family: 'Nunito', sans-serif;
    overflow-x: hidden; /* Prevent horizontal scrollbar from confetti */
    background-color: #ffffff;
}

.header {
    text-align: center;
    margin: 20px 0;
    color: #333;
    font-weight: 700;
}

.game-controls {
    max-width: 520px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.timer {
    font-size: 24px;
    font-weight: 700;
    color: #333;
    font-family: 'Nunito', sans-serif;
    text-align: center;
}

.streak {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 24px;
    font-weight: 700;
    font-family: 'Nunito', sans-serif;
    color: #333;
}

.multiplication-grid {
    border-collapse: separate;
    border-spacing: 2px;
    margin: 20px auto;
    font-family: 'Nunito', sans-serif;
    background-color: #e0e0e0;
    padding: 2px;
    border-radius: 4px;
}

.multiplication-grid td {
    width: 50px;
    height: 50px;
    text-align: center;
    background-color: #ffffff;
    padding: 0;
    border-radius: 2px;
    font-size: 18px;
    transition: background-color 0.2s ease;
}

.multiplication-grid td:first-child,
.multiplication-grid tr:first-child td {
    background-color: #f5f5f5;
    font-weight: 600;
    color: #333;
}

.multiplication-grid input[type="number"] {
    width: 100%;
    height: 100%;
    border: none;
    text-align: center;
    background-color: #ffffff;
    font-size: 18px;
    padding: 0;
    box-sizing: border-box;
    -moz-appearance: textfield;
    font-family: 'Nunito', sans-serif;
    border-radius: 2px;
}

.multiplication-grid input[type="number"]::-webkit-outer-spin-button,
.multiplication-grid input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.multiplication-grid input[type="number"]:focus {
    outline: none;
    background-color: #e3f2fd;
}

.button-container {
    max-width: 600px;
    display: flex;
    justify-content: center;
    margin: 20px auto;
    padding: 0 20px;
}

.button-group {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin: 0 auto;
}

.back-button, .try-again-button {
    padding: 10px 20px;
    font-size: 16px;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s;
    font-family: 'Nunito', sans-serif;
    font-weight: 600;
    min-width: 150px;
    text-align: center;
}

.back-button {
    background-color: white;
    color: #666;
    border: 1px solid #ddd;
}

.back-button:hover {
    background-color: #f5f5f5;
    border-color: #ccc;
}

.try-again-button {
    background-color: #fa8231;
    color: white;
    border: none;
}

.try-again-button:hover {
    background-color: #e67422;
}

.start-button {
    background-color: #4CAF50;
}

.start-button:hover {
    background-color: #45a049;
}

.highlighted-row td {
    background-color: #f7e5da !important;
}

.highlighted-row input {
    background-color: #f7e5da !important;
}

.highlighted-col {
    background-color: #f7e5da !important;
}

.highlighted-col input {
    background-color: #f7e5da !important;
}

.highlighted-cell {
    background-color: #36b46f !important;
}

.highlighted-cell input {
    background-color: #fa8231 !important;
    color: white !important;
}

.correct-answer {
    background-color: #4CAF50 !important;
}

.correct-answer input {
    background-color: #4CAF50 !important;
    color: white !important;
}

.incorrect-answer {
    background-color: #f44336 !important;
}

.incorrect-answer input {
    background-color: #f44336 !important;
    color: white !important;
}

@keyframes fall {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }
    50% {
        opacity: 1;
    }
    75% {
        opacity: 0.7;
    }
    100% {
        transform: translateY(100vh) rotate(360deg);
        opacity: 0;
    }
}

.confetti {
    pointer-events: none;
    user-select: none;
}

.stats-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin: 10px 0;
}

.streak-count {
    min-width: 1.5em;
    text-align: right;
}

.streak-icon {
    font-size: 28px;
    transform-origin: center;
    animation: tilt-shake 1s ease-in-out infinite;
}

@keyframes tilt-shake {
    0% {
        transform: rotate(-5deg);
    }
    50% {
        transform: rotate(5deg);
    }
    100% {
        transform: rotate(-5deg);
    }
}

.game-history {
    max-width: 520px;
    margin: 20px auto;
    padding: 0 20px;
}

.game-history h2 {
    color: #333;
    font-weight: 700;
    margin: 0;
    font-size: 24px;
}

.history-selector {
    display: none;
    margin: 0;
    text-align: center;
    vertical-align: middle;
}

.history-selector.visible {
    display: inline-block;
}

.game-history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 20px;
}

.history-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.history-item {
    display: flex;
    flex-direction: column;
    background-color: #f5f5f5;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.history-item.gold {
    background-color: #fff9c4;
}

.history-item.silver {
    background-color: #f5f5f5;
}

.history-item.bronze {
    background-color: #ffe0b2;
}

.history-item-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.history-datetime {
    text-align: center;
    font-size: 14px;
    color: #666;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #ddd;
}

.history-time {
    font-weight: 600;
    color: #333;
}

.history-streak {
    display: flex;
    align-items: center;
    gap: 5px;
}

.history-medal {
    font-size: 24px;
    margin-right: 10px;
}

.game-menu {
    max-width: 400px;
    margin: 20px auto;
    padding: 20px;
    background-color: #f5f5f5;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.game-menu h2 {
    color: #333;
    margin-bottom: 20px;
    font-weight: 700;
}

.menu-button {
    padding: 12px 24px;
    font-size: 16px;
    color: white;
    background-color: #fa8231;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s;
    font-family: 'Nunito', sans-serif;
    font-weight: 600;
    margin: 10px 0;
    width: 100%;
    max-width: 300px;
}

.menu-button:hover {
    background-color: #e67422;
}

.row-selector {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #ddd;
}

.row-selector label {
    display: block;
    margin-bottom: 10px;
    color: #666;
    font-weight: 600;
}

.row-select {
    width: 100%;
    max-width: 300px;
    padding: 12px 24px;
}

.history-select {
    padding: 8px 12px;
}

.row-select, .history-select {
    font-size: 16px;
    min-width: 140px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 4px;
    font-family: 'Nunito', sans-serif;
    background-color: white;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 16px;
    cursor: pointer;
    transition: border-color 0.2s ease;
}

.row-select:hover, .history-select:hover {
    border-color: rgba(0, 0, 0, 0.2);
}

.row-select:focus, .history-select:focus {
    outline: none;
    border-color: #fa8231;
    box-shadow: 0 0 0 3px rgba(250, 130, 49, 0.1);
}

.winner-message {
    text-align: center;
    font-size: 24px;
    font-weight: bold;
    color: #333333;
    margin: 20px auto;
    padding: 20px;
    max-width: 600px;
    animation: fadeIn 0.5s ease-in;
}

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