* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --primary: #5b8def;
    --primary-dark: #4c7cd6;
    --secondary: #ff6b9d;
    --accent: #ffc759;
    --success: #4ade80;
    --danger: #ff6b6b;
    --bg-main: #f8f9fe;
    --bg-card: #ffffff;
    --text-dark: #2d3748;
    --text-light: #718096;
    --shadow-sm: 0 2px 8px rgba(91, 141, 239, 0.1);
    --shadow-md: 0 4px 16px rgba(91, 141, 239, 0.15);
    --shadow-lg: 0 8px 24px rgba(91, 141, 239, 0.2);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 10%, #f093fb 50%, #4facfe 90%, #00f2fe 100%);
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
    min-height: 100vh;
    padding: 16px;
    color: var(--text-dark);
    overflow-x: hidden;
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.container {
    max-width: 480px;
    margin: 0 auto;
    background: var(--bg-card);
    border-radius: 24px;
    padding: 24px;
    box-shadow: var(--shadow-lg);
}

header {
    text-align: center;
    margin-bottom: 24px;
}

header h1 {
    font-size: 2em;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

header h1::before {
    content: '🎯';
    font-size: 1.2em;
    animation: bounce 2s ease-in-out infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.subtitle {
    color: var(--text-light);
    font-size: 0.9em;
    font-weight: 400;
}

.controls {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 24px;
}

.control-group {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-main);
    padding: 12px 16px;
    border-radius: 12px;
}

.control-group label {
    font-weight: 600;
    color: var(--text-dark);
    font-size: 0.9em;
}

select {
    padding: 8px 12px;
    border: 2px solid var(--bg-main);
    border-radius: 8px;
    font-size: 0.9em;
    background: white;
    color: var(--text-dark);
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
    font-weight: 600;
}

select:hover,
select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(91, 141, 239, 0.1);
}

select option {
    padding: 8px;
}

.btn {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 12px;
    font-size: 1em;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    touch-action: manipulation;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    box-shadow: 0 4px 12px rgba(91, 141, 239, 0.3);
}

.btn-primary:hover {
    box-shadow: 0 6px 16px rgba(91, 141, 239, 0.4);
    transform: translateY(-2px);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: var(--bg-main);
    color: var(--text-dark);
    margin-top: 8px;
}

.btn-secondary:hover {
    background: #e9ecf5;
}

.btn-small {
    width: auto;
    padding: 10px 24px;
    font-size: 0.9em;
    margin-top: 12px;
    background: var(--danger);
    color: white;
}

.game-info {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 20px;
}

.info-card {
    background: var(--bg-main);
    padding: 12px;
    border-radius: 12px;
    text-align: center;
}

.info-label {
    display: block;
    color: var(--text-light);
    font-size: 0.75em;
    margin-bottom: 4px;
    font-weight: 600;
}

.info-value {
    display: block;
    font-size: 1.3em;
    font-weight: 800;
    color: var(--primary);
}

.grid {
    display: grid;
    gap: 8px;
    margin: 0 auto 24px;
    padding: 16px;
    background: var(--bg-main);
    border-radius: 16px;
}

.grid-cell {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border: 3px solid var(--bg-main);
    border-radius: 12px;
    font-size: 1.8em;
    font-weight: 800;
    color: var(--primary);
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    box-shadow: var(--shadow-sm);
    touch-action: manipulation;
}

.grid-cell:active {
    transform: scale(0.9);
}

.grid-cell.correct {
    background: var(--success);
    color: white;
    border-color: var(--success);
    animation: correctPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: none;
    box-shadow: 0 4px 16px rgba(74, 222, 128, 0.4);
}

.grid-cell.wrong {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
    animation: shake 0.4s ease;
    box-shadow: 0 4px 16px rgba(255, 107, 107, 0.4);
}

@keyframes correctPop {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-8px);
    }
    75% {
        transform: translateX(8px);
    }
}

.statistics {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 2px solid var(--bg-main);
}

.statistics h2 {
    color: var(--text-dark);
    margin-bottom: 16px;
    text-align: center;
    font-size: 1.3em;
    font-weight: 700;
}

.history-list {
    max-height: 300px;
    overflow-y: auto;
    background: var(--bg-main);
    border-radius: 12px;
    padding: 12px;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: white;
    border-radius: 8px;
    margin-bottom: 8px;
    box-shadow: var(--shadow-sm);
}

.history-item:last-child {
    margin-bottom: 0;
}

.history-size {
    font-weight: 700;
    color: var(--primary);
    font-size: 1em;
}

.history-time {
    font-weight: 800;
    color: var(--secondary);
    font-size: 1.1em;
}

.history-date {
    font-size: 0.75em;
    color: var(--text-light);
}

.no-data {
    text-align: center;
    color: var(--text-light);
    padding: 24px;
    font-size: 0.9em;
}

.instructions {
    margin-top: 24px;
    padding: 20px;
    background: var(--bg-main);
    border-radius: 12px;
}

.instructions h3 {
    color: var(--text-dark);
    margin-bottom: 12px;
    font-size: 1.1em;
    font-weight: 700;
}

.instructions ul {
    color: var(--text-light);
    line-height: 1.8;
    padding-left: 20px;
}

.instructions li {
    margin-bottom: 8px;
    font-size: 0.9em;
}

/* 完成动画 */
@keyframes celebration {
    0%, 100% {
        transform: scale(1);
    }
    25% {
        transform: scale(1.05);
    }
    50% {
        transform: scale(0.95);
    }
    75% {
        transform: scale(1.02);
    }
}

.completed {
    animation: celebration 0.5s ease;
}

/* 响应式设计 */
@media (max-width: 480px) {
    body {
        padding: 12px;
    }

    .container {
        padding: 20px;
    }

    header h1 {
        font-size: 1.8em;
    }

    .grid-cell {
        font-size: 1.5em;
        border-width: 2px;
    }

    .game-info {
        gap: 6px;
    }

    .info-card {
        padding: 10px 8px;
    }

    .info-value {
        font-size: 1.1em;
    }

    .info-label {
        font-size: 0.7em;
    }
}

@media (min-width: 481px) {
    .container {
        max-width: 500px;
    }
}

/* 滚动条美化 */
.history-list::-webkit-scrollbar {
    width: 4px;
}

.history-list::-webkit-scrollbar-track {
    background: transparent;
}

.history-list::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 4px;
}

.history-list::-webkit-scrollbar-thumb:hover {
    background: var(--primary-dark);
}

/* 触摸反馈优化 */
@media (hover: none) {
    .grid-cell:hover {
        transform: none;
    }
}

