/* 全局樣式 */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow-y: auto;
}

.container {
    width: 90%;
    max-width: 1300px;
    min-height: min(700px, 95vh);
    display: flex;
    flex-direction: row;
    padding: 20px;
    box-sizing: border-box;
    background-color: rgba(255, 255, 255, 0.9);
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

/* 左側控制區 */
.left-panel {
    width: 300px;
    display: flex;
    flex-direction: column;
    padding-right: 20px;
    justify-content: space-between;
    height: 100%;
}

.panel-content {
    flex: 1;
}

h1 {
    color: #2c3e50;
    margin-bottom: 20px;
    text-align: left;
    font-weight: 700;
    letter-spacing: 1px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

/* 右側遊戲區 */
.game-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
}

/* 遊戲信息區域 */
#info {
    width: 100%;
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;
    background-color: #f8f9fa;
    padding: 10px 15px;
    border-radius: 10px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    box-sizing: border-box;
}

#timer {
    font-size: 24px;
    font-weight: bold;
    color: #3498db;
    display: flex;
    align-items: center;
}

#timer::before {
    content: '⏱️';
    margin-right: 5px;
}

#message {
    font-size: 22px;
    color: #2c3e50;
    text-align: center;
    min-height: 30px;
    transition: all 0.3s ease;
    font-weight: 600;
}

/* 數獨網格樣式 */
#sudoku-board {
    display: grid;
    grid-template-columns: repeat(9, 50px);
    grid-template-rows: repeat(9, 50px);
    gap: 1px;
    background-color: #34495e;
    border: 4px solid #2c3e50;
    border-radius: 8px;
    margin-bottom: 40px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
    overflow: visible;
    height: auto;
}

.cell {
    width: 50px;
    height: 50px;
    background-color: #fff;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 28px;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    position: relative;
    border: 0.5px solid rgba(52, 73, 94, 0.2);
}

.cell:hover {
    background-color: #e3f2fd;
}

.cell.selected {
    background-color: #aed5fd;
    box-shadow: inset 0 0 0 3px #0d47a1;
    z-index: 2;
}

/* 筆記模式下選中單元格的樣式 */
.note-mode-active .cell.selected {
    background-color: #e1bee7;
    box-shadow: none;
    outline: 3px dashed #8e44ad;
    outline-offset: -3px;
}

/* 新增：筆記模式下，數字選擇器區域的視覺提示 */
.note-mode-active #fixed-number-selector {
    background-color: #f3e5f5; /* 淡紫色背景 */
    border: 2px dashed #9b59b6; /* 紫色虛線邊框 */
    box-shadow: 0 0 15px rgba(155, 89, 182, 0.3);
}

/* 新增：筆記模式下，「筆記」按鈕的強調樣式 */
.note-mode-active #note-mode-btn.active {
    transform: scale(1.1); /* 稍微放大 */
    box-shadow: 0 6px 12px rgba(142, 68, 173, 0.4); /* 更明顯的陰影 */
    border: 2px solid white;
}

.cell.same-row, .cell.same-col {
    background-color: #e3f2fd;
}

.cell.same-number {
    background-color: #fff9c4;
    color: #333;
    font-weight: bold;
}

.cell.initial {
    color: #2c3e50;
    font-weight: bold;
    cursor: not-allowed;
    background-color: #f0f2f5;
}

.cell.filled {
    color: #1976d2;
}

.cell.error {
    background-color: #ffcdd2;
    color: #b71c1c;
    box-shadow: inset 0 0 0 2px #d32f2f;
}

.cell {
    border-right: 1px solid rgba(52, 73, 94, 0.2);
    border-bottom: 1px solid rgba(52, 73, 94, 0.2);
}

.cell:nth-child(3n) {
    border-right: 2px solid #34495e;
}

.cell:nth-child(n+19):nth-child(-n+27),
.cell:nth-child(n+46):nth-child(-n+54) {
    border-bottom: 2px solid #34495e;
}

.cell:nth-child(9n) {
    border-right: none;
}

