/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

body {
    font-family: 'Microsoft YaHei', 'Noto Sans SC', sans-serif;
    background: linear-gradient(135deg, #fce4ec 0%, #f8bbd9 50%, #f48fb1 100%);
    min-height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
    touch-action: pan-y;
    -webkit-tap-highlight-color: transparent;
    -webkit-overflow-scrolling: touch;
    position: relative;
}

/* 屏幕管理 */
.screen {
    width: 100%;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    position: absolute;
    top: 0;
    left: 0;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s ease, visibility 0.5s ease;
    overflow-y: auto;
    overflow-x: hidden;
    padding-bottom: env(safe-area-inset-bottom);
}

.screen.active {
    opacity: 1;
    visibility: visible;
}

.screen.hidden {
    opacity: 0;
    visibility: hidden;
}

/* 主菜单 */
.menu-container {
    text-align: center;
    padding: 2rem;
    padding-bottom: calc(2rem + env(safe-area-inset-bottom));
    animation: fadeInUp 0.8s ease;
    max-width: 100%;
}

.game-title {
    font-size: clamp(2rem, 5vw, 3.5rem);
    color: #e91e63;
    margin-bottom: 0.5rem;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
    animation: bounceIn 1s ease;
}

.subtitle {
    font-size: clamp(1rem, 3vw, 1.5rem);
    color: #880e4f;
    margin-bottom: 2rem;
}

.button-group {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    max-width: 600px;
    margin: 0 auto;
}

.menu-btn {
    padding: 1.5rem;
    font-size: 1.2rem;
    font-weight: bold;
    border: 4px solid #4CAF50;
    border-radius: 20px;
    background: white;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.menu-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(0,0,0,0.2);
}

.menu-btn:active {
    transform: scale(0.98);
}

.menu-btn.secondary {
    grid-column: span 2;
    border-color: #2196F3;
}

.btn-icon {
    font-size: 3rem;
}

.btn-icon i {
    font-size: inherit;
}

.btn-icon i.fas,
.btn-icon i.far {
    color: #333;
}

.btn-text {
    font-size: 1.3rem;
    color: #333;
}

.btn-desc {
    font-size: 0.9rem;
    color: #666;
}

/* 游戏界面 */
.game-container {
    width: 100%;
    max-width: 800px;
    padding: 1rem;
    padding-bottom: calc(1rem + env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: white;
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.back-btn {
    font-size: 2rem;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 10px;
    transition: all 0.3s ease;
}

.back-btn:hover {
    background: #f5f5f5;
    transform: scale(1.1);
}

.score-display {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.2rem;
    font-weight: bold;
    color: #e91e63;
}

.score-value {
    font-size: 2rem;
    color: #ff9800;
}

.question-display {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 1.1rem;
    color: #880e4f;
    font-weight: bold;
}

.question-value {
    font-size: 2rem;
    color: #e91e63;
}

/* 提示框 */
.instruction-box {
    background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%);
    padding: 1.5rem;
    padding-right: calc(1.5rem + env(safe-area-inset-right));
    padding-left: calc(1.5rem + env(safe-area-inset-left));
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    animation: pulse 2s infinite;
    flex-shrink: 0;
}

.instruction-icon {
    font-size: 3rem;
    margin-bottom: 0.5rem;
}

.instruction-text {
    font-size: clamp(1.5rem, 4vw, 2rem);
    font-weight: bold;
    color: #880e4f;
    text-shadow: 1px 1px 2px rgba(255,255,255,0.5);
}

/* 游戏区域 */
.game-board {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    padding: 1rem;
    padding-right: calc(1rem + env(safe-area-inset-right));
    padding-left: calc(1rem + env(safe-area-inset-left));
    background: rgba(255,255,255,0.3);
    border-radius: 20px;
    min-height: 300px;
    overflow-y: auto;
}

.game-item {
    background: white;
    border-radius: 20px;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    border: 4px solid transparent;
}

.game-item:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(0,0,0,0.2);
}

.game-item:active {
    transform: scale(0.98);
}

.game-item.selected {
    border-color: #4CAF50;
    background: #e8f5e9;
}

.game-item.wrong {
    border-color: #f44336;
    background: #ffebee;
    animation: shake 0.5s ease;
}

.game-item.correct {
    border-color: #4CAF50;
    background: #e8f5e9;
    animation: popIn 0.5s ease;
}

.item-icon {
    font-size: clamp(4rem, 12vw, 6rem);
    margin-bottom: 1rem;
}

.item-icon i {
    font-size: inherit;
}

.item-icon i.fas,
.item-icon i.far {
    color: #333;
}

.item-text {
    font-size: clamp(1.5rem, 4vw, 2rem);
    font-weight: bold;
    color: #333;
}

.item-color {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    margin-bottom: 1rem;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

.item-number {
    font-size: clamp(4rem, 12vw, 6rem);
    font-weight: bold;
    color: #333;
}

/* 反馈显示 */
.feedback-display {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    background: white;
    padding: 2rem 3rem;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    text-align: center;
    z-index: 1000;
    opacity: 0;
    transition: all 0.3s ease;
}

.feedback-display.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

.feedback-icon {
    font-size: 5rem;
    margin-bottom: 1rem;
}

.feedback-text {
    font-size: 2rem;
    font-weight: bold;
    color: #e91e63;
}

/* 胜利界面 */
.victory-container {
    text-align: center;
    padding: 2rem;
    animation: fadeInUp 0.8s ease;
}

.victory-icon {
    font-size: 6rem;
    margin-bottom: 1rem;
    animation: bounce 2s infinite;
}

.victory-title {
    font-size: clamp(2.5rem, 6vw, 4rem);
    color: #e91e63;
    margin-bottom: 0.5rem;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
}

.victory-subtitle {
    font-size: clamp(1.2rem, 3vw, 1.8rem);
    color: #880e4f;
    margin-bottom: 2rem;
}

.stars-container {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

.star {
    font-size: 4rem;
    opacity: 0;
    transform: scale(0);
    animation: starPop 0.6s ease forwards;
}

.star:nth-child(1) { animation-delay: 0.2s; }
.star:nth-child(2) { animation-delay: 0.4s; }
.star:nth-child(3) { animation-delay: 0.6s; }
.star:nth-child(4) { animation-delay: 0.8s; }
.star:nth-child(5) { animation-delay: 1s; }
.star:nth-child(6) { animation-delay: 1.2s; }

.victory-stats {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem 2rem;
    background: white;
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.stat-label {
    font-size: 1rem;
    color: #666;
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 2.5rem;
    font-weight: bold;
    color: #e91e63;
}

.victory-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.victory-btn {
    padding: 1rem 2rem;
    font-size: 1.2rem;
    font-weight: bold;
    border: 3px solid #e91e63;
    border-radius: 15px;
    background: white;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.victory-btn.primary {
    background: #e91e63;
    color: white;
}

.victory-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(0,0,0,0.2);
}

.victory-btn:active {
    transform: scale(0.98);
}

/* 帮助界面 */
.help-container {
    width: 100%;
    max-width: 600px;
    padding: 2rem;
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    animation: fadeInUp 0.8s ease;
    max-height: 90vh;
    overflow-y: auto;
}

.help-title {
    font-size: 2rem;
    color: #e91e63;
    text-align: center;
    margin-bottom: 2rem;
}

.help-content {
    margin-bottom: 2rem;
}

.help-section {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: #fce4ec;
    border-radius: 10px;
}

.help-section-title {
    font-size: 1.3rem;
    color: #e91e63;
    margin-bottom: 0.5rem;
}

.help-text {
    font-size: 1.1rem;
    color: #333;
    line-height: 1.8;
}

.help-btn {
    width: 100%;
    padding: 1rem;
    font-size: 1.2rem;
    font-weight: bold;
    color: white;
    background: #e91e63;
    border: none;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.help-btn:hover {
    background: #c2185b;
    transform: scale(1.02);
}

/* 动画 */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes bounceIn {
    0%, 20%, 40%, 60%, 80%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-20px);
    }
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-15px);
    }
    60% {
        transform: translateY(-7px);
    }
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

@keyframes popIn {
    from {
        opacity: 0;
        transform: scale(0.5);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes starPop {
    0% {
        opacity: 0;
        transform: scale(0) rotate(-180deg);
    }
    50% {
        opacity: 1;
        transform: scale(1.3) rotate(10deg);
    }
    100% {
        opacity: 1;
        transform: scale(1) rotate(0deg);
    }
}

@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    20% {
        transform: translateX(-10px);
    }
    40% {
        transform: translateX(10px);
    }
    60% {
        transform: translateX(-10px);
    }
    80% {
        transform: translateX(10px);
    }
}

/* 响应式设计 */
@media (max-width: 768px) {
    body {
        font-size: 14px;
    }

    .screen {
        min-height: 100vh;
    }

    .menu-container {
        padding: 1.5rem;
        padding-bottom: calc(1.5rem + env(safe-area-inset-bottom));
    }

    .game-title {
        font-size: clamp(1.8rem, 6vw, 2.5rem);
    }

    .subtitle {
        font-size: clamp(1rem, 3vw, 1.3rem);
    }

    .button-group {
        grid-template-columns: 1fr;
        gap: 0.8rem;
        max-width: 400px;
    }

    .menu-btn {
        padding: 1.2rem;
        min-height: 80px;
    }

    .menu-btn.secondary {
        grid-column: span 1;
    }

    .btn-icon {
        font-size: 3.5rem;
    }

    .btn-icon i {
        font-size: inherit;
    }

    .btn-text {
        font-size: 1.2rem;
    }

    .btn-desc {
        font-size: 0.85rem;
    }

    .menu-container {
        padding: 1.5rem;
        padding-bottom: calc(1.5rem + env(safe-area-inset-bottom));
    }

    .game-title {
        font-size: clamp(1.8rem, 6vw, 2.5rem);
    }

    .subtitle {
        font-size: clamp(1rem, 3vw, 1.3rem);
    }

    .button-group {
        grid-template-columns: 1fr;
        gap: 0.8rem;
        max-width: 400px;
    }

    .menu-btn {
        padding: 1.2rem;
        min-height: 80px;
    }

    .menu-btn.secondary {
        grid-column: span 1;
    }

    .btn-icon {
        font-size: 3.5rem;
    }

    .btn-text {
        font-size: 1.2rem;
    }

    .btn-desc {
        font-size: 0.85rem;
    }

    .game-container {
        padding: 0.8rem;
        padding-bottom: calc(0.8rem + env(safe-area-inset-bottom));
    }

    .game-header {
        padding: 0.8rem;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .back-btn {
        font-size: 2.2rem;
        padding: 0.5rem;
    }

    .score-display,
    .question-display {
        font-size: 1.1rem;
    }

    .score-value,
    .question-value {
        font-size: 1.8rem;
    }

    .instruction-box {
        padding: 1rem;
        padding-right: calc(1rem + env(safe-area-inset-right));
        padding-left: calc(1rem + env(safe-area-inset-left));
    }

    .instruction-icon {
        font-size: 3.5rem;
    }

    .instruction-text {
        font-size: clamp(1.3rem, 5vw, 1.7rem);
    }

    .game-board {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.8rem;
        padding: 0.8rem;
        padding-right: calc(0.8rem + env(safe-area-inset-right));
        padding-left: calc(0.8rem + env(safe-area-inset-left));
        min-height: 250px;
    }

    .game-item {
        padding: 1rem;
        min-height: 100px;
        min-width: 80px;
    }

    .item-icon,
    .item-number {
        font-size: clamp(3rem, 12vw, 4.5rem);
        margin-bottom: 0.8rem;
    }

    .item-icon i {
        font-size: inherit;
    }

    .item-text {
        font-size: clamp(1.1rem, 4vw, 1.5rem);
    }

    .item-color {
        width: 75px;
        height: 75px;
        margin-bottom: 0.8rem;
    }

    .feedback-display {
        padding: 1.5rem 2rem;
        max-width: 90%;
    }

    .feedback-icon {
        font-size: 3.5rem;
    }

    .feedback-text {
        font-size: 1.5rem;
    }

    .victory-container {
        padding: 1.5rem;
        padding-bottom: calc(1.5rem + env(safe-area-inset-bottom));
    }

    .victory-icon {
        font-size: 4rem;
    }

    .victory-title {
        font-size: clamp(2rem, 6vw, 2.5rem);
    }

    .victory-subtitle {
        font-size: clamp(1rem, 3vw, 1.3rem);
    }

    .stars-container {
        gap: 0.8rem;
        margin-bottom: 1.5rem;
    }

    .star {
        font-size: 2.5rem;
    }

    .victory-stats {
        gap: 1rem;
    }

    .stat-item {
        padding: 0.8rem 1.5rem;
        min-width: 80px;
    }

    .stat-label {
        font-size: 0.9rem;
    }

    .stat-value {
        font-size: 2rem;
    }

    .victory-buttons {
        flex-direction: column;
        gap: 0.8rem;
    }

    .victory-btn {
        width: 100%;
        padding: 0.8rem 1.5rem;
        font-size: 1.1rem;
    }

    .help-container {
        padding: 1.5rem;
        padding-right: calc(1.5rem + env(safe-area-inset-right));
        padding-left: calc(1.5rem + env(safe-area-inset-left));
        max-height: 80vh;
    }

    .help-title {
        font-size: 1.5rem;
    }

    .help-section {
        padding: 0.8rem;
    }

    .help-section-title {
        font-size: 1.1rem;
    }

    .help-text {
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    body {
        font-size: 13px;
    }

    .menu-container,
    .game-container,
    .victory-container {
        padding: 1rem;
        padding-bottom: calc(1rem + env(safe-area-inset-bottom));
    }

    .game-title {
        font-size: 1.6rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    .button-group {
        gap: 0.6rem;
    }

    .menu-btn {
        padding: 1rem;
        min-height: 70px;
    }

    .btn-icon {
        font-size: 3rem;
    }

    .btn-icon i {
        font-size: inherit;
    }

    .btn-text {
        font-size: 1.1rem;
    }

    .btn-desc {
        font-size: 0.75rem;
    }

    .game-header {
        padding: 0.6rem;
    }

    .score-display,
    .question-display {
        font-size: 0.9rem;
    }

    .score-value,
    .question-value {
        font-size: 1.3rem;
    }

    .instruction-box {
        padding: 0.8rem;
    }

    .instruction-icon {
        font-size: 2.8rem;
    }

    .instruction-text {
        font-size: 1.2rem;
    }

    .game-board {
        gap: 0.6rem;
        padding: 0.6rem;
        min-height: 200px;
    }

    .game-item {
        padding: 0.8rem;
        min-height: 80px;
    }

    .item-icon,
    .item-number {
        font-size: 2.8rem;
        margin-bottom: 0.6rem;
    }

    .item-icon i {
        font-size: inherit;
    }

    .item-text {
        font-size: 1.1rem;
    }

    .item-color {
        width: 65px;
        height: 65px;
        margin-bottom: 0.6rem;
    }

    .feedback-display {
        padding: 1rem 1.5rem;
        max-width: 85%;
    }

    .feedback-icon {
        font-size: 2.5rem;
    }

    .feedback-text {
        font-size: 1.2rem;
    }

    .victory-icon {
        font-size: 3rem;
    }

    .victory-title {
        font-size: 1.5rem;
    }

    .victory-subtitle {
        font-size: 1rem;
    }

    .star {
        font-size: 2rem;
    }

    .stat-item {
        padding: 0.6rem 1rem;
    }

    .stat-label {
        font-size: 0.8rem;
    }

    .stat-value {
        font-size: 1.5rem;
    }

    .victory-btn {
        padding: 0.8rem 1rem;
        font-size: 1rem;
    }

    .help-container {
        padding: 1rem;
    }

    .help-title {
        font-size: 1.3rem;
    }

    .help-section-title {
        font-size: 1rem;
    }

    .help-text {
        font-size: 0.9rem;
    }
}

/* 超小屏幕 (iPhone SE, 小屏手机) */
@media (max-width: 360px) {
    body {
        font-size: 12px;
    }

    .game-board {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    .menu-btn {
        min-height: 60px;
    }

    .game-item {
        min-height: 60px;
        padding: 0.6rem;
    }

    .item-icon,
    .item-number {
        font-size: 3rem;
    }

    .item-icon i {
        font-size: inherit;
    }
}

/* 横屏模式优化 */
@media (max-height: 500px) and (orientation: landscape) {
    .screen {
        min-height: 100vh;
    }

    .menu-container {
        padding: 1rem;
    }

    .game-container {
        padding: 0.5rem;
    }

    .game-board {
        min-height: 180px;
    }

    .instruction-box {
        padding: 0.6rem;
    }

    .instruction-icon {
        font-size: 1.5rem;
    }

    .instruction-text {
        font-size: 1rem;
    }
}
