:root {
    --red-primary: #e54d42;
    --red-light: #fadbd8;
    --blue-primary: #3498db;
    --blue-light: #d6eaf8;
    --bg-color: #f5f7fa;
    --text-dark: #333;
    --text-gray: #888;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-dark);
    padding-bottom: 40px;
}

.app-container {
    max-width: 480px;
    margin: 0 auto;
    background: #fff;
    min-height: 100vh;
    padding: 20px 15px;
    box-shadow: 0 0 20px rgba(0,0,0,0.05);
}

header {
    text-align: center;
    margin-bottom: 25px;
}

header h1 {
    font-size: 24px;
    color: var(--text-dark);
    margin-bottom: 5px;
}

.subtitle {
    font-size: 12px;
    color: var(--text-gray);
}

.section-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 10px;
    padding-left: 5px;
    border-left: 4px solid;
}

.red-section .section-title { border-color: var(--red-primary); color: var(--red-primary); }
.blue-section .section-title { border-color: var(--blue-primary); color: var(--blue-primary); }

.balls-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr); /* 手机端每行8个比较紧凑 */
    gap: 8px;
    margin-bottom: 25px;
}

.ball {
    aspect-ratio: 1;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    background: #f0f0f0;
    color: #ccc;
    transition: all 0.2s ease;
    user-select: none;
}

/* 红球状态 */
.ball.red-ball.active {
    background: var(--red-primary);
    color: #fff;
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(229, 77, 66, 0.4);
}

.ball.red-ball.flashing {
    background: #fff;
    color: var(--red-primary);
    border: 1px solid var(--red-primary);
    animation: pulse 0.1s infinite;
}

/* 蓝球状态 */
.ball.blue-ball.active {
    background: var(--blue-primary);
    color: #fff;
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(52, 152, 219, 0.4);
}

.ball.blue-ball.flashing {
    background: #fff;
    color: var(--blue-primary);
    border: 1px solid var(--blue-primary);
    animation: pulse 0.1s infinite;
}

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

.controls {
    display: flex;
    gap: 15px;
    margin-bottom: 30px;
    padding: 0 10px;
}

button {
    border: none;
    outline: none;
    border-radius: 25px;
    font-size: 16px;
    font-weight: 600;
    padding: 12px 20px;
    cursor: pointer;
    transition: opacity 0.2s;
    flex: 1;
}

button:active {
    opacity: 0.8;
}

.btn-primary {
    background: linear-gradient(135deg, #e54d42, #c0392b);
    color: white;
    box-shadow: 0 4px 10px rgba(229, 77, 66, 0.3);
}

.btn-secondary {
    background: #e0e0e0;
    color: #999;
    box-shadow: none;
}

.btn-secondary:not(:disabled) {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
    box-shadow: 0 4px 10px rgba(52, 152, 219, 0.3);
}

.btn-secondary:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.history-section {
    background: #fff;
    border-radius: 12px;
    padding: 15px;
    border: 1px solid #eee;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.section-header h2 {
    font-size: 16px;
    color: var(--text-dark);
}

.btn-text {
    background: none;
    color: var(--text-gray);
    font-size: 12px;
    padding: 5px 10px;
    box-shadow: none;
    flex: none;
}

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

.history-item {
    display: flex;
    align-items: center;
    background: #fafafa;
    padding: 10px;
    border-radius: 8px;
    border-left: 4px solid #ddd;
    animation: slideIn 0.3s ease-out;
}

.history-item.red-border { border-left-color: var(--red-primary); }
.history-item.blue-border { border-left-color: var(--blue-primary); }

.history-balls {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-left: 10px;
}

.h-ball {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: white;
    font-weight: bold;
}

.h-red { background: var(--red-primary); }
.h-blue { background: var(--blue-primary); }

footer {
    font-size: 0.65rem;
    text-align: center;
    color: #b9c2d0;
    margin-top: 20px;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* 适配超小屏幕 */
@media (max-width: 320px) {
    .balls-grid {
        grid-template-columns: repeat(7, 1fr);
        gap: 5px;
    }
    .ball { font-size: 10px; }
}