.cell:nth-child(n+1):nth-child(-n+3),
.cell:nth-child(n+10):nth-child(-n+12),
.cell:nth-child(n+19):nth-child(-n+21) {
    background-color: #f5f7fa;
}

.cell:nth-child(n+4):nth-child(-n+6),
.cell:nth-child(n+13):nth-child(-n+15),
.cell:nth-child(n+22):nth-child(-n+24) {
    background-color: #fff;
}

.cell:nth-child(n+7):nth-child(-n+9),
.cell:nth-child(n+16):nth-child(-n+18),
.cell:nth-child(n+25):nth-child(-n+27) {
    background-color: #f5f7fa;
}

.cell:nth-child(n+28):nth-child(-n+30),
.cell:nth-child(n+37):nth-child(-n+39),
.cell:nth-child(n+46):nth-child(-n+48) {
    background-color: #fff;
}

.cell:nth-child(n+31):nth-child(-n+33),
.cell:nth-child(n+40):nth-child(-n+42),
.cell:nth-child(n+49):nth-child(-n+51) {
    background-color: #f5f7fa;
}

.cell:nth-child(n+34):nth-child(-n+36),
.cell:nth-child(n+43):nth-child(-n+45),
.cell:nth-child(n+52):nth-child(-n+54) {
    background-color: #fff;
}

.cell:nth-child(n+55):nth-child(-n+57),
.cell:nth-child(n+64):nth-child(-n+66),
.cell:nth-child(n+73):nth-child(-n+75) {
    background-color: #f5f7fa;
}

.cell:nth-child(n+58):nth-child(-n+60),
.cell:nth-child(n+67):nth-child(-n+69),
.cell:nth-child(n+76):nth-child(-n+78) {
    background-color: #fff;
}

.cell:nth-child(n+61):nth-child(-n+63),
.cell:nth-child(n+70):nth-child(-n+72),
.cell:nth-child(n+79):nth-child(-n+81) {
    background-color: #f5f7fa;
}

/* 控制按鈕樣式 */
#controls {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 10px;
    margin-bottom: 25px;
}

#difficulty-controls, #game-controls {
    display: flex;
    justify-content: flex-start;
    gap: 15px;
}

button {
    padding: 12px 24px;
    font-size: 16px;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 8px rgba(0, 0, 0, 0.15);
}

button:active {
    transform: translateY(1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

button::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 5px;
    height: 5px;
    background: rgba(255, 255, 255, 0.5);
    opacity: 0;
    border-radius: 100%;
    transform: scale(1, 1) translate(-50%);
    transform-origin: 50% 50%;
}

button:focus:not(:active)::after {
    animation: ripple 1s ease-out;
}

@keyframes ripple {
    0% {
        transform: scale(0, 0);
        opacity: 0.5;
    }
    100% {
        transform: scale(20, 20);
        opacity: 0;
    }
}

.difficulty-btn {
    background-color: #9b59b6;
    color: white;
    opacity: 0.7;
}

.difficulty-btn.active {
    background-color: #8e44ad;
    color: white;
    opacity: 1;
}

#start-btn {
    background-color: #3498db;
    color: white;
}

#check-btn {
    background-color: #2ecc71;
    color: white;
}

#reset-btn {
    background-color: #e74c3c;
    color: white;
}

#undo-btn, #redo-btn {
    background-color: #95a5a6;
    color: white;
}

#undo-btn:disabled, #redo-btn:disabled {
    background-color: #ecf0f1;
    color: #bdc3c7;
    cursor: not-allowed;
    transform: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* 勝利動畫 */
