* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Comic Sans MS', 'Microsoft YaHei', Arial, sans-serif;
    background: linear-gradient(180deg, #87CEEB 0%, #98FB98 50%, #FFB6C1 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
  
    padding: 10px;
    position: relative;
    overflow-x: hidden;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(255, 255, 255, 0.3) 0%, transparent 20%),
        radial-gradient(circle at 90% 80%, rgba(255, 255, 255, 0.3) 0%, transparent 20%),
        radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.2) 0%, transparent 30%);
    pointer-events: none;
    z-index: 0;
}

.container {
    width: 100%;
    max-width: 1200px;
    padding: 5px;
    position: relative;
    z-index: 1;
}

header {
    text-align: center;
    margin-bottom: 40px;
    padding: 20px;
    background: linear-gradient(135deg, #FF6B6B 0%, #FF8E53 100%);
    border-radius: 20px;
    box-shadow: 0 8px 20px rgba(255, 107, 107, 0.3);
}

header.hidden {
    display: none;
}

header h1 {
    font-size: 2.8rem;
    color: white;
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.2);
    margin-bottom: 10px;
    font-weight: bold;
    letter-spacing: 2px;
}

.subtitle {
    font-size: 1.4rem;
    color: rgba(255, 255, 255, 0.95);
    font-weight: 500;
}

.header-actions {
    text-align: center;
    margin: 15px 0 25px;
}

.header-actions.hidden {
    display: none;
}

.help-link {
    display: inline-block;
    padding: 10px 20px;
    font-size: 1.1rem;
    color: #4CAF50;
    text-decoration: none;
    font-weight: bold;
    transition: all 0.3s ease;
    border-bottom: 2px solid #4CAF50;
}

.help-link:hover {
    color: #45a049;
    border-bottom-color: #45a049;
    transform: translateY(-2px);
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: linear-gradient(135deg, #FFF9E6 0%, #FFE4B5 100%);
    border-radius: 20px;
    box-shadow: 0 25px 70px rgba(0, 0, 0, 0.4);
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    border: 4px solid #FFD700;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    border-bottom: 2px solid #FFD700;
}

.modal-header h2 {
    font-size: 1.8rem;
    color: #FF6B6B;
    margin: 0;
    font-family: 'Comic Sans MS', 'Arial Rounded MT Bold', sans-serif;
}

.close-btn {
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: #666;
    transition: color 0.3s ease;
}

.close-btn:hover {
    color: #FF6B6B;
}

.modal-body {
    padding: 30px;
}

.modal-body h3 {
    font-size: 1.4rem;
    color: #2E7D32;
    margin-top: 0;
    margin-bottom: 15px;
    font-family: 'Comic Sans MS', 'Arial Rounded MT Bold', sans-serif;
}

.modal-body ul {
    margin-bottom: 25px;
    padding-left: 20px;
}

.modal-body li {
    margin-bottom: 8px;
    font-size: 1.1rem;
    color: #333;
    line-height: 1.4;
}

.selection-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 25px;
    padding: 50px 30px;
    background: linear-gradient(135deg, #FFF9E6 0%, #FFE4B5 100%);
    border-radius: 25px;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.1);
}

.selection-panel.hidden {
    display: none;
}

.select-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    width: 100%;
    max-width: 450px;
}

