/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Noto Sans SC', 'Arial', sans-serif;
    background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 50%, #fecfef 100%);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #333;
}

/* 通用容器 */
.container {
    background: white;
    border-radius: 25px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.15), 0 5px 15px rgba(0,0,0,0.1);
    padding: 35px;
    margin: 20px;
    max-width: 800px;
    width: 100%;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.container::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 154, 158, 0.1) 0%, transparent 70%);
    animation: float 6s ease-in-out infinite;
}

@keyframes float {
    0%, 100% {
        transform: translateY(0) rotate(0deg);
    }
    50% {
        transform: translateY(-10px) rotate(1deg);
    }
}

/* 标题样式 */
h1 {
    font-family: 'Fredoka One', cursive;
    font-size: 2.8rem;
    color: #ff6b6b;
    margin-bottom: 30px;
    text-shadow: 2px 2px 8px rgba(255, 107, 107, 0.3);
    letter-spacing: 2px;
}

h2 {
    font-family: 'Fredoka One', cursive;
    font-size: 1.8rem;
    color: #4ecdc4;
    margin-bottom: 25px;
    text-shadow: 1px 1px 4px rgba(78, 205, 196, 0.2);
}

h3 {
    font-family: 'Fredoka One', cursive;
    font-size: 1.3rem;
    color: #4ecdc4;
    margin-bottom: 15px;
}

/* 游戏说明 */
.game-description {
    margin-bottom: 25px;
    overflow: hidden;
}

