:root {
    --bg-color: #ea9999;
    --grid-bg: #ecf0f1;
    --border-color: #bdc3c7;
    --cell-size: 45px;
}

body {
    margin: 0;
    background-color: var(--bg-color);
    font-family: 'Nunito', sans-serif;
    color: #333;
    display: flex;
    justify-content: center;
    min-height: 100vh;
}

/* View Management */
.view-section {
    display: none;
    width: 100%;
    justify-content: center;
}
.view-section.active {
    display: flex;
}

/* Puzzle List Styles */
#puzzle-list-view {
    flex-direction: column;
    align-items: center;
    max-width: 800px;
    padding: 40px 20px;
}

.main-title {
    font-family: 'Bangers', cursive;
    font-size: 80px;
    color: white;
    text-transform: uppercase;
    margin: 0 0 10px 0;
    text-shadow: 4px 4px 0 rgba(0,0,0,0.2);
    letter-spacing: 4px;
    text-align: center;
}

.list-subtitle {
    color: white;
    font-size: 24px;
    margin-bottom: 40px;
    text-align: center;
    font-weight: bold;
}

#puzzle-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    width: 100%;
}

.puzzle-card {
    background: white;
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    position: relative;
}

.puzzle-status-icon {
    width: 32px;
    height: 32px;
    margin-bottom: 10px;
    background-repeat: no-repeat;
}

.puzzle-card h3 {
    margin: 0 0 10px 0;
    font-size: 22px;
    color: #2c3e50;
}

.puzzle-info {
    font-size: 14px;
    color: #7f8c8d;
    background: #ecf0f1;
    padding: 5px 12px;
    border-radius: 15px;
    font-weight: bold;
}

.back-btn {
    position: absolute;
    top: 20px;
    left: 20px;
    background: rgba(255, 255, 255, 0.3);
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 20px;
    cursor: pointer;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: background 0.2s;
}
.back-btn:hover { background: rgba(255, 255, 255, 0.5); }

.logout-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.3);
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 20px;
    cursor: pointer;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: background 0.2s;
    z-index: 100;
}
.logout-btn:hover { background: rgba(255, 255, 255, 0.5); }

#main-layout {
    display: flex;
    flex-direction: column;
    width: 1200px;
    max-width: 100%;
    padding: 20px;
    box-sizing: border-box;
    gap: 20px;
}

.row {
    display: flex;
    flex-direction: row;
    gap: 20px;
    width: 100%;
}

.col {
    display: flex;
    flex-direction: column;
    flex: 1;
}

#header-col { justify-content: center; }

/* Adjust suspect grid for the new layout */
#suspects-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-start;
}

