:root {
    --primary-color: #4CAF50;
    --secondary-color: #2196F3;
    --highlight-color: #FF9800;
    --bg-color: #f0f8ff;
    --text-color: #333;
    --selected-bg: #fff3e0;
    --selected-border: #ff9800;
}

body {
    font-family: 'Comic Sans MS', 'Microsoft JhengHei', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    display: flex;
    justify-content: center;
    min-height: 100vh;
}

.container {
    width: 95%;
    max-width: 1200px;
    padding: 10px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

h1 {
    color: var(--secondary-color);
    margin-bottom: 10px;
    font-size: 2rem;
}

.status-bar {
    display: flex;
    gap: 30px;
    font-size: 1.5rem;
    font-weight: bold;
    color: #555;
    margin-bottom: 15px;
    background: white;
    padding: 10px 30px;
    border-radius: 50px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.status-item {
    min-width: 120px;
}

#score-display {
    color: var(--primary-color);
}

/* Combo 樣式 */
.combo-container {
    width: 100%;
    max-width: 500px;
    margin-bottom: 15px;
    text-align: center;
    transition: opacity 0.3s;
}

.combo-text {
    font-size: 2rem;
    font-weight: bold;
    color: #ff5722;
    text-shadow: 1px 1px 0px #fff;
    margin-bottom: 5px;
    animation: pop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes pop {
    0% { transform: scale(0.5); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.timer-bar-bg {
    width: 100%;
    height: 10px;
    background: #e0e0e0;
    border-radius: 5px;
    overflow: hidden;
}

.timer-bar {
    height: 100%;
    width: 100%;
    background: #ff9800;
    transition: width 0.1s linear;
}

.game-area {
    background: white;
    padding: 30px 20px;
    border-radius: 20px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    width: 100%;
    box-sizing: border-box;
    min-height: 400px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    overflow-x: auto; /* 加入橫向捲軸以防萬一 */
}

/* 算式顯示區 */
.equation-container {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: nowrap; /* 強制不換行 */
    font-size: 2.5rem; /* 稍微縮小字體以容納更多分數 */
    margin-bottom: 30px;
    gap: 10px;
    width: 100%;
    min-height: 180px;
}

.fraction {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    vertical-align: middle;
    margin: 0 5px;
}

.numerator, .denominator, .integer {
    padding: 10px 15px;
    border: 3px solid transparent;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 40px;
    text-align: center;
}

.numerator:hover, .denominator:hover, .integer:hover {
    background-color: #e3f2fd;
}

.numerator.selected, .denominator.selected, .integer.selected {
    background-color: var(--selected-bg);
    border-color: var(--selected-border);
    transform: scale(1.1);
    font-weight: bold;
    color: var(--highlight-color);
}

.fraction-line {
    width: 100%;
    height: 3px;
    background-color: #333;
    margin: 5px 0;
}

.operator {
    margin: 0 5px;
    font-weight: bold;
    color: #666;
}

/* 訊息與輸入區 */
.message-box {
    font-size: 1.2rem;
    color: #555;
    margin-bottom: 20px;
    min-height: 1.5em;
}

.input-area {
    width: 100%;
    max-width: 320px;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: #fafafa;
    padding: 15px;
    border-radius: 15px;
    border: 2px solid #ddd;
}

.hidden {
    display: none !important;
}

.display-value {
    width: 100%;
    height: 50px;
    background: white;
    border: 2px solid #ccc;
    border-radius: 8px;
    margin-bottom: 15px;
    font-size: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.numpad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    width: 100%;
    margin-bottom: 15px;
}

.num-btn {
    padding: 15px;
    font-size: 1.5rem;
    border: none;
    border-radius: 10px;
    background-color: white;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    cursor: pointer;
    transition: background 0.1s;
}

.num-btn:active {
    background-color: #ddd;
}

.action-btn {
    background-color: var(--secondary-color);
    color: white;
    font-size: 1.2rem;
}

#btn-submit {
    background-color: var(--primary-color);
}

.cancel-btn {
    background: transparent;
    border: 2px solid #999;
    padding: 8px 20px;
    border-radius: 20px;
    color: #666;
    cursor: pointer;
}

/* 結果區 */
.result-area {
    text-align: center;
}

.next-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 15px 40px;
    font-size: 1.5rem;
    border-radius: 30px;
    cursor: pointer;
    margin-top: 20px;
    box-shadow: 0 4px 10px rgba(76, 175, 80, 0.3);
}

.next-btn:hover {
    background-color: #43a047;
}

.final-score-popup {
    font-size: 2rem;
    color: var(--primary-color);
    margin: 20px 0;
}
