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

:root {
    --main-color: #94b8d7;
    --light-main-color: #b6d0e5;
    --correct-color: #9dcc9d;
    --highlight-color: #f5d993;
    --dark-gray: #555;
    --light-gray: #f8f9fa;
    --cell-size: 3.2rem;
    --border-radius: 8px;
    --font-size-hint: 0.9rem;
}

body {
    font-family: 'Noto Sans KR', sans-serif, Arial;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background-color: var(--light-gray);
    color: var(--dark-gray);
    overflow-x: hidden;
    max-width: 100vw;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 1.2rem;
    background-color: var(--main-color);
    color: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

header h1 {
    font-size: 1.3rem;
    font-weight: bold;
    margin: 0;
}

#new-game-btn {
    padding: 6px 14px;
    font-size: 0.85rem;
    font-weight: bold;
    background-color: white;
    color: var(--main-color);
    border: none;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

#new-game-btn:hover {
    background-color: #f0f0f0;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

#game-container {
    display: flex;
    flex-direction: row;
    flex: 1;
    padding: 0.8rem;
    max-width: 100%;
    margin: 0 auto;
    align-items: flex-start;
    gap: 1.2rem;
    overflow-x: hidden;
    justify-content: flex-start;
}

#grid-area {
    flex: 0 0 auto;
    display: flex;
    justify-content: flex-start;
    align-items: flex-start;
    padding: 0.5rem;
    max-width: 90%;
    margin-left: 1rem;
}

#hints-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0.8rem;
    margin-top: 0;
    border-radius: var(--border-radius);
    background-color: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    height: 80vh;
    overflow: hidden;
    max-width: 30%;
}

.hints-column {
    flex: 1;
    padding: 0 12px 15px 12px;
    min-height: 0;
    overflow-y: auto;
    max-height: 48%;
    border-bottom: 1px solid #eaeaea;
}

.hints-column:last-child {
    border-bottom: none;
    border-top: 1px solid #eaeaea;
}

.hints-column h2 {
    display: flex;
    align-items: center;
    font-size: 1rem;
    padding-bottom: 0.5rem;
    margin-bottom: 0.8rem;
    border-bottom: 2px solid var(--main-color);
    position: sticky;
    top: 0;
    background-color: white;
    z-index: 5;
    padding-top: 0.5rem;
}

.hint-direction-indicator {
    margin-left: 8px;
    font-size: 0.9rem;
    opacity: 0.5;
}

.hint-direction-indicator.active {
    opacity: 1;
    color: var(--main-color);
}

.hint-list {
    list-style: none;
    padding: 0;
    overflow-y: auto;
    height: 100%;
}

.hint-item {
    padding: 8px 12px;
    margin-bottom: 8px;
    border-radius: var(--border-radius);
    background-color: #f3f7fb;
    cursor: pointer;
    transition: all 0.25s ease;
    position: relative;
    border-left: 3px solid transparent;
    font-size: var(--font-size-hint);
    line-height: 1.4;
}

