:root {
    --primary: #ff6b6b;      /* Ceria Merah/Pink */
    --primary-dark: #ee5253;
    --secondary: #54a0ff;    /* Biru Langit */
    --success: #1dd1a1;      /* Hijau Segar */
    --success-dark: #10ac84;
    --warning: #feca57;      /* Kuning Cerah */
    --danger: #ff9f43;       /* Oranye */
    --text-main: #222f3e;
    --bg-color: #c8d6e5;
    --card-bg: #ffffff;
}

* {
    box-sizing: border-box;
    /* Font yang ramah anak, memprioritaskan font bulat */
    font-family: 'Nunito', 'Quicksand', 'Comic Sans MS', 'Chalkboard SE', 'Fredoka One', sans-serif;
}

body {
    margin: 0;
    padding: 0;
    background-color: #74b9ff; /* Bright blue */
    background-image: radial-gradient(rgba(255,255,255,0.3) 15%, transparent 16%), radial-gradient(rgba(255,255,255,0.3) 15%, transparent 16%);
    background-size: 40px 40px;
    background-position: 0 0, 20px 20px;
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
}

.screen {
    padding: 3vh 2vw;
    max-width: 98%;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

#game-screen {
    height: 100vh;
    overflow: hidden;
}

.hidden {
    display: none !important;
}

/* Typography */
h1 {
    color: var(--primary);
    font-size: clamp(32px, 5vw, 48px);
    margin: 0 0 15px 0;
    font-weight: 900;
    text-shadow: 3px 3px 0 var(--warning); /* Yellow shadow */
    letter-spacing: 2px;
    text-align: center;
}

h2 {
    font-size: clamp(24px, 3vw, 36px);
    margin: 0;
    color: var(--primary);
    font-weight: 900;
}

.subtitle {
    color: var(--text-main);
    font-size: 18px;
    margin-bottom: 25px;
    text-align: center;
    font-weight: 700;
    background: rgba(255,255,255,0.7);
    padding: 10px 20px;
    border-radius: 20px;
    display: inline-block;
}

/* Cards & Containers */
.container {
    background: var(--card-bg);
    padding: clamp(20px, 3vw, 40px);
    border-radius: 30px;
    border: 5px solid #fff;
    box-shadow: 0 15px 35px rgba(0,0,0,0.1), inset 0 0 0 4px var(--warning);
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

/* Forms & Tables */
.table-responsive {
    overflow-x: auto;
    width: 100%;
    margin-bottom: 25px;
    border-radius: 16px;
    border: 3px solid var(--secondary);
    background: #f8f9fa;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
}

th, td {
    padding: 15px;
    text-align: left;
    border-bottom: 2px dashed #dcdde1;
}

th {
    background-color: var(--secondary);
    font-weight: 800;
    color: white;
    text-transform: uppercase;
    font-size: 15px;
    letter-spacing: 1px;
}

td:first-child, th:first-child {
    width: 60px;
    text-align: center;
    font-weight: 900;
    color: var(--primary);
    font-size: 18px;
}

input[type="text"] {
    width: 100%;
    padding: 12px 20px;
    border: 3px solid #dfe6e9;
    border-radius: 25px;
    font-size: 16px;
    font-weight: 700;
    transition: all 0.2s;
    background-color: #fff;
}

input[type="text"]:focus {
    outline: none;
    border-color: var(--warning);
    box-shadow: 0 0 0 4px rgba(254, 202, 87, 0.3);
    transform: scale(1.02);
}

/* Playful Buttons */
.btn {
    padding: 14px 28px;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    font-size: 18px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 1px;
    background-color: var(--secondary);
    color: white;
    box-shadow: 0 6px 0 #2e86de, 0 10px 20px rgba(0,0,0,0.1);
    transition: all 0.1s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 5px;
}

.btn:active { 
    transform: translateY(6px); 
    box-shadow: 0 0 0 transparent, 0 2px 5px rgba(0,0,0,0.1); 
}
.btn:disabled { 
    opacity: 0.5; 
    cursor: not-allowed; 
    transform: translateY(6px);
    box-shadow: 0 0 0 transparent;
}

.btn.primary { background-color: var(--primary); box-shadow: 0 6px 0 var(--primary-dark), 0 10px 20px rgba(0,0,0,0.1); }
.btn.success { background-color: var(--success); box-shadow: 0 6px 0 var(--success-dark), 0 10px 20px rgba(0,0,0,0.1); }
.btn.danger { background-color: var(--danger); box-shadow: 0 6px 0 #e15f41; padding: 10px 15px; font-size: 14px;}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-top: 20px;
    justify-content: center;
}

.error {
    color: #fff;
    margin-top: 15px;
    font-weight: 800;
    background: var(--primary);
    padding: 15px;
    border-radius: 15px;
    text-align: center;
    border: 3px solid var(--primary-dark);
    display: empty ? none : block;
}
.error:empty { display: none; }

/* Game Screen */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    background: var(--card-bg);
    padding: 10px 30px;
    border-radius: 30px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.08), inset 0 0 0 4px var(--secondary);
    flex-wrap: wrap;
    gap: 15px;
    flex-shrink: 0;
}

.header-actions {
    display: flex;
    gap: 10px;
}

.game-container {
    display: flex;
    gap: 20px;
    align-items: stretch;
    flex: 1;
    height: calc(100vh - 200px);
    min-height: 0;
}

.board-wrapper {
    flex: 2.5;
    background: var(--card-bg);
    padding: 20px;
    border-radius: 30px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.1), inset 0 0 0 5px var(--warning);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: auto;
    height: 100%;
}