@keyframes victory-flash {
    0% { opacity: 1; background-color: #fff; }
    25% { background-color: #d5f5e3; }
    50% { opacity: 0.9; background-color: #2ecc71; }
    75% { background-color: #d5f5e3; }
    100% { opacity: 1; background-color: #fff; }
}

.victory {
    animation: victory-flash 1s ease-in-out 3;
}

/* 錯誤動畫 */
@keyframes error-shake {
    0% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    50% { transform: translateX(5px); }
    75% { transform: translateX(-5px); }
    100% { transform: translateX(0); }
}

.error {
    animation: error-shake 0.4s ease-in-out;
}

/* 激勵語句區域 - 新樣式 */
#motivation-container {
    position: absolute;
    top: 10px;
    right: 15px;
    width: auto;
    white-space: nowrap;
    padding: 0;
    background-color: transparent;
    border-radius: 0;
    box-shadow: none;
    border: none;
    text-align: right;
    z-index: 10;
}

#motivation-container::before,
#motivation-container::after {
    content: none;
}

#motivation-text {
    font-size: 15px;
    color: #4a5568;
    line-height: 1.4;
    font-style: italic;
    text-align: right;
    opacity: 0;
    position: relative;
    padding: 0 5px;
    text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.7);
    display: inline-block;
}

#motivation-text::before {
    content: '"';
    position: absolute;
    left: -5px;
    top: 0;
    font-size: inherit;
    color: inherit;
    opacity: 0.8;
}

#motivation-text::after {
    content: '"';
    position: absolute;
    right: -5px;
    top: 0;
    font-size: inherit;
    color: inherit;
    opacity: 0.8;
}

/* 新增：選擇器標註樣式 */
.selector-label {
    font-size: 12px;
    color: #555;
    margin-bottom: 5px;
    text-align: center;
}

/* 固定底部數字選擇器 */
#fixed-number-selector {
    background-color: rgba(255, 255, 255, 0.9);
    padding: 15px 10px;
    border-radius: 10px;
    box-shadow: 0 -4px 10px rgba(0, 0, 0, 0.1);
    width: 100%;
    box-sizing: border-box;
    position: sticky;
    bottom: 0;
}

.number-selector-row {
    display: flex;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}

.fixed-number-btn {
    flex: 1;
    margin: 0 3px;
    padding: 8px 0;
    font-size: 18px;
    border: 1px solid #ccc;
    border-radius: 6px;
    background-color: #fff;
    color: #333;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 35px;
    height: 35px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.fixed-number-btn:hover {
    background-color: #e3f2fd;
    transform: translateY(-2px);
}

.fixed-number-btn.active {
    background-color: #3498db;
    color: white;
}

#note-mode-btn, #clear-btn {
    font-size: 14px;
    padding: 8px 10px;
}

#note-mode-btn {
    background-color: #f0f2f5;
}

#note-mode-btn.active {
    background-color: #9b59b6;
    color: white;
}

#clear-btn {
    background-color: #e74c3c;
    color: white;
}

/* 筆記模式的小數字 */
.cell .notes {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    font-size: clamp(8px, 2vw, 10px);
    color: #5972a3;
    line-height: 1.1;
    box-sizing: border-box;
    padding: 1px;
    font-weight: 600;
}

.cell .notes span {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    opacity: 0.8;
}

/* 新增：筆記說明文字樣式 */
#note-instructions {
    font-size: 12px;
    color: #555;
    margin-top: 10px;
    text-align: center;
    padding: 5px;
    background-color: rgba(236, 240, 241, 0.7);
    border-radius: 5px;
}

/* 統計區域樣式 */
#stats-container {
    margin-top: 20px;
    padding: 15px;
    background-color: #f8f9fa;
    border-radius: 10px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    margin-bottom: 25px;
}

.progress-title, .stats-title {
    font-size: 16px;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 10px;
}

.progress-bar {
    height: 12px;
    background-color: #ecf0f1;
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 5px;
    flex-grow: 1;
    margin-right: 10px;
}

#progress-bar-container {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

#progress-indicator {
    height: 100%;
    background: linear-gradient(90deg, #3498db, #2ecc71);
    width: 0%;
    transition: width 0.3s ease;
}

#progress-percent {
    font-size: 14px;
    font-weight: bold;
    color: #2c3e50;
    width: 40px;
    text-align: right;
}

#numbers-distribution {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 5px;
}

.number-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 30px;
}