.hint-item:hover {
    background-color: #e8f0f8;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

.hint-item.active {
    background-color: #e6f2ff;
    font-weight: bold;
    border-left: 3px solid var(--main-color);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

.hint-number {
    display: inline-block;
    min-width: 20px;
    height: 20px;
    line-height: 20px;
    text-align: center;
    background-color: var(--main-color);
    color: white;
    font-weight: bold;
    border-radius: 50%;
    margin-right: 6px;
    font-size: 0.75rem;
}

#grid {
    display: grid;
    grid-gap: 2px;
    padding: 6px;
    background-color: var(--dark-gray);
    border-radius: 6px;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
    max-width: 100%;
    margin: 0 auto;
}

.grid-cell {
    width: var(--cell-size);
    height: var(--cell-size);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.4rem;
    font-weight: bold;
    background-color: white;
    border: 1px solid #e0e0e0;
    border-radius: 3px;
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
}

.grid-cell:hover:not(.black) {
    transform: scale(1.02);
    border-color: var(--light-main-color);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
    z-index: 1;
}

.grid-cell.black {
    background-color: var(--dark-gray);
    border: none;
    cursor: default;
}

.grid-cell.selected {
    border: 2px solid var(--main-color);
    box-shadow: 0 0 6px rgba(148, 184, 215, 0.6);
    z-index: 3;
    transform: scale(1.03);
}

.grid-cell.highlight-word {
    background-color: #f0f7ff;
    border-color: #b0d0ff;
    z-index: 2;
}

.grid-cell.correct-word-part {
    background-color: var(--correct-color);
    border-color: var(--correct-color);
    color: white;
    z-index: 1;
}

.cell-number {
    position: absolute;
    top: 1px;
    left: 1px;
    font-size: 0.65rem;
    color: var(--dark-gray);
    width: 12px;
    height: 12px;
    line-height: 12px;
    text-align: center;
    font-weight: bold;
}

.cell-content {
    font-size: 1.5rem;
    font-weight: bold;
}

footer {
    padding: 1.5rem;
    text-align: center;
    background-color: var(--main-color);
    color: white;
}

#completion-effects {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
}

#completion-toast {
    position: fixed;
    bottom: 20%;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(157, 204, 157, 0.9);
    color: white;
    padding: 12px 24px;
    border-radius: 30px;
    font-size: 1.2rem;
    font-weight: bold;
    animation: fadeInOut 3s forwards;
    z-index: 101;
}

#fireworks-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100;
}

.firework {
    position: absolute;
    border-radius: 50%;
    filter: blur(1px);
    box-shadow: 0 0 10px 2px rgba(255, 255, 255, 0.8);
}

@keyframes fadeInOut {
    0% { opacity: 0; transform: translate(-50%, 20px); }
    20% { opacity: 1; transform: translate(-50%, 0); }
    80% { opacity: 1; transform: translate(-50%, 0); }
    100% { opacity: 0; transform: translate(-50%, -20px); }
}

@keyframes explode {
    0% { transform: scale(0); opacity: 1; }
    50% { transform: scale(20); opacity: 0.8; }
    100% { transform: scale(40); opacity: 0; }
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    #game-container {
        flex-direction: column;
        align-items: center;
        padding: 0.5rem;
    }
    
    #grid-area {
        max-width: 100%;
        margin-left: 0;
        justify-content: center;
        margin-bottom: 1rem;
    }
    
    #hints-area {
        height: auto;
        max-height: 50vh;
        width: 100%;
        margin-top: 0.5rem;
        flex-direction: column;
        max-width: 100%;
    }
    
    .hints-column {
        padding: 0 8px 12px 8px;
        max-height: none;
        flex: 0 0 auto;
        height: 50%;
    }
    
    :root {
        --cell-size: 2.8rem;
    }
    
    header {
        flex-direction: row;
        padding: 8px;
        justify-content: space-between;
    }
    
    header h1 {
        margin-bottom: 0;
        font-size: 1.1rem;
    }

    .hint-list {
        max-height: none;
    }

    .grid-cell {
        font-size: 1.3rem;
    }

    .cell-content {
        font-size: 1.3rem;
    }
}

@media (max-width: 480px) {
    :root {
        --cell-size: 2rem;
        --font-size-hint: 0.75rem;
    }

    #game-container {
        padding: 0.3rem;
        gap: 0.5rem;
    }

    #grid-area {
        padding: 0.3rem;
    }

    #hints-area {
        padding: 0.5rem;
    }

    #grid {
        padding: 4px;
        grid-gap: 2px;
    }

    .grid-cell {
        font-size: 1rem;
    }

    .cell-content {
        font-size: 1rem;
    }
    
    .hint-item {
        padding: 6px 8px;
        font-size: var(--font-size-hint);
        margin-bottom: 6px;
    }
    
    #new-game-btn {
        padding: 4px 10px;
        font-size: 0.75rem;
    }

    .hints-column h2 {
        font-size: 0.9rem;
    }
}
