/* 기본 설정과 색깔 요정들의 주문들! */
:root {
    --bg-color: #f0f8ff;
    --panel-bg: #ffffff;
    --primary-color: #ff6b6b;
    --shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
    --border-radius: 20px;
}

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

/* 화면 전체 꾸미기 (벽지) */
body {
    font-family: 'Jua', sans-serif;
    background-color: var(--bg-color);
    /* 귀여운 땡땡이 점 배경 만들기 */
    background-image: radial-gradient(#dcdde1 2px, transparent 2px);
    background-size: 30px 30px;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

/* 색칠공부 앱의 가장 큰 테두리 (집) */
.app-container {
    background-color: var(--panel-bg);
    width: 95vw;
    height: 95vh;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 5px solid #fff;
    outline: 5px solid #b2bec3;
}

/* 윗부분 이름표 (지붕) */
header {
    background-color: #ffeaa7;
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 4px solid #ffeaa7;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    z-index: 10;
}

h1 {
    font-size: 2rem;
    color: #2d3436;
    text-shadow: 2px 2px 0px #fff;
    white-space: nowrap;
    margin-right: 20px;
}

.actions {
    display: flex;
    gap: 15px;
    overflow-x: auto;
    padding-bottom: 5px;
    max-width: 100%;
}

/* 스크롤바 예쁘게 만들기 */
.actions::-webkit-scrollbar {
    height: 8px;
}

.actions::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.5);
    border-radius: 10px;
}

.actions::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
}

/* 지우기, 저장하기 버튼들 (예쁘게 통통 튀게) */
.action-btn {
    font-family: 'Jua', sans-serif;
    font-size: 1.2rem;
    padding: 10px 20px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    background-color: #74b9ff;
    color: white;
    box-shadow: 0 4px 0 #0984e3;
    transition: transform 0.1s, box-shadow 0.1s;
    flex-shrink: 0;
}

/* 눌렀을 때 쏙 들어가는 마법 */
.action-btn:active {
    transform: translateY(4px);
    box-shadow: 0 0 0 #0984e3;
}

#clearBtn {
    background-color: #ff7675;
    box-shadow: 0 4px 0 #d63031;
}

#saveBtn {
    background-color: #55efc4;
    box-shadow: 0 4px 0 #00b894;
    color: #2d3436;
}

.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* 왼쪽에 있는 도구 상자 */
.sidebar {
    width: 250px;
    background-color: #fdfbfb;
    border-right: 3px dashed #dfe6e9;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.panel h2 {
    font-size: 1.5rem;
    color: #2d3436;
    margin-bottom: 15px;
    text-align: center;
    background: #fab1a0;
    border-radius: 10px;
    padding: 5px;
    color: white;
    text-shadow: 1px 1px 0px #e17055;
}

.tool-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.tool-btn {
    font-family: 'Jua', sans-serif;
    font-size: 1.3rem;
    padding: 12px;
    border: 3px solid transparent;
    border-radius: 15px;
    background-color: #f1f2f6;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    padding-left: 20px;
}

.tool-btn:hover {
    background-color: #eccc68;
    transform: scale(1.05);
    /* 커지는 마법 */
}

/* 선택되었을 때! */
.tool-btn.active {
    background-color: #ffa502;
    color: white;
    border-color: #ff7f50;
    box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.2);
}

/* 물감들 나열하기 (3칸씩) */
.color-palette {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    padding: 10px;
}

.color-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 3px solid white;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: transform 0.2s;
}

.color-btn:hover {
    transform: scale(1.2) translateY(-5px);
    /* 눌러보고 싶게 통통! */
}

.color-btn.active {
    border: 4px solid #2d3436;
    transform: scale(1.1);
}

/* 진짜 그리는 도화지 구역 */
.canvas-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: #f5f6fa;
    position: relative;
    padding: 20px;
}

.canvas-wrapper {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    background-color: #dfe4ea;
    border-radius: var(--border-radius);
    padding: 20px;
}

canvas {
    background-color: white;
    box-shadow: var(--shadow);
    border-radius: 10px;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* 밑그림 고르기 구역 */
.templates-panel {
    margin-top: 20px;
    background-color: white;
    padding: 15px;
    border-radius: 15px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.templates-panel h2 {
    font-size: 1.2rem;
    margin-bottom: 10px;
    color: #636e72;
}

.templates-list {
    display: flex;
    gap: 20px;
    overflow-x: auto;
    padding-bottom: 10px;
}

.template-thumb {
    width: 80px;
    height: 80px;
    object-fit: contain;
    background-color: #f1f2f6;
    border-radius: 10px;
    border: 3px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    color: #636e72;
    text-align: center;
    flex-shrink: 0;
}

.template-thumb:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.template-thumb.active {
    border-color: #ff6b6b;
    background-color: #ffb8b8;
}