.description-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: linear-gradient(135deg, #4ecdc4, #45b7aa);
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    border-radius: 15px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.description-header:hover {
    background: linear-gradient(135deg, #45b7aa, #3aa89d);
}

.description-header h3 {
    margin: 0;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    color: white !important;
    text-shadow: none !important;
}

.toggle-icon {
    font-size: 1rem;
    transition: transform 0.3s ease;
}

.description-content {
    padding: 0;
    background: white;
    border-top: none;
    max-height: 0;
    overflow: hidden;
    transition: all 0.3s ease;
    opacity: 0;
    transform: translateY(-10px);
    margin: 0;
}

.description-content.show {
    padding: 20px;
    max-height: 300px;
    opacity: 1;
    transform: translateY(0);
    transition: all 0.5s ease;
    border-top: 1px solid #e9ecef;
    margin-top: 0;
}

.description-content ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.description-content li {
    color: #555;
    margin-bottom: 8px;
    padding-left: 25px;
    position: relative;
    line-height: 1.4;
}

.description-content li::before {
    content: '✓';
    position: absolute;
    left: 0;
    color: #4ecdc4;
    font-weight: bold;
}

/* 年级选择界面 */
.grade-selection {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 15px;
    margin-bottom: 35px;
}

.grade-btn {
    background: linear-gradient(135deg, #4ecdc4, #45b7aa);
    color: white;
    border: none;
    border-radius: 20px;
    padding: 20px 15px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 8px rgba(78, 205, 196, 0.3);
    position: relative;
    overflow: hidden;
}

.grade-btn:hover {
    background: linear-gradient(135deg, #45b7aa, #3aa89d);
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 8px 16px rgba(78, 205, 196, 0.4);
}

.grade-btn.selected {
    background: linear-gradient(135deg, #ff6b6b, #ff8e53);
    box-shadow: 0 6px 12px rgba(255, 107, 107, 0.4);
    transform: scale(1.05);
}

.grade-btn.selected::after {
    content: '✓';
    position: absolute;
    top: 5px;
    right: 10px;
    font-size: 1.2rem;
    font-weight: bold;
    animation: checkmark 0.5s ease-in-out;
}

@keyframes checkmark {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.5);
        opacity: 1;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        padding: 25px;
        margin: 15px;
    }
    
    h1 {
        font-size: 2.2rem;
        margin-bottom: 20px;
    }
    
    h2 {
        font-size: 1.5rem;
        margin-bottom: 20px;
    }
    
    .grade-selection {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    
    .grade-btn {
        padding: 15px 10px;
        font-size: 0.9rem;
    }
    
    .btn {
        padding: 12px 20px;
        font-size: 1rem;
        margin: 8px;
    }
    
    .game-description {
        margin-bottom: 20px;
    }
    
    .description-header {
        padding: 12px 15px;
    }
    
    .description-header h3 {
        font-size: 1.1rem;
    }
    
    .description-content {
        padding: 15px;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 1.8rem;
    }
    
    h2 {
        font-size: 1.3rem;
    }
    
    .grade-selection {
        grid-template-columns: 1fr;
    }
    
    .btn {
        padding: 10px 15px;
        font-size: 0.9rem;
    }
}

/* 按钮样式 */
.btn {
    background: #ffd166;
    color: #333;
    border: none;
    border-radius: 25px;
    padding: 15px 30px;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    margin: 10px;
    position: relative;
    overflow: hidden;
}

.btn:hover {
    background: #ffc43d;
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 6px 12px rgba(255, 209, 102, 0.4);
}

.btn:active {
    transform: translateY(0) scale(0.98);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.btn:disabled {
    background: #e9ecef;
    color: #6c757d;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* 主按钮样式 */
.btn-primary {
    background: linear-gradient(135deg, #ff6b6b, #ff8e53);
    color: white;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #ee5a52, #f8b400);
    box-shadow: 0 6px 12px rgba(255, 107, 107, 0.4);
}

/* 开始游戏按钮动画 */
#start-game {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 8px 16px rgba(255, 209, 102, 0.4);
    }
}

/* 游戏界面 */

/* 顶部栏 - 倒计时和按钮同一行 */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 600px;
    margin-bottom: 20px;
    gap: 20px;
}

.timer-container {
  
    width: 100%;
}

.top-bar-controls {
    
    gap: 10px;
}

.top-bar-controls .btn {
    padding: 5px 10px;
    font-size: 1rem;
    margin: 10px;
    width: 100%;
}

.timer {
    font-size: 1.5rem;
    font-weight: bold;
    color: #ff6b6b;
    background: #f8f9fa;
    padding: 10px 20px;
    border-radius: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    text-align: center;
    margin-bottom: 10px;
}

.timer-bar {
    width: 100%;
    height: 10px;
    background: #e9ecef;
    border-radius: 5px;
    overflow: hidden;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
    position: relative;
}

.timer-progress {
    height: 100%;
    background: linear-gradient(270deg, #ff6b6b, #ffd166);
    border-radius: 5px;
    width: 100%;
    transition: width 1s linear;
    position: absolute;
    right: 0;
    top: 0;
}

.cards-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin: 30px 0;
    width: 100%;
}

.card {
    color: black;
    border-radius: 15px;
    padding: 0;
    font-size: 2rem;
    font-family: 'Fredoka One', cursive;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 8px 16px rgba(0,0,0,0.15), inset 0 2px 4px rgba(255,255,255,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.2);
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.2), inset 0 2px 4px rgba(255,255,255,0.4);
    opacity: 0.9;
}

.card.selected {
    background: linear-gradient(45deg, rgba(255,107,107,0.4), rgba(255,165,0,0.4), rgba(255,255,0,0.4));
    box-shadow: 0 8px 16px rgb(255 218 107 / 38%), inset 0 0 15px rgb(238 255 107 / 60%);
    border: 2px solid #fff56b;
    transform: scale(0.95);
}

.selected-words {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin: 20px 0;
    flex-wrap: wrap;
    min-height: 74px;
    border: 2px dashed #ddd;
    border-radius: 15px;
    padding: 10px;
    background: #fafafa;
    align-items: center;
    box-sizing: border-box;
}

.selected-words:empty::before {
    content: '请选择字卡';
    color: #999;
    font-size: 1rem;
}

.word-chip {
    background: #f8f9fa;
    border: 2px solid #4ecdc4;
    border-radius: 20px;
    padding: 10px 15px;
    font-size: 1.2rem;
    font-weight: bold;
    color: #333;
}



/* 动画效果 */
@keyframes arc {
    0% {
        opacity: 0;
        transform: scale(0.8);
    }
    50% {
        opacity: 1;
        transform: scale(1.1);
    }
    100% {
        opacity: 0;
        transform: scale(1);
    }
}

.arc-effect {
    position: relative;
}

.arc-effect::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle, rgba(0, 123, 255, 0.6) 0%, rgba(0, 123, 255, 0) 70%);
    border-radius: 15px;
    animation: arc 1s ease-in-out;
}

.arc-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

.arc-line {
    position: absolute;
    background: linear-gradient(90deg, rgba(0, 123, 255, 0.8), rgba(0, 191, 255, 0.8));
    height: 3px;
    transform-origin: left center;
    animation: arc-line 1s ease-in-out;
    box-shadow: 0 0 10px rgba(0, 123, 255, 0.8);
    border-radius: 50% 50% 50% 50% / 100% 100% 100% 100%;
}

@keyframes arc-line {
    0% {
        opacity: 0;
        transform: scaleX(0);
    }
    50% {
        opacity: 1;
        transform: scaleX(1);
    }
    100% {
        opacity: 0;
        transform: scaleX(1);
    }
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        padding: 20px;
    }

    h1 {
        font-size: 2rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    .grade-selection {
        grid-template-columns: repeat(3, 1fr);
    }

    .cards-container {
        grid-template-columns: repeat(4, 1fr);
    }

    .card {
        padding: 15px;
    }
}

@media (max-width: 480px) {
    .grade-selection {
        grid-template-columns: repeat(2, 1fr);
    }

    .cards-container {
        grid-template-columns: repeat(3, 1fr);
    }

    .card {
        padding: 10px;
    }

    .btn {
        padding: 10px 20px;
        font-size: 1rem;
    }
}

/* 模态窗样式 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    border-radius: 20px;
    padding: 30px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    animation: modalFadeIn 0.3s ease;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-content h3 {
    font-size: 1.5rem;
    color: #ff6b6b;
    margin-bottom: 15px;
}

.modal-content p {
    font-size: 1.1rem;
    color: #555;
    margin-bottom: 20px;
}

/* 隐藏类 */
.hidden {
    display: none !important;
}