.select-group label {
    font-size: 1.5rem;
    color: #FF6B6B;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

select {
    width: 100%;
    padding: 18px 25px;
    font-size: 1.2rem;
    border: 4px solid #FFD700;
    border-radius: 20px;
    background: white;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

select:hover {
    border-color: #FF8E53;
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(255, 142, 83, 0.3);
}

select:focus {
    outline: none;
    border-color: #FF6B6B;
    box-shadow: 0 0 0 4px rgba(255, 107, 107, 0.2);
}

select:disabled {
    background: #f5f5f5;
    cursor: not-allowed;
    opacity: 0.7;
}

.btn {
    padding: 12px 30px;
    font-size: 1.2rem;
    font-weight: bold;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-transform: none;
    letter-spacing: 1px;
    font-family: inherit;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s;
}

.btn:hover::before {
    left: 100%;
}

.btn-primary {
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
    color: white;
    border: 2px solid #3d8b40;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 6px 20px rgba(76, 175, 80, 0.5);
    background: linear-gradient(135deg, #5CBF60 0%, #4CAF50 100%);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0) scale(0.98);
}

.btn-primary:disabled {
    background: #cccccc;
    border-color: #aaaaaa;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-secondary {
    background: linear-gradient(135deg, #FF6B6B 0%, #FF8E53 100%);
    color: white;
    border: 2px solid #e55a5a;
}

.btn-secondary:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 6px 20px rgba(255, 107, 107, 0.5);
    background: linear-gradient(135deg, #FF8E53 0%, #FF6B6B 100%);
}

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

.btn-hint {
    background: linear-gradient(135deg, #FFD93D 0%, #F6AD55 100%);
    color: #333;
    border: 2px solid #e6c200;
}

.btn-hint:hover:not(:disabled) {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 6px 20px rgba(255, 217, 61, 0.5);
    background: linear-gradient(135deg, #FFE066 0%, #FFD93D 100%);
}

.btn-hint:active:not(:disabled) {
    transform: translateY(0) scale(0.98);
}

.btn-hint:disabled {
    background: #cccccc;
    border-color: #aaaaaa;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.cell.hint {
    animation: hintPulse 1s ease-in-out infinite;
    box-shadow: 0 0 20px rgba(255, 217, 61, 0.8), 0 0 40px rgba(255, 217, 61, 0.6);
    border: 4px solid #FFD93D;
}

@keyframes hintPulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 20px rgba(255, 217, 61, 0.8), 0 0 40px rgba(255, 217, 61, 0.6);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 0 30px rgba(255, 217, 61, 1), 0 0 60px rgba(255, 217, 61, 0.8);
    }
}

.game-panel {
    display: none;
}

.game-panel.hidden {
    display: none;
}

.game-panel:not(.hidden) {
    display: block;
}

.game-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    margin-bottom: 10px;
    padding: 20px;
    background: linear-gradient(135deg, #E8F5E9 0%, #C8E6C9 100%);
    border-radius: 20px;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.1);
}

.info-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    flex-wrap: nowrap;
    overflow-x: auto;
    min-width: fit-content;
    color: #2E7D32;
    font-weight: bold;
}

.button-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    flex-wrap: nowrap;
    margin-bottom: 10px;
}

.info-label {
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

.info-value {
    font-size: 1.8rem;
    font-weight: bold;
    color: #FF6B6B;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
    margin-right: 15px;
}

.game-board {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
   
    background: linear-gradient(135deg, #FFF9E6 0%, #FFE4B5 100%);
    border-radius: 25px;
    overflow: hidden;
    box-shadow: inset 0 4px 15px rgba(0, 0, 0, 0.1);
    border: 3px solid #FFD700;
    
}

#line-canvas {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
    z-index: 10;
}

.grid-container {
    display: flex;
    flex-wrap: nowrap;
    flex-direction: column;
    gap: 0;
    padding: 5px;
    position: relative;
    z-index: 1;
    justify-content: center;
    align-items: center;
}

.grid-row {
    display: flex;
    flex-wrap: nowrap;
    gap: 0;
}

.cell {
    width: 100px;
    height: 100px;
    border-radius: 18px;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1.2rem;
    font-weight: bold;
    color: #333;
    text-shadow: 2px 2px 4px rgba(255, 255, 255, 0.9);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.2);
    padding: 12px;
    word-wrap: break-word;
    word-break: break-word;
    line-height: 1.3;
    margin: 0;
    background-repeat: no-repeat;
    background-size: cover;
    background-position: center center;
}

.cell.selected {
    transform: scale(1.12) translateY(-5px);
    z-index: 5;
}

.cell.empty {
    visibility: hidden;
    pointer-events: none;
}

.cell.matched {
    animation: matchDisappear 0.6s ease forwards;
}

.cell.wrong {
    animation: shake 0.6s ease;
}

@keyframes matchDisappear {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.3) rotate(10deg);
        opacity: 0.7;
    }
    100% {
        transform: scale(0) rotate(20deg);
        opacity: 0;
    }
}

@keyframes shake {
    0%, 100% {
        transform: translateX(0) scale(1);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-8px) scale(1);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(8px) scale(1);
    }
}