#crossword-board {
    position: relative;
    /* dimensions set via JS */
}

/* Playful Cells */
.cell {
    position: absolute;
    background: white;
    border: 3px solid #2f3640;
    border-radius: 10px; /* Rounded boxes */
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 3px 3px 0 #2f3640; /* Chunky 3D border */
    overflow: hidden;
}

.cell input {
    width: 100%;
    height: 100%;
    border: none;
    text-align: center;
    font-weight: 900;
    text-transform: uppercase;
    background: transparent;
    padding: 0;
    margin: 0;
    outline: none;
    color: #2f3640;
}

.cell input:focus {
    background: #fff9c4; /* Soft yellow highlight */
}

/* Correct Animation */
@keyframes bounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

.cell input.correct {
    background-color: var(--success) !important;
    color: white;
    animation: bounce 0.4s ease;
}

.cell input.wrong {
    background-color: var(--primary) !important;
    color: white;
}

.cell input[readonly] {
    cursor: default;
}

.cell .number {
    position: absolute;
    top: 3px;
    left: 4px;
    line-height: 1;
    font-weight: 900;
    color: var(--secondary);
    pointer-events: none;
    text-shadow: 1px 1px 0 #fff;
}

/* Clues Sidebar */
.clues-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-width: 350px;
    height: 100%;
    overflow-y: auto;
    padding-right: 15px; /* for scrollbar */
}

/* Playful Scrollbar for Clues */
.clues-container::-webkit-scrollbar {
    width: 14px;
}
.clues-container::-webkit-scrollbar-track {
    background: transparent;
}
.clues-container::-webkit-scrollbar-thumb {
    background: var(--warning);
    border-radius: 10px;
    border: 4px solid #74b9ff;
}

.clues-col {
    background: var(--card-bg);
    padding: 25px;
    border-radius: 30px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.1), inset 0 0 0 4px var(--primary);
    flex-shrink: 0;
}

.clues-col:last-child {
    inset: 0 0 0 4px var(--success);
    border: 4px solid var(--success);
}
.clues-col:first-child {
    border: 4px solid var(--primary);
}

.clues-col h3 {
    margin-top: 0;
    margin-bottom: 20px;
    color: var(--text-main);
    font-size: 24px;
    font-weight: 900;
    text-align: center;
    background: #f1f2f6;
    padding: 10px;
    border-radius: 20px;
}

.clues-col ul {
    list-style-type: none;
    padding: 0;
    margin: 0;
}

.clues-col li {
    margin-bottom: 15px;
    line-height: 1.5;
    font-size: 16px;
    font-weight: 700;
    display: flex;
    align-items: flex-start;
    padding: 12px 15px;
    background: #f8f9fa;
    border-radius: 15px;
    border: 2px solid #dfe6e9;
    transition: all 0.2s;
    cursor: default;
}

.clues-col li:hover {
    background: #fff;
    border-color: var(--warning);
    transform: scale(1.02);
}

.clues-col li strong {
    min-width: 35px;
    color: white;
    background: var(--primary);
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    margin-right: 12px;
    font-weight: 900;
    font-size: 14px;
    box-shadow: 0 3px 0 var(--primary-dark);
}
.clues-col:last-child li strong {
    background: var(--success);
    box-shadow: 0 3px 0 var(--success-dark);
}

/* Check actions floating bottom */
.check-actions {
    margin-top: 15px;
    justify-content: center;
    background: rgba(255,255,255,0.9);
    padding: 15px;
    border-radius: 50px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15), inset 0 0 0 3px var(--secondary);
    flex-shrink: 0;
}

/* Import Modal */
#import-modal .container {
    border: 5px solid var(--secondary);
    box-shadow: 0 20px 50px rgba(0,0,0,0.3);
}

#import-data {
    border: 3px solid #dfe6e9;
    border-radius: 15px;
    padding: 15px;
    font-size: 16px;
    font-weight: 700;
}

/* Responsive Breakpoints */
@media (max-width: 992px) {
    .game-container { flex-direction: column; }
    .clues-container { width: 100%; flex-direction: row; flex-wrap: wrap; }
    .clues-col { flex: 1; min-width: 300px; }
}

@media (max-width: 600px) {
    .screen { padding: 15px 10px; }
    .header { flex-direction: column; align-items: stretch; text-align: center; }
    .header-actions { width: 100%; justify-content: center; margin-top: 15px; flex-wrap: wrap; }
    .btn { padding: 12px 20px; font-size: 14px; width: 100%; }
    .clues-container { flex-direction: column; }
    .clues-col { min-width: 100%; }
}

/* Print Styles - Tetap bersih untuk dicetak */
@media print {
    body { background: white; }
    .screen { max-width: 100%; padding: 0; }
    #setup-screen, .header button, .check-actions { display: none !important; }
    .header { box-shadow: none; padding: 0; margin-bottom: 20px; border: none; }
    .game-container { flex-direction: column; }
    .board-wrapper, .clues-col { box-shadow: none; padding: 0; border: none; }
    #crossword-board { margin: 0 auto 30px auto; }
    .clues-container { flex-direction: row; gap: 40px; }
    .clues-col { background: transparent; }
    .clues-col li { background: transparent; border: none; padding: 5px 0; }
    .clues-col li strong { box-shadow: none; }
    .cell input { display: none; }
    .cell { border: 2px solid #000; box-shadow: none; border-radius: 0; }
}
