*, *::before, *::after {
    box-sizing: border-box;
}

:root {
    --base-cell-size: 26px; 
    --cell-size: 26px;      
    --filled-color: #2c3e50;
    --x-color: #e74c3c;
    --preview-fill: rgba(44, 62, 80, 0.6);
    --preview-cross: rgba(231, 76, 60, 0.6);
    --preview-erase: rgba(255, 0, 0, 0.2);
    --hint-bg: #f8f9fa;
    --hint-done-bg: #d1d5db;
    --border-light: #e0e0e0;
    --border-heavy: #555555;
    --toolbar-height: 70px;
}

body {
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, sans-serif;
    margin: 0; padding: 0;
    background-color: #f0f2f5;
    overflow: hidden;
    display: flex; flex-direction: column; 
    height: 100vh;
    height: 100dvh;
    user-select: none; -webkit-user-select: none;
}

header {
    background: white; padding: 0 12px; height: 45px; flex-shrink: 0;
    display: flex; justify-content: space-between; align-items: center;
    border-bottom: 1px solid #ddd; z-index: 100;
}

.header-left { 
    display: flex; align-items: center; gap: 8px; 
    overflow: hidden; flex: 1; min-width: 0; margin-right: 8px;
}
.title { 
    font-weight: bold; font-size: 1rem; color: #333; 
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    flex: 1; 
}

.btn-group { display: flex; gap: 4px; flex-shrink: 0; }

.icon-btn {
    width: 32px; height: 32px; border: 1px solid #ddd; background: white;
    border-radius: 4px; font-size: 1.1rem; cursor: pointer;
    display: flex; justify-content: center; align-items: center;
    padding: 0; flex-shrink: 0; margin-left: 2px;
}
.icon-btn:disabled { opacity: 0.3; }

.chk-btn {
    background: #2c3e50; color: white; border: none; padding: 0 12px;
    height: 32px; border-radius: 4px; font-weight: bold; font-size: 0.85rem; cursor: pointer;
    white-space: nowrap; flex-shrink: 0; margin-left: 4px;
}

.game-viewport {
    flex: 1; overflow: auto; position: relative; background: #e9ecef;
    touch-action: pan-x pan-y; cursor: grab; display: flex;
    -webkit-overflow-scrolling: touch;
}
.game-viewport.locked { touch-action: none; cursor: crosshair; }

.game-board {
    display: grid; background: white; margin: auto;
    border-top: 1px solid var(--border-light);
    border-left: 1px solid var(--border-light);
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
    transform-origin: top left; 
}

.hint, .cell {
    display: flex; justify-content: center; align-items: center;
    border-right: 1px solid var(--border-light);
    border-bottom: 1px solid var(--border-light);
}

