:root {
    --primary: #9eaffc;
    --success: #2ec4b6;
    --bg-soft: #f0f2f5;
    --card-shadow: 0 10px 20px rgba(0,0,0,0.08);
}

body {
    font-family: 'Segoe UI', system-ui, sans-serif;
    background-color: #e9ecef;
    display: flex; justify-content: center; align-items: center;
    min-height: 100vh; margin: 0;
}

.container {
    background: white; padding: 40px; border-radius: 30px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.1);
    width: 800px; text-align: center;
}

.top-controls { display: flex; justify-content: space-between; margin-bottom: 25px; }

.control-box {
    background: var(--bg-soft); padding: 10px 15px; border-radius: 15px;
    justify-content: space-between;
    display: flex; align-items: center; gap: 10px; margin-bottom: 8px;
}

.control-box select, .control-box input {
    border: none; background: transparent; outline: none; font-weight: 600;
}

.arrow-down {
    width: 0; 
    height: 0; 
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid #333; /* Màu mũi tên */
    margin-left: 10px;
}

#currentVoiceName {
    font-size: 0.85rem;
    font-weight: bold;
    color: #333;
}

.timer-wrapper {
    background: #fff0f6;
    padding: 5px 15px;
    border-radius: 12px;
    font-weight: bold;
    color: #d63384;
    font-size: 1.1rem;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
    display: inline-block;
    margin-top: 5px; 
}

.settings-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 5px;
}

.time-input-hidden, .hidden { display: none !important; }

.game-area {
    display: flex; height: 350px; background: var(--bg-soft);
    border-radius: 25px; position: relative; margin-bottom: 30px;
    padding: 20px 20px;
}

.slot { 
    flex: 1; position: relative; 
    display: flex; justify-content: center; align-items: center; 
}

.card {
    width: 200px; height: 280px; position: absolute;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform-style: preserve-3d;
    perspective: 1000px;
    cursor: pointer;
}

.card-face {
    position: absolute; width: 100%; height: 100%;
    backface-visibility: hidden !important;
    -webkit-backface-visibility: hidden !important;
    border-radius: 20px;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 25px; box-sizing: border-box;
}

.card-front { background: var(--primary); color: white; z-index: 2; }
.card-back { background: white; transform: rotateY(180deg); color: #333; z-index: 1; }

/* PC State: Card moves to the right slot */
.card.is-dealt {
    transform: translateX(370px) rotateY(180deg) !important;
    z-index: 500 !important;
}

.card.is-dealt .card-front { visibility: hidden; }

/* Footer & Buttons */
.footer-info { display: flex; justify-content: space-between; align-items: center; }

#btnPause { background-color: #ff9f1c; color: white; }
#btnPause.paused { background-color: #2ec4b6; }

#leftSlot {
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

input[disabled] + span, 
label:has(input[disabled]) {
    color: #bdc3c7;
    cursor: not-allowed;
    opacity: 0.6;
}

.btn { 
    padding: 12px 25px; border-radius: 12px; border: none; 
    cursor: pointer; font-weight: 600; background: #e0e0e0; transition: 0.3s;
}
.btn:hover { background: #d0d0d0; }

.btn-primary { 
    background: var(--success); color: white; padding: 12px 40px; 
    border-radius: 12px; border: none; font-weight: bold; cursor: pointer;
}

.status { font-weight: bold; color: #7f8c8d; font-size: 1.1rem; }

/* Debug Overlay Styles */
.debug-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
}

.debug-content {
    background: white;
    padding: 20px;
    border-radius: 15px;
    max-width: 90%;
    max-height: 80%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.debug-content h3 {
    display: flex;
    justify-content: space-between;
    margin-top: 0;
}

#closeDebug {
    background: #ff4d4d;
    color: white;
    border: none;
    border-radius: 5px;
    padding: 5px 10px;
    cursor: pointer;
}

.table-scroll {
    overflow-y: auto;
    border: 1px solid #ddd;
}

#inputTime {
    width: 50px;
    padding: 5px;
    border: 1px solid #ccc;
    border-radius: 5px;
    text-align: center;
}

#voiceTable {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    text-align: left;
}

#voiceTable th, #voiceTable td {
    padding: 8px;
    border-bottom: 1px solid #eee;
}

#voiceTable th {
    background: #f8f9fa;
    position: sticky;
    top: 0;
}

/* Mobile Optimization */
@media (max-width: 768px) {
    .top-controls { flex-direction: column; align-items: stretch; gap: 15px; }
    .settings-left { display: flex; flex-direction: column; gap: 10px; }
    .control-box { justify-content: space-between; padding: 8px 12px; }
    .control-box select { max-width: 120px; font-size: 0.9rem; }
    #inputTime { width: 40px; }
    .settings-right {
        align-items: center;
        flex-direction: row;
        justify-content: space-around;
        background: var(--bg-soft);
        padding: 10px;
        border-radius: 15px;
    }
    .game-area { justify-content: center; }
    .slot:last-child { display: none; }
    .card { width: 190px; height: 270px; }

    .card.is-moving-right { transform: translateX(60px) rotateY(90deg) !important; }
    .card.is-dealt { transform: translateX(0) rotateY(180deg) !important; }
    .card.is-undoing { transition: none !important; transform: translateX(60px) rotateY(180deg) !important; opacity: 0; }
    .card.is-returning { transition: transform 0.3s ease-in-out, opacity 0.2s !important; transform: translateX(0) rotateY(0deg) !important; opacity: 1; }
    .card.is-hidden-mobile { opacity: 0 !important; visibility: hidden; }

    .footer-info { flex-direction: column; align-items: flex-start !important; padding-left: 15px; }
    .button-group { display: flex; flex-direction: column; width: 100%; gap: 8px; }
    #btnDeal, #btnPause, #btnUndo, #btnReset {
            width: 100% !important; /* Chiếm hết chiều ngang container */
            max-width: 400px;       /* Giới hạn lại để không quá dài trên tablet */
            margin-left: 0 !important;
        }


    #btnDeal { order: 1; }
    #btnPause { order: 2; }
    #btnUndo { order: 3; }
    #btnReset { order: 4; }
    .status { order: -1; margin-bottom: 10px; }
}