body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: #f5f5f5;
    margin: 0;
    padding: 20px;
    user-select: none;
}

h1 { color: #333; margin-bottom: 10px; text-align: center; }

/* --- UI Controls --- */
.header-controls {
    margin-bottom: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 90vw;
    /* 400px board + 2x12px border */
    max-width: 424px;
}
.tabs { 
    display: flex; 
    flex: 1;
    margin-right: 15px;
    background: #e0e0e0; 
    border-radius: 8px; 
    overflow: hidden; 
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.1);
}
button.tab {
    flex: 1;
    margin: 0;
    border-radius: 0;
    background: transparent;
    color: #555;
    box-shadow: none;
    transition: all 0.3s ease;
}
button.tab:hover {
    background: rgba(0,0,0,0.05);
}
button.tab.active {
    background: #5d4037;
    color: white;
}
button.tab.active:hover {
    background: #3e2723;
}

#board-wrapper { position: relative; }

#board {
    width: 90vw;
    max-width: 400px;
    aspect-ratio: 4 / 5;
    background: #a1887f;
    position: relative;
    border: 12px solid #5d4037;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    box-sizing: content-box;
    overflow: hidden;
    touch-action: none;
}

.exit-marker {
    position: absolute;
    border: 4px dashed #4caf50;
    box-sizing: border-box;
    background: rgba(76, 175, 80, 0.2);
    z-index: 5;
    /* Matches the animation speed of the other pieces perfectly */
    transition: top 0.2s ease, left 0.2s ease;
    pointer-events: none; /* Let pieces be dragged above it in play mode */
}
#board.mode-edit .exit-marker {
    cursor: grab;
    pointer-events: auto;
}
#board.mode-edit .exit-marker:active {
    cursor: grabbing;
}

.piece {
    position: absolute;
    box-sizing: border-box;
    border: 2px solid #3e2723;
    border-radius: 6px;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.2);
    cursor: grab;
    z-index: 10;
}

.piece.smooth { transition: top 0.2s ease, left 0.2s ease; }
.piece:active { cursor: grabbing; }

/* Piece Colors */
.piece.C { background: #d32f2f; }
.piece.V { background: #1976d2; }
.piece.H { background: #388e3c; }
.piece.S { background: #fbc02d; }

/* --- Edit Palette --- */
#edit-panel {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    width: 90vw;
    max-width: 400px;
}

.palette-area { display: flex; gap: 15px; align-items: flex-end; justify-content: center; height: 80px; }

.palette-piece {
    border: 2px solid #3e2723; border-radius: 4px; cursor: grab;
    box-shadow: inset 0 0 5px rgba(0,0,0,0.2);
    transition: outline 0.2s ease;
}
.palette-piece.active {
    outline: 4px solid #4caf50;
    outline-offset: 2px;
}
.palette-piece.C { width: 50px; height: 50px; background: #d32f2f; }
.palette-piece.V { width: 25px; height: 50px; background: #1976d2; }
.palette-piece.H { width: 50px; height: 25px; background: #388e3c; }
.palette-piece.S { width: 25px; height: 25px; background: #fbc02d; }

/* --- Play Controls --- */
#play-panel {
    margin-top: 20px; display: flex; flex-direction: column; align-items: center; gap: 15px;
}

#step-controls { display: flex; gap: 15px; align-items: center; font-size: 18px; font-weight: bold; }

button {
    padding: 10px 20px; font-size: 16px; font-weight: bold; color: white;
    background: #5d4037; border: none; border-radius: 5px; cursor: pointer;
}
button:hover { background: #3e2723; }
button:disabled { background: #ccc; cursor: not-allowed; color: #666;}
.btn-red { background: #d32f2f; } .btn-red:hover { background: #b71c1c; }

#status { margin-top: 15px; font-weight: bold; font-size: 18px; color: #333; text-align: center; height: 25px;}

/* Ghost element for drag and drop */
#ghost {
    position: fixed; pointer-events: none; opacity: 0.7; z-index: 9999;
    border: 2px solid #fff; box-shadow: 0 10px 20px rgba(0,0,0,0.5); border-radius: 6px; display: none;
    transition: none !important; /* Forces drag ghost to never animate when reused */
}
.lang-switcher {
    display: flex;
    gap: 2px;
    background: #e0e0e0;
    padding: 3px;
    border-radius: 8px;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
}
.lang-btn {
    padding: 4px 6px;
    font-size: 20px; /* Larger font for flags */
    background: transparent;
    border-radius: 6px;
    box-shadow: none;
    min-width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    /* line-height: 1; */
}
.lang-btn:hover {
    background: rgba(0,0,0,0.05);
}
.lang-btn.active {
    background: #fff;
    /* color: #5d4037; */
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