.number-stat-digit {
    font-size: 16px;
    font-weight: bold;
    color: #2c3e50;
    transition: color 0.2s ease;
}

.number-stat-count {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 14px;
    background-color: #ecf0f1;
    margin-top: 5px;
    transition: all 0.2s ease;
}

.number-stat-complete .number-stat-count {
    background-color: #2ecc71;
    color: white;
}

/* 已完成數字的樣式 */
.number-stat-complete .number-stat-digit {
    color: #7f8c8d;
    text-decoration: line-through;
}

/* 響應式設計 */
@media (max-width: 900px) {
    .container {
        width: 100%;
        flex-direction: column;
        height: auto;
        padding: 15px;
        border-radius: 10px;
        min-height: 700px;
    }
    
    .left-panel {
        width: 100%;
        padding-right: 0;
        margin-bottom: 20px;
        min-height: 200px;
    }
    
    .panel-content {
        margin-bottom: 15px;
    }
    
    .game-panel {
        width: 100%;
    }
    
    h1 {
        font-size: 24px;
        margin-bottom: 15px;
    }
    
    #info {
        padding: 8px 12px;
    }
    
    #timer {
        font-size: 20px;
    }
    
    #message {
        font-size: 18px;
    }
    
    #sudoku-board {
        grid-template-columns: repeat(9, 1fr);
        grid-template-rows: repeat(9, 1fr);
        gap: 1px;
        margin: 10px 0;
    }
    
    .cell {
        width: 100%;
        height: 0;
        padding-bottom: 100%;
        font-size: clamp(14px, 4.5vw, 20px);
        position: relative;
    }
    
    .cell span {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
    }
    
    #difficulty-controls, #game-controls {
        flex-wrap: wrap;
        gap: 10px;
    }
    
    button {
        padding: 10px 15px;
        font-size: 14px;
    }
    
    #motivation-container {
        margin-top: 20px;
        padding: 15px;
    }
    
    #motivation-text {
        font-size: 14px;
        padding: 5px 20px;
    }
    
    #fixed-number-selector {
        padding: 8px;
    }
    
    .fixed-number-btn {
        font-size: 16px;
        padding: 10px 8px;
        min-width: 35px;
    }
    
    #note-mode-btn, #clear-btn {
        padding: 10px 12px;
    }
    
    .progress-title, .stats-title {
        font-size: 14px;
    }
    
    #stats-container {
        padding: 10px;
        margin-top: 15px;
    }
    
    .number-stat {
        width: 25px;
    }
    
    .number-stat-digit {
        font-size: 14px;
    }
    
    .number-stat-count {
        width: 20px;
        height: 20px;
        font-size: 10px;
    }
}

/* 窄螢幕：數字選擇列改兩行 grid，避免 11 顆按鈕水平溢出，觸控目標維持 >=40px */
@media (max-width: 480px) {
    #fixed-number-selector {
        padding: 8px 6px;
    }

    .number-selector-row {
        display: grid;
        grid-template-columns: repeat(6, 1fr);
        gap: 6px;
        row-gap: 6px;
    }

    .fixed-number-btn {
        flex: none;
        width: 100%;
        margin: 0;
        min-width: 40px;
        height: 44px;
        padding: 0;
        font-size: 18px;
    }

    #note-mode-btn, #clear-btn {
        font-size: 15px;
        padding: 0;
    }
}