.suspect-container {
    width: 23%; /* Approx 4 per row in the column */
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 10px;
    min-width: 90px;
}
header { margin-bottom: 0; }
.logo { font-family: 'Bangers', cursive; font-size: 48px; color: white; text-transform: uppercase; line-height: 1; margin: 0; text-shadow: 2px 2px 0 rgba(0,0,0,0.2); letter-spacing: 2px; }
.logo-highlight { color: #2c3e50; position: relative; display: inline-block; }
.logo-highlight-accent { color: #8a2a27; position: relative; display: inline-block; }
/* .logo-highlight::after { content: ''; display: block; width: 6px; height: 6px; background: #40e0d0; border-radius: 50%; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); } */
.subtitle { font-size: 20px; font-weight: bold; color: white; margin-top: 5px; }
.difficulty { font-size: 14px; color: white; font-weight: bold; }

.polaroid { background: white; padding: 4px 4px 24px 4px; box-shadow: 0 2px 4px rgba(0,0,0,0.3); text-align: center; margin-bottom: -10px; z-index: 2; position: relative; width: 100%; box-sizing: border-box; }
.polaroid.suspect-placed { background-color: black; border-color: black; }
.polaroid.suspect-placed .polaroid-name { color: white !important; }
.polaroid-img { width: 100%; aspect-ratio: 1; background-color: #f0f0f0; display: flex; justify-content: center; align-items: center; font-size: 30px; border: 1px solid #ddd; overflow: hidden; }
.polaroid-name { font-family: 'Patrick Hand', cursive; font-size: 16px; margin-top: 3px; color: #333; position: absolute; bottom: 4px; width: 100%; left: 0; }

.suspect-sprite {
    width: 100%;
    height: 100%;
    background-image: url('../images/suspects.png');
    background-size: 500% 400%; /* 5 columns, 4 rows */
    background-repeat: no-repeat;
}

.object-sprite {
    width: 100%;
    height: 100%;
    background-image: url('../images/set-02.png');
    background-size: 1000% 400%; /* 10 columns, 4 rows */
    background-repeat: no-repeat;
    position: absolute;
    top: 0;
    left: 0;
}

/* Object Mappings */
/* Row 0 */
.obj-ARNA { background-position: 0% 0%; }
.obj-CARE { background-position: 11.111% 0%; }
.obj-CAVL { background-position: 22.222% 0%; }
.obj-CAVO { background-position: 33.333% 0%; }
.obj-CMVF { background-position: 44.444% 0%; }
.obj-CMVI { background-position: 55.555% 0%; }
.obj-ESTA { background-position: 66.666% 0%; }
.obj-LICH { background-position: 77.777% 0%; }
.obj-LIXO { background-position: 88.888% 0%; }
.obj-MCOS { background-position: 100% 0%; }

/* Row 1 */
.obj-MEHF { background-position: 0% 33.333%; }
.obj-MEHI { background-position: 11.111% 33.333%; }
.obj-MEHM { background-position: 22.222% 33.333%; }
.obj-MESA { background-position: 33.333% 33.333%; }
.obj-MEVF { background-position: 44.444% 33.333%; }
.obj-MEVI { background-position: 55.555% 33.333%; }
.obj-MEVM { background-position: 66.666% 33.333%; }
.obj-PLAN { background-position: 77.777% 33.333%; }
.obj-POLT { background-position: 88.888% 33.333%; }
.obj-PRES { background-position: 100% 33.333%; }

/* Row 2 */
.obj-TAHO { background-position: 0% 66.666%; }
.obj-TALE { background-position: 11.111% 66.666%; }
.obj-TANO { background-position: 22.222% 66.666%; }
.obj-TANS { background-position: 33.333% 66.666%; }
.obj-TAOE { background-position: 44.444% 66.666%; }
.obj-TAPE { background-position: 55.555% 66.666%; }
.obj-TASO { background-position: 66.666% 66.666%; }
.obj-TASU { background-position: 77.777% 66.666%; }
.obj-TELE { background-position: 88.888% 66.666%; }
.obj-URPE { background-position: 100% 66.666%; }

.clue-bubble { background: white; border-radius: 8px; padding: 6px 4px 4px 4px; font-size: 11px; line-height: 1.2; text-align: center; color: black; box-shadow: 0 1px 3px rgba(0,0,0,0.1); position: relative; z-index: 15; width: 100%; box-sizing: border-box; margin-top: 12px; }
.clue-bubble.victim { background-color: #e57373; color: white; font-weight: bold; }

/* Re-organized Sections */
#rules-section { display: flex; justify-content: space-between; margin-bottom: 10px; gap: 10px; width: 100%; }
.rule-box { background: #fff0f0; border-radius: 10px; padding: 10px; font-size: 11px; flex: 1; position: relative; box-shadow: 0 2px 5px rgba(0,0,0,0.1); }
.rule-number { position: absolute; top: -10px; left: -10px; width: 20px; height: 20px; background: #4caf50; color: white; border-radius: 50%; display: flex; justify-content: center; align-items: center; font-weight: bold; font-size: 12px; }

.legend-section { display: flex; gap: 10px; font-size: 10px; justify-content: center; width: 100%; box-sizing: border-box; padding-bottom: 10px; }
.legend-group { display: flex; align-items: center; gap: 15px; padding: 0px 10px; }
.legend-title { font-weight: bold; margin-right: 5px; }
.legend-item { display: flex; flex-direction: column; align-items: center; width: 30px; text-align: center; }
.legend-icon { font-size: 16px; }

#game-wrapper { display: flex; justify-content: center; margin-bottom: 15px; }
#game-container { padding: 10px; background: white; border-radius: 8px; box-shadow: 0 4px 15px rgba(0,0,0,0.3); display: inline-block; outline: none; }

#grid {
    display: grid;
    grid-template-columns: repeat(var(--grid-cols, 11), var(--cell-size));
    grid-template-rows: repeat(var(--grid-rows, 11), var(--cell-size));
    gap: 0;
    border: 2px solid #000;
    position: relative;
}
.cell { width: var(--cell-size); height: var(--cell-size); background-color: var(--grid-bg); border: 1px solid var(--border-color); box-sizing: border-box; display: flex; justify-content: center; align-items: center; font-size: 10px; color: #7f8c8d; user-select: none; position: relative; }
.cell:hover { background-color: #d5dbdb !important; }
.cell.cell-marked { opacity: 0.4; }

.pattern-E { background-image: radial-gradient(rgba(0,0,0,0.1) 15%, transparent 16%), radial-gradient(rgba(0,0,0,0.1) 15%, transparent 16%); background-size: 10px 10px; background-position: 0 0, 5px 5px; }
.pattern-B { background-image: linear-gradient(45deg, rgba(255,255,255,0.4) 25%, transparent 25%, transparent 75%, rgba(255,255,255,0.4) 75%, rgba(255,255,255,0.4)), linear-gradient(45deg, rgba(255,255,255,0.4) 25%, transparent 25%, transparent 75%, rgba(255,255,255,0.4) 75%, rgba(255,255,255,0.4)); background-size: 20px 20px; background-position: 0 0, 10px 10px; }
.pattern-L { background-image: linear-gradient(90deg, transparent 50%, rgba(0,0,0,0.05) 50%); background-size: 15px 100%; }
.pattern-C { background-image: repeating-linear-gradient(0deg, transparent, transparent 19px, rgba(0,0,0,0.1) 20px), repeating-linear-gradient(90deg, transparent, transparent 19px, rgba(0,0,0,0.1) 20px); background-size: 20px 20px; }
.pattern-V { background-image: linear-gradient(rgba(255,255,255,0.5) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,0.5) 1px, transparent 1px); background-size: 22.5px 22.5px; }

.wall-top { border-top: 3px solid #000; }
.wall-right { border-right: 3px solid #000; }
.wall-bottom { border-bottom: 3px solid #000; }
.wall-left { border-left: 3px solid #000; }

.door-v { position: absolute; left: -5px; top: 15%; height: 70%; width: 8px; background-color: #9b59b6; border: 1px solid #000; border-radius: 4px; z-index: 5; }
.door-h { position: absolute; top: -5px; left: 15%; width: 70%; height: 8px; background-color: #9b59b6; border: 1px solid #000; border-radius: 4px; z-index: 5; }
.label { position: absolute; background: white; border: 2px solid #000; border-radius: 12px; padding: 1px 6px; font-size: 9px; font-weight: bold; color: black; transform: translate(-50%, -50%); white-space: nowrap; z-index: 10; box-shadow: 0 1px 3px rgba(0,0,0,0.2); font-family: serif; text-transform: uppercase; }
.mark { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); font-weight: bold; z-index: 20; pointer-events: none; text-shadow: 1px 1px 0 #fff, -1px -1px 0 #fff, 1px -1px 0 #fff, -1px 1px 0 #fff; display: flex; justify-content: center; align-items: center; width: 100%; height: 100%; }

#footer-section { background: white; padding: 15px; border-radius: 20px; text-align: center; font-weight: bold; color: #555; box-shadow: 0 2px 5px rgba(0,0,0,0.1); display: flex; justify-content: center; align-items: center; gap: 10px; }
#footer-section input { border: none; border-bottom: 2px solid #ccc; font-family: 'Nunito', sans-serif; font-size: 16px; padding: 5px; width: 150px; text-align: center; outline: none; text-transform: uppercase; }
#check-btn { background-color: #e57373; color: white; border: none; padding: 8px 20px; border-radius: 20px; font-weight: bold; cursor: pointer; font-size: 14px; transition: background 0.2s; }
#check-btn:hover { background-color: #ef5350; }

/* Modal Styles */
#modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

#modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

#modal-content {
    background: white;
    padding: 30px;
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    max-width: 400px;
    width: 90%;
    transform: scale(0.8);
    transition: transform 0.3s;
}

#modal-overlay.active #modal-content {
    transform: scale(1);
}

#modal-title {
    margin-top: 0;
    font-family: 'Bangers', cursive;
    font-size: 32px;
    color: #2c3e50;
    letter-spacing: 1px;
}

#modal-message {
    font-size: 18px;
    margin: 20px 0;
    color: #555;
}

#modal-close-btn {
    background-color: #e57373;
    color: white;
    border: none;
    padding: 10px 25px;
    border-radius: 25px;
    font-weight: bold;
    cursor: pointer;
    font-size: 16px;
    transition: background 0.2s;
    font-family: 'Nunito', sans-serif;
    text-transform: uppercase;
}

#modal-close-btn:hover {
    background-color: #ef5350;
}