.message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(135deg, #FFF9E6 0%, #FFE4B5 100%);
    padding: 50px 90px;
    border-radius: 30px;
    box-shadow: 0 25px 70px rgba(0, 0, 0, 0.4);
    text-align: center;
    z-index: 1000;
    animation: fadeIn 0.4s ease;
    border: 4px solid #FFD700;
    min-width: 400px;
}

.message.hidden {
    display: none;
}

.message h2 {
    font-size: 2.8rem;
    color: #FF6B6B;
    margin-bottom: 25px;
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.1);
    font-weight: bold;
    font-family: 'Comic Sans MS', 'Arial Rounded MT Bold', sans-serif;
    animation: bounce 1s ease-in-out infinite alternate;
    white-space: nowrap;
}

.message p {
    font-size: 1.8rem;
    color: #4CAF50;
    margin-bottom: 35px;
    font-weight: bold;
    font-family: 'Comic Sans MS', 'Arial Rounded MT Bold', sans-serif;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

@keyframes bounce {
    from {
        transform: translateY(0);
    }
    to {
        transform: translateY(-10px);
    }
}

.message .btn {
    margin-top: 10px;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.7);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

@media (max-width: 768px) {
   
    header {
        padding: 15px;
        border-radius: 15px;
    }

    header h1 {
        font-size: 2rem;
    }

    .subtitle {
        font-size: 1.1rem;
    }

    .selection-panel {
        padding: 30px 20px;
        border-radius: 18px;
    }

    .select-group label {
        font-size: 1.2rem;
    }

    select {
        padding: 14px 18px;
        font-size: 1.1rem;
    }

    .btn {
        padding: 14px 35px;
        font-size: 1.2rem;
    }

    .game-info {
        gap: 12px;
        padding: 12px;
        border-radius: 15px;
    }

    .info-row {
        gap: 20px;
    }

    .button-row {
        gap: 12px;
    }

    .info-value {
        font-size: 1.2rem;
        margin-right: 10px;
    }

    .btn {
        padding: 10px 20px;
        font-size: 1rem;
    }

    .game-board {
     
        border-radius: 18px;
    }

    .cell {
        width: 75px;
        height: 75px;
        font-size: 1rem;
        padding: 8px;
        border-radius: 12px;
    }

    .message {
        padding: 35px 60px;
        border-radius: 20px;
        min-width: 300px;
    }

    .message h2 {
        font-size: 1.8rem;
        font-family: 'Comic Sans MS', 'Arial Rounded MT Bold', sans-serif;
        animation: bounce 1s ease-in-out infinite alternate;
        white-space: nowrap;
    }

    .message p {
        font-size: 1.2rem;
        color: #4CAF50;
        font-weight: bold;
        font-family: 'Comic Sans MS', 'Arial Rounded MT Bold', sans-serif;
    }
}

@media (max-width: 480px) {
    body {
        padding: 10px;
    }

    header h1 {
        font-size: 1.6rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    .selection-panel {
        padding: 20px 15px;
        border-radius: 15px;
    }

    .select-group label {
        font-size: 1.1rem;
    }

    select {
        padding: 12px 15px;
        font-size: 1rem;
    }

    .btn {
        padding: 8px 15px;
        font-size: 0.9rem;
    }

    .game-info {
        gap: 8px;
        padding: 10px;
        border-radius: 12px;
    }

    .info-row {
        gap: 15px;
    }

    .button-row {
        gap: 10px;
    }

    .info-value {
        font-size: 1rem;
        margin-right: 8px;
    }

    .btn {
        padding: 8px 15px;
        font-size: 0.9rem;
    }

    .game-board {
       
        border-radius: 15px;
    }

    .cell {
        width: 22vw;
        height: 22vw;
        min-width: 70px;
        max-width: 90px;
        font-size: 1rem;
        padding: 10px;
        border-radius: 12px;
    }

    .message {
        padding: 25px 45px;
        border-radius: 15px;
        min-width: 250px;
    }

    .message h2 {
        font-size: 1.5rem;
        font-family: 'Comic Sans MS', 'Arial Rounded MT Bold', sans-serif;
        animation: bounce 1s ease-in-out infinite alternate;
        white-space: nowrap;
    }

    .message p {
        font-size: 1.1rem;
        color: #4CAF50;
        font-weight: bold;
        font-family: 'Comic Sans MS', 'Arial Rounded MT Bold', sans-serif;
    }
}