* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Finger Paint', cursive;
}

body {
    background-color: #233e2a; 
    background-image: 
        radial-gradient(circle at center, rgba(0,0,0,0.1) 0%, rgba(0,0,0,0.6) 100%),
        url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.2' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.08'/%3E%3C/svg%3E");
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    padding: 3rem;
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 0 0 3px rgba(255,255,255,0.4), 1px 1px 5px rgba(0,0,0,0.5);
}

.app-container {
    width: 100%;
    max-width: 1600px; 
    display: flex;
    flex-direction: column;
    gap: 2rem;
    margin: 0 auto;
}

.chalk-box {
    border: none !important;
    position: relative;
    background: rgba(255,255,255,0.03); 
    box-shadow: 
        inset 0 0 0 2px rgba(255,255,255,0.1), 
        0 0 0 3px rgba(255,255,255,0.2), 
        0 0 10px rgba(255,255,255,0.1); 
    border-radius: 8px;
}

header h1 {
    font-size: 3rem; 
    letter-spacing: 3px;
    text-align: center;
    opacity: 0.95;
    margin-bottom: 0.5rem;
    text-shadow: 0 0 5px rgba(255,255,255,0.6), 2px 2px 8px rgba(0,0,0,0.6);
}

.top-controls {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 2rem;
    max-width: 1100px; 
    margin: 0 auto;
    width: 100%;
}

.btn {
    background: transparent;
    color: rgba(255, 255, 255, 0.9);
    padding: 1rem 1.2rem; 
    font-size: 1.3rem; 
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    user-select: none; 
    text-shadow: inherit;
}

.btn:hover {
    background: rgba(255, 255, 255, 0.1); 
    transform: translateY(-2px);
    box-shadow: inset 0 0 0 2px rgba(255,255,255,0.3), 0 0 0 4px rgba(255,255,255,0.4), 0 4px 8px rgba(0,0,0,0.3);
}

.btn:active { transform: translateY(2px) scale(0.98); }

.main-layout {
    display: grid;
    grid-template-columns: 350px 1fr; 
    gap: 2rem; 
    align-items: stretch;
    min-height: 65vh; 
    transition: all 0.5s ease;
}

.left-panel {
    display: flex;
    flex-direction: column;
}

.panel-section {
    padding: 2rem 1.5rem; 
    box-shadow: 0 2px 2px -2px rgba(255,255,255,0.5); 
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1; 
}

.panel-section.last-section { box-shadow: none; }

.player-input-section {
    flex-direction: column;
    gap: 1.5rem;
}

.avatar-preview-container {
    position: relative;
    width: 64px;
    height: 64px;
}

.avatar-preview-container img {
    width: 100%;
    height: 100%;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.15); 
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);
}

.reroll-btn {
    position: absolute;
    bottom: -8px;
    right: -10px;
    background: transparent;
    border: 2px dashed rgba(255, 255, 255, 0.5);
    color: white;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s;
    user-select: none;
}

.reroll-btn:hover {
    background: rgba(255,255,255,0.1);
    transform: rotate(45deg);
    border-color: #D4AF37;
    color: #D4AF37;
}

input[type="text"] {
    width: 100%;
    background: transparent;
    border: none;
    box-shadow: 0 3px 2px -2px rgba(255,255,255,0.4);
    color: rgba(255, 255, 255, 0.95);
    padding: 0.8rem; 
    font-size: 1.5rem; 
    outline: none;
    text-align: center;
    transition: all 0.3s ease;
    text-shadow: inherit;
}

input[type="text"]:focus { box-shadow: 0 3px 2px -2px #D4AF37; }
input[type="text"]::placeholder { color: rgba(255, 255, 255, 0.4); }
h2 { font-size: 1.6rem; }

.settings-section { flex-direction: column; gap: 1.8rem; }
.step-controls { display: flex; justify-content: space-around; width: 100%; gap: 10px; }
.step-input-group { display: flex; flex-direction: column; align-items: center; gap: 8px; font-size: 1.2rem; opacity: 0.9; }

.chalk-number {
    width: 60px; 
    background: transparent;
    border: none;
    box-shadow: 0 3px 2px -2px rgba(255,255,255,0.4);
    color: rgba(255, 255, 255, 0.95);
    padding: 0.4rem; 
    font-size: 1.4rem; 
    outline: none;
    text-align: center;
    -moz-appearance: textfield; 
}
.chalk-number::-webkit-outer-spin-button, .chalk-number::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.chalk-number:focus { box-shadow: 0 3px 2px -2px #D4AF37; }

.chalk-checkbox-wrapper { position: relative; width: 100%; display: flex; justify-content: center; }
.checkbox-label { font-size: 1.2rem; cursor: pointer; display: flex; align-items: center; gap: 12px; user-select: none; position: relative; }
.checkbox-label input { position: absolute; opacity: 0; cursor: pointer; height: 0; width: 0; }
.chalk-checkmark { position: relative; height: 28px; width: 28px; background-color: transparent; box-shadow: inset 0 0 0 2px rgba(255,255,255,0.1), 0 0 0 3px rgba(255,255,255,0.4); border-radius: 4px; transition: all 0.2s ease; }
.checkbox-label:hover input ~ .chalk-checkmark { background-color: rgba(255, 255, 255, 0.05); }
.chalk-checkmark:after { content: ""; position: absolute; display: none; left: 6px; top: 2px; width: 11px; height: 16px; border: solid rgba(255, 255, 255, 0.9); border-width: 0 3px 3px 0; transform: rotate(45deg); filter: drop-shadow(0 0 2px rgba(255,255,255,0.6)); }
.checkbox-label input:checked ~ .chalk-checkmark:after { display: block; }

.right-panel { overflow: hidden; display: flex; flex-direction: column; }
.scoreboard-header { box-shadow: 0 2px 2px -2px rgba(255,255,255,0.5); padding: 1.5rem; text-align: center; }

#match-name {
    font-size: 2.8rem; 
    color: #D4AF37;
    text-shadow: 0 0 4px rgba(212, 175, 55, 0.5), 1px 1px 2px rgba(0,0,0,0.7);
    letter-spacing: 1.5px;
    padding: 10px 0 15px 0; 
    line-height: 1.3; 
    overflow: visible;
}
#match-name:focus { background: rgba(255, 255, 255, 0.05); }

#scoreboard-container { flex: 1; overflow-y: auto; padding: 1rem 0; }
.table-responsive { width: 100%; overflow-x: auto; }
.scoreboard-table { width: 100%; border-collapse: collapse; text-align: center; }
.scoreboard-table th, .scoreboard-table td {
    box-shadow: 0 1px 1px -1px rgba(255,255,255,0.3);
    padding: 1.2rem 1rem; 
    white-space: nowrap;
}
.scoreboard-table th {
    font-size: 1.3rem; 
    color: rgba(255, 255, 255, 0.6);
    background: rgba(0, 0, 0, 0.1);
    box-shadow: 0 2px 2px -2px rgba(255,255,255,0.5);
}

.scoreboard-table td { font-size: 1.5rem; }

.player-name-cell {
    font-size: 1.6rem; 
    text-align: left;
    padding-left: 1.5rem !important;
    position: relative;
    width: 280px; 
}

.player-name-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
}

