* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    margin: 0;
    color: #1a1a1a;
    padding: 1rem;
    position: relative;
    overflow-x: hidden;
}

@media (min-height: 800px) {
    body {
        align-items: center;
    }
}

.background-decoration {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: -1;
    background: radial-gradient(circle at 20% 50%, rgba(102, 126, 234, 0.1) 0%, transparent 50%),
                radial-gradient(circle at 80% 80%, rgba(118, 75, 162, 0.1) 0%, transparent 50%);
    pointer-events: none;
}

.game-container {
    background: rgba(255, 255, 255, 0.98);
    padding: 2rem;
    border-radius: 24px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15),
                0 0 1px rgba(0, 0, 0, 0.05);
    max-width: min(95vw, 1600px);
    width: 100%;
    display: flex;
    flex-direction: column;
    backdrop-filter: blur(10px);
    animation: slideUp 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
    margin: 1rem auto;
}

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

.header-section {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #f0f2f5;
    text-align: center;
}

.mode-selector {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding: 1.5rem;
    background: linear-gradient(135deg, #fef9e7 0%, #fdfce4 100%);
    border-radius: 16px;
    text-align: center;
}

.mode-selector p {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: #2d3748;
}

.mode-selector {
    flex-direction: row;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

@media (min-width: 768px) {
    .mode-selector {
        gap: 1.5rem;
    }
}

.mode-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.8rem;
    padding: 1.5rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    border: 2px solid #f0ad4e;
    background: rgba(255, 255, 255, 0.8);
    color: #2d3748;
    border-radius: 14px;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.mode-btn:hover {
    background: #f0ad4e;
    color: white;
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(240, 173, 78, 0.4);
}

.mode-btn:active {
    transform: translateY(-1px);
}

.mode-icon {
    font-size: 2rem;
}

.mode-selector-buttons {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    justify-content: center;
}

.info-panel {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    padding: clamp(0.8rem, 2vw, 1.5rem);
    border-radius: 16px;
    flex-wrap: wrap;
}

@media (min-width: 1024px) {
    .info-panel {
        flex-wrap: nowrap;
        gap: 2rem;
    }
}

.game-title {
    margin: 0;
    font-size: clamp(1.8rem, 5vw, 2.8rem);
    font-weight: 900;
    letter-spacing: -1px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.game-subtitle {
    margin: 0.5rem 0 0 0;
    font-size: clamp(0.75rem, 2vw, 0.95rem);
    color: #8899bb;
    font-weight: 500;
    letter-spacing: 1px;
}

.status-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
}

@media (min-width: 768px) {
    .status-group {
        align-items: flex-start;
    }
}

.status-display {
    font-weight: 700;
    font-size: 1.1rem;
    color: #2d3748;
    background: rgba(255, 255, 255, 0.7);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    min-height: 32px;
    display: flex;
    align-items: center;
}

.phase-display {
    font-weight: 500;
    font-size: 0.85rem;
    color: #5a6c7d;
    padding: 0 1rem;
}

.button-group {
    display: flex;
    gap: 0.8rem;
    flex-wrap: wrap;
    justify-content: center;
    min-width: auto;
}

@media (min-width: 1024px) {
    .button-group {
        justify-content: flex-end;
    }
}

.btn {
    padding: 0.7rem 1.2rem;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    border-radius: 12px;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.btn-icon {
    font-size: 1.1rem;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:disabled {
    background: linear-gradient(135deg, #d0d0d0 0%, #b0b0b0 100%);
    color: #999;
    cursor: not-allowed;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.btn-primary:not(:disabled):hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.4);
}

.btn-primary:not(:disabled):active {
    transform: translateY(-1px);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.85);
    color: #667eea;
    border: 2px solid #667eea;
}

.btn-secondary:hover {
    background: #667eea;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.3);
}

.btn-secondary:active {
    transform: translateY(0);
}

.canvas-wrapper {
    width: 100%;
    max-width: 700px;
    margin: 0 auto;
    position: relative;
    animation: fadeIn 0.8s ease-out 0.2s backwards;
    display: flex;
    justify-content: center;
}

.game-area {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    width: 100%;
}

.main-layout {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 2rem;
    width: 100%;
    align-items: start;
}

/* 超宽屏 (1920px+) */
@media (min-width: 1920px) {
    .main-layout {
        grid-template-columns: 1fr 400px;
        gap: 3rem;
    }
}

/* 平板/小笔记本 (1024px - 1440px) */
@media (max-width: 1440px) and (min-width: 1024px) {
    .main-layout {
        grid-template-columns: 1fr 300px;
        gap: 1.5rem;
    }

    .instructions-panel {
        max-height: 80vh;
    }
}

/* Edge 半屏/小屏笔记本 (900px - 1023px) */
@media (max-width: 1023px) and (min-width: 900px) {
    .main-layout {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .instructions-panel {
        max-height: 60vh;
    }

    .game-container {
        padding: 1.5rem;
    }
}

/* 平板竖屏/小屏笔记本 (768px - 899px) */
@media (max-width: 899px) {
    .main-layout {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

canvas {
    border-radius: 20px;
    background: linear-gradient(135deg, #fffef2 0%, #fffff8 100%);
    cursor: crosshair;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.12),
                inset 0 1px 2px rgba(255, 255, 255, 0.5);
    transition: all 0.3s ease;
    display: block;
    width: 100%;
    max-width: 700px;
    height: auto;
    aspect-ratio: 1;
}

@media (max-width: 768px) {
    canvas {
        max-width: 100%;
    }
}

canvas:hover {
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15),
                inset 0 1px 2px rgba(255, 255, 255, 0.5);
}

.instructions-panel {
    background: linear-gradient(135deg, #fef9e7 0%, #fdfce4 100%);
    padding: 1.5rem;
    border-radius: 16px;
    box-sizing: border-box;
    animation: fadeIn 0.8s ease-out 0.4s backwards;
    max-height: 70vh;
    overflow-y: auto;
    grid-column: 2;
}

.instructions-panel::-webkit-scrollbar {
    width: 6px;
}

.instructions-panel::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 10px;
}

.instructions-panel::-webkit-scrollbar-thumb {
    background: rgba(102, 126, 234, 0.3);
    border-radius: 10px;
}

.instructions-panel::-webkit-scrollbar-thumb:hover {
    background: rgba(102, 126, 234, 0.5);
}

.instructions-header {
    margin: 0;
    margin-bottom: 1rem;
}

.instructions-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: #2d3748;
}

.instructions-content {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.rule-item {
    background: rgba(255, 255, 255, 0.7);
    padding: 0.9rem;
    border-radius: 10px;
    text-align: left;
    transition: all 0.3s ease;
    border-left: 3px solid #f0ad4e;
}

.rule-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
    background: rgba(255, 255, 255, 0.95);
}

.rule-title {
    font-weight: 700;
    font-size: 0.85rem;
    color: #d48806;
    margin-bottom: 0.3rem;
}

.rule-desc {
    font-size: 0.75rem;
    color: #666;
    line-height: 1.4;
    margin: 0;
}

/* 手机竖屏 (max-width: 600px) */
@media (max-width: 600px) {
    .game-container {
        padding: 1rem;
        border-radius: 16px;
        margin: 0.5rem auto;
    }

    .header-section {
        margin-bottom: 1rem;
        padding-bottom: 0.8rem;
    }

    .game-title {
        font-size: 1.8rem;
    }

    .info-panel {
        flex-direction: column;
        gap: 0.8rem;
        padding: 1rem;
        align-items: stretch;
    }

    .status-group {
        align-items: center;
        width: 100%;
    }

    .status-display {
        font-size: 1rem;
    }

    .mode-selector {
        padding: 1rem;
        gap: 0.8rem;
    }

    .mode-btn {
        padding: 0.9rem 1.2rem;
        font-size: 0.85rem;
        gap: 0.6rem;
    }

    .mode-icon {
        font-size: 1.5rem;
    }

    .btn {
        padding: 0.5rem 0.8rem;
        font-size: 0.75rem;
        gap: 0.4rem;
    }

    .btn-icon {
        font-size: 0.9rem;
    }

    .instructions-panel {
        grid-column: 1;
        max-height: 50vh;
        padding: 1rem;
    }

    .rule-item {
        padding: 0.7rem;
        border-radius: 8px;
    }

    .rule-title {
        font-size: 0.8rem;
    }

    .rule-desc {
        font-size: 0.7rem;
    }

    canvas {
        max-width: 100%;
        border-radius: 16px;
    }
}

/* 平板竖屏 (601px - 768px) */
@media (min-width: 601px) and (max-width: 768px) {
    .game-container {
        padding: 1.25rem;
    }

    .main-layout {
        gap: 1rem;
    }

    .info-panel {
        gap: 1rem;
    }

    .instructions-panel {
        grid-column: 1;
        max-height: 60vh;
    }

    .btn {
        padding: 0.6rem 0.9rem;
        font-size: 0.85rem;
    }

    canvas {
        max-width: 100%;
    }
}
}