/* 操作動畫 */
@keyframes cell-fill {
    0% { transform: scale(0.8); opacity: 0.5; }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes cell-clear {
    0% { opacity: 1; }
    100% { opacity: 0.5; }
}

@keyframes note-toggle {
    0% { transform: scale(0.9); opacity: 0.7; }
    100% { transform: scale(1); opacity: 1; }
}

.cell-animate-fill span {
    animation: cell-fill 0.2s ease-out;
}

.cell-animate-clear > * {
    animation: cell-clear 0.2s ease-out;
}

.cell-animate-note .notes {
    animation: note-toggle 0.15s ease-out;
}

/* 按鈕焦點樣式 */
button:focus, .fixed-number-btn:focus {
    outline: 2px solid #3498db;
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(52, 152, 219, 0.3);
}

/* 移除默認 outline，使用自定義樣式 */
button:focus:not(:focus-visible) {
    outline: none;
    box-shadow: none;
}

.fixed-number-btn:focus:not(:focus-visible) {
    outline: none;
    box-shadow: none;
}

/* 格子焦點樣式 */
.cell:focus {
    outline: 2px solid #f39c12;
    outline-offset: -2px;
    z-index: 3;
}

.cell.selected:focus {
    outline-color: #f39c12;
}

.note-mode-active .cell.selected:focus {
    outline-color: #f39c12;
}

/* 最終檢查錯誤的樣式 (例如，使用不同的邊框) */
.cell.final-check-error {
    box-shadow: inset 0 0 0 3px #e57373;
    background-color: #ffebee;
}

/* 新增：中學生喜歡的按鈕樣式 */
.difficulty-btn, .control-btn, #solution-btn {
    border-radius: 15px;
    font-size: 16px;
    font-weight: bold;
    padding: 10px 15px;
    border: none;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    text-transform: uppercase;
    margin: 5px;
    letter-spacing: 1px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
}

.difficulty-btn:hover, .control-btn:hover, #solution-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 10px rgba(0, 0, 0, 0.2);
}

.difficulty-btn:active, .control-btn:active, #solution-btn:active {
    transform: translateY(1px);
    box-shadow: 0 2px 3px rgba(0, 0, 0, 0.1);
}

/* 難度按鈕樣式 */
.easy-btn {
    background: linear-gradient(45deg, #2ecc71, #27ae60);
    color: white;
}

.easy-btn.active {
    background: linear-gradient(45deg, #27ae60, #145a32);
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.2);
}

.easy-btn:before {
    content: "🌟 ";
}

.medium-btn {
    background: linear-gradient(45deg, #3498db, #2980b9);
    color: white;
}

.medium-btn.active {
    background: linear-gradient(45deg, #2980b9, #1a5276);
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.2);
}

.medium-btn:before {
    content: "🔍 ";
}

.hard-btn {
    background: linear-gradient(45deg, #e74c3c, #c0392b);
    color: white;
}

.hard-btn.active {
    background: linear-gradient(45deg, #c0392b, #922b21);
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.2);
}

.hard-btn:before {
    content: "🔥 ";
}

/* 遊戲控制按鈕樣式 */
.undo-btn {
    background: linear-gradient(45deg, #1abc9c, #16a085);
    color: white;
}

.undo-btn:before {
    content: "";
}

.redo-btn {
    background: linear-gradient(45deg, #e67e22, #d35400);
    color: white;
}

.redo-btn:before {
    content: "";
}

/* 禁用按鈕樣式 */
.undo-btn:disabled, .redo-btn:disabled {
    background: linear-gradient(45deg, #95a5a6, #7f8c8d);
    color: #ecf0f1;
    cursor: not-allowed;
    box-shadow: none;
    opacity: 0.7;
}

/* 按鈕點擊特效 */
.difficulty-btn::after, .control-btn::after, #solution-btn::after {
    content: "";
    display: block;
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    pointer-events: none;
    background-image: radial-gradient(circle, #fff 10%, transparent 10.01%);
    background-repeat: no-repeat;
    background-position: 50%;
    transform: scale(10, 10);
    opacity: 0;
    transition: transform 0.5s, opacity 1s;
}

.difficulty-btn:active::after, .control-btn:active::after, #solution-btn:active::after {
    transform: scale(0, 0);
    opacity: 0.3;
    transition: 0s;
}

/* 解答按鈕樣式 */
#solution-btn {
    background: linear-gradient(45deg, #ff4081, #d81b60);
    color: white;
    animation: none;
}

#solution-btn:before {
    content: "";
}

#solution-btn:hover {
    background: linear-gradient(45deg, #d81b60, #ad1457);
    transform: translateY(-2px);
}

/* 新增：錯誤計數器容器樣式 */
#error-counter-container {
    margin: 15px 0;
    padding: 12px 15px;
    background-color: #f8f9fa;
    border-radius: 15px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    gap: 8px;
    border: 2px dashed #e0e0e0;
}

/* 錯誤計數顯示樣式 */
#error-counter {
    font-size: 18px;
    font-weight: bold;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
}

#error-counter::before {
    content: '🎮';
    margin-right: 8px;
    font-size: 20px;
}

#error-counter.low-errors {
    color: #27ae60;
}