.player-avatar {
    width: 28px; 
    height: 28px;
    border-radius: 4px;
    background-color: transparent;
    box-shadow: none;
}

.delete-btn {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.3);
    font-size: 1.5rem;
    cursor: pointer;
    transition: color 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
    text-shadow: none;
}

.delete-btn:hover {
    color: #ff4757;
}

.total-cell {
    font-size: 1.8rem; 
    box-shadow: -2px 0 2px -1px rgba(255,255,255,0.4) !important;
    background: rgba(0, 0, 0, 0.15);
    font-weight: bold;
}
.cell-controls { display: flex; align-items: center; justify-content: center; gap: 1rem; font-size: 1.5rem; }
.cell-controls span { display: inline-block; min-width: 35px; }
.score-btn.small {
    width: 36px; height: 36px; 
    font-size: 1.4rem; 
    border-radius: 6px; padding: 0; display: flex; justify-content: center; align-items: center; border: 2px dashed rgba(255,255,255,0.5); background: transparent; color: white; cursor: pointer;
}
.score-btn.small:hover { background: rgba(255,255,255,0.1); }

.player-row { transition: background-color 0.4s ease; }
.player-row.rank-1 { background: linear-gradient(90deg, rgba(212, 175, 55, 0.2) 0%, rgba(212, 175, 55, 0.05) 100%); }
.player-row.rank-1 .player-name-cell, .player-row.rank-1 .total-cell { color: #D4AF37; text-shadow: 0 0 5px rgba(212, 175, 55, 0.6); }

.player-row.rank-2 { background: linear-gradient(90deg, rgba(192, 192, 192, 0.15) 0%, rgba(192, 192, 192, 0.05) 100%); }
.player-row.rank-2 .player-name-cell, .player-row.rank-2 .total-cell { color: #C0C0C0; text-shadow: 0 0 5px rgba(192, 192, 192, 0.5); }

.player-row.rank-3 { background: linear-gradient(90deg, rgba(205, 127, 50, 0.15) 0%, rgba(205, 127, 50, 0.05) 100%); }
.player-row.rank-3 .player-name-cell, .player-row.rank-3 .total-cell { color: #CD7F32; text-shadow: 0 0 5px rgba(205, 127, 50, 0.5); }

.crown-icon { width: 28px; height: auto; margin-left: 4px; vertical-align: middle; filter: drop-shadow(0 0 4px rgba(212, 175, 55, 0.8)) brightness(0.9) contrast(1.2); animation: dropInCrown 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards; }
.empty-state { text-align: center; opacity: 0.5; padding: 6rem 2rem; font-size: 1.5rem; }

.post-game-controls {
    display: flex;
    justify-content: center;
    gap: 2rem;
    padding: 2rem; 
    background: rgba(0, 0, 0, 0.2);
    border-top: 2px dashed rgba(255,255,255,0.3);
}

.animate-enter { animation: popInRow 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards; transform-origin: center top; }
.animate-score span { animation: scoreBump 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards; color: #D4AF37; }
@keyframes popInRow { 0% { opacity: 0; transform: translateY(15px); } 100% { opacity: 1; transform: translateY(0); } }
@keyframes scoreBump { 0% { transform: scale(1); } 50% { transform: scale(1.6); } 100% { transform: scale(1); color: inherit; } }
@keyframes dropInCrown { 0% { opacity: 0; transform: translateY(-20px) rotate(-20deg) scale(0.5); } 100% { opacity: 1; transform: translateY(0) rotate(0deg) scale(1); } }