.hint { background-color: var(--hint-bg); font-size: 11px; color: #444; font-weight: 500; line-height: 1; transition: background-color 0.2s; }

.hint.col {
    position: sticky; top: 0; z-index: 10;
    flex-direction: column; justify-content: flex-end; 
    padding-bottom: 2px;
    border-bottom: 2px solid var(--border-heavy); 
}
.hint.row {
    position: sticky; left: 0; z-index: 10;
    flex-direction: row; justify-content: flex-end; align-items: center;
    padding-right: 4px;
    border-right: 2px solid var(--border-heavy);
}

.corner {
    position: sticky; top: 0; left: 0; z-index: 20;
    background: #ddd; 
    border-right: 2px solid var(--border-heavy);
    border-bottom: 2px solid var(--border-heavy);
}

.hint.completed { background-color: var(--hint-done-bg); }
.hint.completed .hint-span { color: #888; opacity: 0.7; }

.hint-span { margin: 0 1px; padding: 2px; cursor: pointer; display: inline-block;} 
.hint-span.checked { text-decoration: line-through; color: #ccc; opacity: 0.6; }

.cell { font-size: calc(var(--cell-size) * 0.6); position: relative; } 
.cell.filled { background-color: var(--filled-color); border-color: var(--border-light); }
.cell.crossed { color: var(--x-color); font-weight: 900; }
.cell.crossed::after { content: "×"; }

.thick-r { border-right: 2px solid var(--border-heavy) !important; }
.thick-b { border-bottom: 2px solid var(--border-heavy) !important; }

.cell-coord {
    position: absolute; bottom: 1px; right: 1px;
    font-size: 8px; color: #999; font-family: monospace;
    pointer-events: none; line-height: 1; z-index: 5;
    transform: scale(0.8); transform-origin: bottom right;
}
.cell.filled .cell-coord { color: rgba(255,255,255,0.4); }

.cell.preview-f { background-color: var(--preview-fill); }
.cell.preview-x { color: var(--preview-cross); }
.cell.preview-x::after { content: "×"; }
.cell.preview-erase { background-color: var(--preview-erase); }

/* [수정됨] 힌트 배경을 은은한 그레이톤으로 변경 (기존보다 채도 낮춤) */
.hint.guide-highlight {
    background-color: #edf2f7 !important;
}

/* [수정됨] 셀 가이드라인 투명도 대폭 낮춤 (0.15 -> 0.06) 및 차분한 블루톤 적용 */
.cell.guide-highlight::before {
    content: "";
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(66, 100, 160, 0.06);
    pointer-events: none;
    z-index: 1;
}

.toolbar {
    height: auto;
    min-height: var(--toolbar-height);
    background: white; border-top: 1px solid #ddd;
    display: flex; justify-content: space-around; align-items: center;
    padding-bottom: env(safe-area-inset-bottom);
    padding-top: 5px;
    flex-shrink: 0;
    z-index: 101;
}
.tool-btn {
    flex: 1; height: 60px; border: none; background: transparent;
    display: flex; flex-direction: column; justify-content: center; align-items: center;
    gap: 4px; color: #888; cursor: pointer;
    outline: none; -webkit-tap-highlight-color: transparent;
}
.tool-btn.active { color: #2c3e50; font-weight: bold; background-color: #f8f9fa; border-radius: 8px; }
.tool-icon { font-size: 1.4rem; }

#drag-tooltip {
    position: fixed; 
    background-color: rgba(33, 37, 41, 0.95); 
    color: white;
    padding: 6px 12px; 
    border-radius: 8px; 
    font-size: 0.8rem; 
    font-family: monospace;
    pointer-events: none; z-index: 1000; display: none;
    transform: translate(-50%, -130%); 
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    text-align: center;
    white-space: pre-wrap;
    line-height: 1.4;
    border: 1px solid rgba(255,255,255,0.2);
}
.tooltip-accent { color: #f1c40f; font-weight: bold; font-size: 1rem; }

.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.5); z-index: 2000;
    display: none; justify-content: center; align-items: center;
    backdrop-filter: blur(2px);
}
.modal-box {
    background: white; padding: 24px; border-radius: 12px;
    width: 80%; max-width: 320px; text-align: center;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    animation: popIn 0.3s ease-out;
}
@keyframes popIn {
    0% { transform: scale(0.8); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}
.modal-msg { margin-bottom: 20px; font-size: 1.1rem; color: #333; line-height: 1.5; font-weight: 500;}
.modal-btn {
    background: #2c3e50; color: white; border: none;
    padding: 12px 30px; border-radius: 6px; font-weight: bold;
    cursor: pointer; font-size: 1rem;
    transition: background 0.2s;
}
.modal-btn:active { background: #1a252f; }

.toast-msg {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0,0,0,0.8);
    color: white;
    padding: 10px 20px;
    border-radius: 20px;
    z-index: 2000;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
    font-size: 0.9rem;
    white-space: nowrap;
}
.toast-msg.show { opacity: 1; }

.load-list-container {
    max-height: 300px;
    overflow-y: auto;
    margin: 10px 0;
    border-top: 1px solid #eee;
    border-bottom: 1px solid #eee;
}
.load-item {
    padding: 12px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    text-align: left;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.load-item:active { background-color: #f5f5f5; }
.load-item:last-child { border-bottom: none; }
.load-info { display: flex; flex-direction: column; flex: 1; }
.load-date { font-size: 0.9rem; font-weight: bold; color: #333; }
.load-meta { font-size: 0.8rem; color: #888; margin-top: 2px; }
.btn-delete-save {
    padding: 5px 10px;
    font-size: 0.8rem;
    color: #ff4444;
    border: 1px solid #ff4444;
    background: none;
    border-radius: 4px;
    margin-left: 10px;
    cursor: pointer;
}