#error-counter.medium-errors {
    color: #f39c12;
}

#error-counter.high-errors {
    color: #e74c3c;
    animation: pulse 1.5s infinite;
}

/* 失敗次數顯示樣式 */
#failure-counter {
    font-size: 14px;
    color: #7f8c8d;
    margin-top: 5px;
}

#failure-counter::before {
    content: '📊';
    margin-right: 8px;
}

/* 新增：成功次數顯示樣式 */
#success-counter {
    font-size: 14px;
    color: #27ae60;
    margin-top: 5px;
}

#success-counter::before {
    content: '🏆';
    margin-right: 8px;
}

/* 失敗訊息樣式 */
.failure-message {
    color: #e74c3c !important;
    font-weight: bold !important;
    font-size: 24px !important;
    animation: pulse 1s infinite;
}

/* 已顯示解答的單元格樣式 */
.cell.solution-revealed {
    color: #e74c3c !important;
    font-weight: bold;
    animation: solution-appear 0.5s ease-out;
}

@keyframes solution-appear {
    0% {
        transform: scale(0.8);
        opacity: 0;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* 失敗覆蓋層樣式 */
#failure-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(231, 76, 60, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    opacity: 1;
    transition: opacity 1s ease;
}

#failure-overlay.fade-out {
    opacity: 0;
}

.failure-text {
    font-size: 80px;
    color: white;
    font-weight: bold;
    text-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
    transform: rotate(-10deg);
    animation: shake 0.5s ease-in-out;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
}

@keyframes shake {
    0%, 100% {
        transform: rotate(-10deg);
    }
    25% {
        transform: rotate(-15deg) scale(1.1);
    }
    50% {
        transform: rotate(-5deg);
    }
    75% {
        transform: rotate(-12deg) scale(1.05);
    }
}

/* 新增：勝利橫幅樣式 */
#victory-banner {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 1;
    transition: opacity 1s ease-out;
    animation: banner-fade-in 0.5s ease-out;
    cursor: pointer;
}

#victory-banner.fade-out {
    opacity: 0;
}

.victory-banner-content {
    background: linear-gradient(135deg, #f1c40f, #ff9800, #f39c12);
    padding: 40px 80px;
    border-radius: 30px;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.4);
    text-align: center;
    animation: banner-scale-in 0.7s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform-origin: center;
    border: 5px solid white;
    outline: 5px solid gold;
}

.victory-text {
    font-size: 90px;
    font-weight: bold;
    color: white;
    text-shadow: 3px 3px 8px rgba(0, 0, 0, 0.5);
    margin: 0 30px;
    display: inline-block;
    animation: text-glow 1.5s ease-in-out infinite alternate;
}

.star {
    font-size: 60px;
    vertical-align: middle;
    animation: star-spin 2s linear infinite, star-pulse 1s ease-in-out infinite alternate;
    display: inline-block;
    margin: 0 10px;
    color: #fff59d;
}

.victory-subtext {
    margin-top: 25px;
    font-size: 28px;
    color: #fff;
    text-shadow: 2px 2px 5px rgba(0, 0, 0, 0.6);
    opacity: 0;
    animation: subtext-fade-in 1s ease-out 0.5s forwards;
}

@keyframes banner-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes banner-scale-in {
    from { transform: scale(0.3) rotate(-10deg); opacity: 0; }
    to { transform: scale(1) rotate(0deg); opacity: 1; }
}

