/* 基础样式 */
:root {
    --primary-color: #2196F3;
    --primary-hover: #1976D2;
    --bg-color: #f5f5f5;
    --border-color: #ddd;
    --text-color: #333;
    --cell-size: min(40px, 5vw);
    --grid-gap: 1px;
    --disabled-color: #e0e0e0;
    --transition-speed: 0.3s;
    --background-color: #f5f5f5;
    --grid-border: #2c3e50;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 20px;
    background-color: var(--background-color);
    color: #333;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    position: relative;
    z-index: 1000;
    flex: 1;
}

/* 标题样式 */
.header {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px;
    border-bottom: 2px solid var(--border-color);
}

.header h1 {
    color: var(--primary-color);
    margin: 0 0 10px 0;
}

h2 {
    color: var(--text-color);
    margin: 0 0 20px 0;
    font-size: 1.5em;
}

/* 主内容区布局 */
.main-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    align-items: start;
}

/* 单词选择区域 */
.word-selection {
    background: white;
    padding: 20px;
    border-radius: 8px;
    max-height: 600px;
    overflow-y: auto;
}

.word-list {
    margin-bottom: 20px;
}

.word-item {
    display: flex;
    flex-direction: column;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.word-item:hover {
    background-color: rgba(33, 150, 243, 0.1);
    transform: translateY(-2px);
}

.word-item.selected {
    background-color: var(--primary-color);
    color: white;
    box-shadow: 0 2px 8px rgba(33, 150, 243, 0.3);
}

.word-item.selected .word-hint {
    color: rgba(255, 255, 255, 0.9);
}

.word-text {
    font-weight: bold;
    color: var(--primary-color);
}

.word-hint {
    color: #666;
    font-size: 0.9em;
}

/* 预览区域 */
.preview-section {
    background: white;
    padding: 20px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.preview-grid {
    width: 100%;
    max-width: 400px;
    aspect-ratio: 1;
    background: #2c3e50;
    border-radius: 4px;
    display: grid;
    gap: 1px;
    padding: 2px;
    margin: 0 auto;
}

.preview-grid .cell {
    background: white;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2em;
    font-weight: bold;
    color: #2c3e50;
}

.preview-grid .cell.empty {
    background: #2c3e50;
}

/* 按钮样式 */
.button {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1em;
    transition: background 0.3s;
    width: 100%;
}

.button:hover {
    background: #1976D2;
}

/* 游戏页面样式 */
.game-header {
    text-align: center;
    margin-bottom: 30px;
}

.game-header h1 {
    color: #2c3e50;
    font-size: 2.5em;
    margin-bottom: 20px;
}

.game-controls {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.game-controls .button {
    background-color: #3498db;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    transition: background-color 0.3s ease;
    margin: 0 5px;
}

.game-controls .button:hover {
    background-color: #2980b9;
}

.game-content {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
    animation: fadeIn 0.5s ease;
    flex-direction: row;
}

.clues-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.clues-section {
    margin-bottom: 20px;
}

.clues-section h2 {
    color: #2c3e50;
    border-bottom: 2px solid #3498db;
    padding-bottom: 5px;
    margin-bottom: 15px;
}

.clue-item {
    padding: 8px;
    margin-bottom: 8px;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.clue-item:hover {
    background-color: #f7f9fc;
}

.clue-number {
    font-weight: bold;
    color: #3498db;
    margin-right: 5px;
}

/* 网格容器样式 */
.grid-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 20px 0;
    padding: 20px;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

/* 网格样式 */
.crossword-grid {
    display: grid;
    gap: var(--grid-gap);
    background-color: var(--grid-border);
    padding: var(--grid-gap);
    border-radius: 8px;
    margin: 20px auto;
    width: fit-content;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* 单元格样式 */
.cell {
    background-color: white;
    width: var(--cell-size);
    height: var(--cell-size);
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 1px solid #e0e0e0;
}

.cell.empty {
    background-color: var(--grid-border);
    border: none;
}

/* 输入框样式 */
.cell input {
    width: 100%;
    height: 100%;
    border: none;
    text-align: center;
    font-size: calc(var(--cell-size) * 0.6);
    font-weight: bold;
    color: var(--text-color);
    background: transparent;
    cursor: pointer;
    caret-color: transparent;
}

.cell input:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: -2px;
    background-color: rgba(33, 150, 243, 0.1);
}

.cell.correct {
    color: #4CAF50;
    animation: correctPulse 0.5s ease;
}

.cell.incorrect {
    color: #f44336;
    animation: incorrectShake 0.5s ease;
}

/* 数字标记样式 */
.number {
    position: absolute;
    top: 2px;
    left: 2px;
    font-size: calc(var(--cell-size) * 0.3);
    color: #666;
    pointer-events: none;
}

/* 按钮样式 */
.button:disabled {
    background-color: #bdc3c7;
    cursor: not-allowed;
}

/* 状态消息样式 */
.game-status {
    text-align: center;
    padding: 10px;
    margin-top: 20px;
    border-radius: 5px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.game-status.error {
    background-color: #ffebee;
    color: #c62828;
    opacity: 1;
}

.game-status.success {
    background-color: #e8f5e9;
    color: #2e7d32;
    opacity: 1;
}

/* 动画关键帧 */
@keyframes slideDown {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes correctPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

@keyframes incorrectShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* 响应式设计 */
@media (max-width: 768px) {
    .main-content {
        grid-template-columns: 1fr;
    }

    .container {
        padding: 10px;
    }

    .word-selection, .preview-section {
        max-height: none;
    }

    .game-content {
        flex-direction: column;
    }

    .grid-container {
        order: 1;
        margin: 0 auto;
        width: 100%;
        max-width: 500px;
    }

    .clues-container {
        order: 2;
        flex: none;
        width: auto;
        max-height: none;
    }

    .game-controls {
        padding: 0 10px;
    }

    .cell input {
        font-size: calc(var(--cell-size) * 0.7);
    }
}

@media (max-width: 480px) {
    :root {
        --cell-size: min(40px, 8vw);
    }

    body {
        padding: 10px;
    }

    .container {
        padding: 10px;
    }

    .game-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .game-controls .button {
        width: 100%;
    }

    .cell .number {
        font-size: calc(var(--cell-size) * 0.3);
    }
}

/* 触摸设备优化 */
@media (hover: none) {
    .cell input {
        font-size: calc(var(--cell-size) * 0.8);
    }

    .button {
        padding: 12px 20px;
    }

    .clue-item {
        padding: 12px 8px;
    }
}

/* 祝贺动画样式 */
.celebration-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.5s ease;
}

.celebration-overlay.show {
    opacity: 1;
    visibility: visible;
}

.celebration-content {
    background: linear-gradient(135deg, #2196F3, #1976D2);
    padding: 40px 80px;
    border-radius: 20px;
    box-shadow: 0 0 50px rgba(33, 150, 243, 0.5);
    text-align: center;
    transform: scale(0.5) translateY(-100px);
    opacity: 0;
    transition: all 0.5s ease;
    animation: float 3s ease-in-out infinite;
}

.celebration-overlay.show .celebration-content {
    transform: scale(1) translateY(0);
    opacity: 1;
}

.celebration-title {
    font-size: 5em;
    margin-bottom: 20px;
    color: #fff;
    text-shadow: 0 0 20px rgba(255,255,255,0.8);
    animation: glow 2s ease-in-out infinite alternate;
    font-weight: bold;
    letter-spacing: 2px;
}

.celebration-message {
    font-size: 2em;
    color: #E3F2FD;
    text-shadow: 0 0 10px rgba(255,255,255,0.5);
    font-weight: 300;
}

@keyframes glow {
    from {
        text-shadow: 0 0 20px #fff,
                     0 0 30px #2196F3,
                     0 0 40px #2196F3,
                     0 0 50px #2196F3;
    }
    to {
        text-shadow: 0 0 30px #fff,
                     0 0 40px #64B5F6,
                     0 0 50px #64B5F6,
                     0 0 60px #64B5F6;
    }
}

@keyframes float {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-20px); }
    100% { transform: translateY(0px); }
}

/* 响应式调整 */
@media (max-width: 768px) {
    .celebration-content {
        padding: 30px 40px;
    }
    
    .celebration-title {
        font-size: 3em;
    }
    
    .celebration-message {
        font-size: 1.5em;
    }
}

@media (max-width: 480px) {
    .celebration-content {
        padding: 20px 30px;
    }
    
    .celebration-title {
        font-size: 2.5em;
    }
    
    .celebration-message {
        font-size: 1.2em;
    }
}

@keyframes confetti {
    0% { transform: translateY(0) rotateZ(0); opacity: 1; }
    100% { transform: translateY(1000px) rotateZ(720deg); opacity: 0; }
}

.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    background: #f00;
    opacity: 0;
}

.confetti.show {
    animation: confetti 5s ease-in-out forwards;
}

/* 生成不同颜色的彩带 */
.confetti:nth-child(2n) { background: #0f0; }
.confetti:nth-child(3n) { background: #00f; }
.confetti:nth-child(4n) { background: #ff0; }
.confetti:nth-child(5n) { background: #f0f; }

/* 为每个彩带设置不同的延迟和位置 */
.confetti:nth-child(1) { left: 10%; animation-delay: 0s; }
.confetti:nth-child(2) { left: 20%; animation-delay: 0.2s; }
.confetti:nth-child(3) { left: 30%; animation-delay: 0.4s; }
.confetti:nth-child(4) { left: 40%; animation-delay: 0.6s; }
.confetti:nth-child(5) { left: 50%; animation-delay: 0.8s; }
.confetti:nth-child(6) { left: 60%; animation-delay: 1s; }
.confetti:nth-child(7) { left: 70%; animation-delay: 1.2s; }
.confetti:nth-child(8) { left: 80%; animation-delay: 1.4s; }
.confetti:nth-child(9) { left: 90%; animation-delay: 1.6s; }
.confetti:nth-child(10) { left: 100%; animation-delay: 1.8s; }

/* 高亮样式 */
.cell.highlighted {
    background-color: #e3f2fd;
}

.cell.highlighted input {
    background-color: transparent;
}

/* 移动端输入优化 */
.cell input {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* 移动端滑动优化 */
.clues-container {
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: var(--primary-color) transparent;
}

.clues-container::-webkit-scrollbar {
    width: 6px;
}

.clues-container::-webkit-scrollbar-track {
    background: transparent;
}

.clues-container::-webkit-scrollbar-thumb {
    background-color: var(--primary-color);
    border-radius: 3px;
}

/* 活跃状态优化 */
.cell input:focus {
    background-color: rgba(33, 150, 243, 0.2);
}

.cell.highlighted input:focus {
    background-color: rgba(33, 150, 243, 0.3);
}

/* 触摸设备优化 */
@media (hover: none) {
    .cell {
        touch-action: manipulation;
    }

    .cell input {
        font-size: calc(var(--cell-size) * 0.8);
    }

    .button {
        min-height: 44px;
        padding: 12px 20px;
    }

    .clue-item {
        padding: 12px 8px;
        min-height: 44px;
    }
}

/* 小屏幕设备优化 */
@media (max-width: 480px) {
    .container {
        padding: 10px;
        margin: 0;
        border-radius: 0;
        min-height: 100vh;
        display: flex;
        flex-direction: column;
    }

    .game-content {
        flex: 1;
        margin: 0;
    }

    .grid-container {
        padding: 10px;
        margin: 0 -10px;
        border-radius: 0;
        box-shadow: none;
    }

    .clues-container {
        margin: 10px -10px 0;
        border-radius: 0;
        box-shadow: none;
        border-top: 1px solid var(--border-color);
    }

    .game-controls {
        position: sticky;
        top: 0;
        background: white;
        z-index: 100;
        padding: 10px 0;
        margin: 0;
    }

    .game-status {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        margin: 0;
        padding: 10px;
        background: rgba(255, 255, 255, 0.9);
        backdrop-filter: blur(5px);
        z-index: 100;
        text-align: center;
    }
}

/* 动画优化 */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* 深色模式支持 */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-color: #121212;
        --text-color: #ffffff;
        --border-color: #444;
        --primary-color: #64B5F6;
        --primary-hover: #42A5F5;
        --background-color: #1a1a1a;
    }

    body {
        background-color: var(--bg-color);
    }

    .container {
        background-color: #1E1E1E;
    }

    .cell {
        background-color: #2D2D2D;
    }

    .cell input {
        color: var(--text-color);
    }

    .cell.empty {
        background-color: #121212;
    }

    .cell.highlighted {
        background-color: rgba(100, 181, 246, 0.2);
    }

    .clues-container {
        background-color: #1E1E1E;
    }

    .game-controls {
        background-color: #1E1E1E;
    }

    .game-status {
        background-color: rgba(30, 30, 30, 0.9);
    }
}

/* 清除其他页面的样式影响 */
#wordwall {
    display: none !important;
}

.wordwall-wrapper {
    display: none !important;
}

/* 确保我们的容器独立显示 */
#sports-crossword {
    position: relative;
    z-index: 1000;
    background-color: var(--background-color);
    min-height: 100vh;
    width: 100%;
    display: flex;
    flex-direction: column;
}

/* 移动设备 (小于768px) */
@media screen and (max-width: 767px) {
    .container {
        padding: 10px;
    }
    
    .game-content {
        flex-direction: column;
    }
    
    .grid-container {
        width: 100%;
        margin-bottom: 20px;
    }
    
    .clues-container {
        width: 100%;
    }
}

/* 平板设备 (768px - 1024px) */
@media screen and (min-width: 768px) and (max-width: 1024px) {
    .game-content {
        gap: 20px;
    }
    
    .grid-container {
        width: 55%;
    }
    
    .clues-container {
        width: 45%;
    }
}

/* 桌面设备 (大于1024px) */
@media screen and (min-width: 1025px) {
    .container {
        max-width: 1200px;
        margin: 0 auto;
    }
} 