@keyframes star-spin {
    from { transform: rotate(0deg) scale(1); }
    to { transform: rotate(360deg) scale(1); }
}

@keyframes star-pulse {
    from { transform: scale(0.9); opacity: 0.8; }
    to { transform: scale(1.1); opacity: 1; }
}

@keyframes text-glow {
    from {
        text-shadow: 0 0 10px #fff, 0 0 20px #fff, 0 0 30px #ffdd57, 0 0 40px #ffdd57;
    }
    to {
        text-shadow: 0 0 20px #fff, 0 0 30px #ffdd57, 0 0 40px #ffdd57, 0 0 50px #ffdd57;
    }
}

@keyframes subtext-fade-in {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* 新增：彩帶樣式 */
#confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    z-index: 999;
}

.confetti {
    position: absolute;
    top: -30px;
    opacity: 0;
    will-change: transform, opacity;
}

@keyframes confetti-fall {
    0% {
        transform: translateY(0) rotateZ(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(110vh) rotateZ(720deg);
        opacity: 0;
    }
}

@keyframes confetti-spin {
    0% { transform: rotateY(0deg); }
    100% { transform: rotateY(360deg); }
}

/* 新增：誇張稱讚橫幅樣式 */
#praise-banner {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 1;
    transition: opacity 0.5s ease-out;
    animation: banner-fade-in 0.5s ease-out;
    cursor: pointer;
}

#praise-banner.fade-out {
    opacity: 0;
}

.praise-content {
    background: linear-gradient(135deg, #3498db, #2980b9, #1abc9c);
    padding: 40px 60px;
    border-radius: 20px;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.4);
    text-align: center;
    animation: praise-scale-in 0.7s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform-origin: center;
    border: 5px solid white;
    min-width: 350px;
    max-width: 600px;
}

.praise-header {
    margin-bottom: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.praise-icon {
    font-size: 40px;
    animation: trophy-bounce 1s ease-in-out infinite alternate;
    display: inline-block;
    margin: 0 15px;
    text-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.praise-title {
    font-size: 48px;
    font-weight: bold;
    color: white;
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.4);
    animation: praise-pulse 1.5s ease-in-out infinite alternate;
}

.praise-message {
    font-size: 24px;
    color: #fff;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    margin: 20px 0 30px;
    line-height: 1.4;
    padding: 10px;
    background-color: rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    animation: message-fade-in 0.8s ease-out;
}

.countdown-container {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.countdown-text {
    font-size: 18px;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 10px;
}

.countdown-timer {
    font-size: 60px;
    font-weight: bold;
    color: white;
    width: 100px;
    height: 100px;
    line-height: 100px;
    border-radius: 50%;
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.4);
    margin-top: 10px;
    transition: transform 0.2s ease-out;
}

.countdown-pulse {
    animation: countdown-pulse 0.5s ease-out;
}

@keyframes praise-scale-in {
    from { transform: scale(0.3) rotate(-5deg); opacity: 0; }
    to { transform: scale(1) rotate(0deg); opacity: 1; }
}

@keyframes trophy-bounce {
    0% { transform: translateY(0) rotate(0deg); }
    100% { transform: translateY(-10px) rotate(5deg); }
}

@keyframes praise-pulse {
    0% { text-shadow: 0 0 10px rgba(255, 255, 255, 0.8), 0 0 20px rgba(255, 255, 255, 0.4); }
    100% { text-shadow: 0 0 15px rgba(255, 255, 255, 1), 0 0 30px rgba(255, 255, 255, 0.6); }
}

@keyframes message-fade-in {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes countdown-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}
/* Footer */
.sudoku-footer {
    text-align: center;
    padding: 10px;
    margin-top: 10px;
}
.sudoku-footer a {
    color: #87CEEB;
    text-decoration: none;
    font-size: 14px;
    padding: 6px 16px;
    border-radius: 8px;
    background: rgba(255,255,255,0.1);
    transition: all 0.3s;
}
.sudoku-footer a:hover {
    background: rgba(255,255,255,0.2);
}
