:root {
    --bg-dark: #1a1a2e;
    --bg-panel: #16213e;
    --accent: #0f3460;
    --primary: #e94560;
    --text: #eaeaea;
    --domino-bg: #f0f0f0;
    --domino-dot: #333;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Segoe UI', Tahoma, sans-serif; }
body { background: var(--bg-dark); color: var(--text); min-height: 100vh; }
.app-container, .game-container { min-height: 100vh; display: flex; flex-direction: column; padding: 10px; }

button { cursor: pointer; border: none; padding: 10px 20px; border-radius: 5px; font-weight: bold; transition: 0.2s; }
.btn-primary { background: var(--primary); color: white; }
.btn-secondary { background: var(--accent); color: white; }
.btn-danger { background: #c0392b; color: white; }
.btn-small { padding: 5px 10px; font-size: 0.8rem; }
.btn-full { width: 100%; margin-top: 10px; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.login-bg { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-container { background: var(--bg-panel); padding: 40px; border-radius: 10px; text-align: center; width: 90%; max-width: 400px; }
.login-container input { width: 100%; padding: 12px; margin: 15px 0; border-radius: 5px; border: 1px solid var(--accent); background: var(--bg-dark); color: white; }
.error { color: #e74c3c; margin-top: 10px; }

.top-bar { display: flex; justify-content: space-between; align-items: center; padding: 10px; background: var(--bg-panel); border-radius: 8px; margin-bottom: 10px; }
.room-list table { width: 100%; border-collapse: collapse; margin-top: 10px; }
.room-list th, .room-list td { padding: 10px; text-align: left; border-bottom: 1px solid var(--accent); }
.hidden { display: none !important; }
.panel { background: var(--bg-panel); padding: 20px; border-radius: 8px; margin: 10px 0; }

.lobby-controls { display: flex; gap: 10px; margin-bottom: 10px; }
.player-select { display: flex; gap: 10px; margin: 15px 0; }
.btn-option { background: var(--accent); color: white; padding: 10px 20px; border-radius: 5px; }

.player-list { list-style: none; padding: 0; margin: 15px 0; }
.player-item { display: flex; justify-content: space-between; align-items: center; padding: 10px; background: var(--bg-dark); margin-bottom: 8px; border-radius: 6px; }
.player-info { display: flex; align-items: center; gap: 10px; }
.player-avatar { width: 35px; height: 35px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: white; font-weight: bold; }
.badge-host { background: #f1c40f; color: #000; padding: 2px 6px; border-radius: 3px; font-size: 0.7rem; font-weight: bold; }

.room-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; flex: 1; overflow: hidden; }
.player-list-panel, .chat-panel { background: var(--bg-panel); padding: 15px; border-radius: 8px; display: flex; flex-direction: column; overflow: hidden; }
.chat-box { flex: 1; overflow-y: auto; background: var(--bg-dark); padding: 10px; border-radius: 6px; margin: 10px 0; min-height: 200px; }
.chat-msg { margin-bottom: 6px; font-size: 0.9rem; word-wrap: break-word; }
.chat-input { display: flex; gap: 8px; }
.chat-input input { flex: 1; padding: 10px; border-radius: 5px; border: 1px solid var(--accent); background: var(--bg-dark); color: white; }

.game-header { display: flex; justify-content: space-between; align-items: center; padding: 10px; background: var(--bg-panel); border-radius: 8px; }
.timer { font-size: 1.5rem; font-weight: bold; color: #f1c40f; }
.board-area { flex: 1; background: #2d5a27; border-radius: 10px; margin: 10px 0; display: flex; align-items: center; justify-content: center; overflow-x: auto; padding: 20px; }
.opponents-area { display: flex; justify-content: space-around; padding: 10px; }
.opponent { text-align: center; padding: 10px; background: var(--bg-panel); border-radius: 8px; min-width: 80px; }
.opponent.active { border: 2px solid #f1c40f; box-shadow: 0 0 10px #f1c40f; }
.my-area { background: var(--bg-panel); padding: 15px; border-radius: 10px 10px 0 0; }
.my-hand { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; margin-bottom: 15px; min-height: 90px; }
.action-buttons { display: flex; justify-content: center; gap: 10px; }

.domino { width: 40px; height: 80px; background: var(--domino-bg); border-radius: 4px; display: flex; flex-direction: column; border: 1px solid #999; cursor: pointer; position: relative; box-shadow: 2px 2px 5px rgba(0,0,0,0.3); transition: transform 0.2s; }
.domino:hover { transform: translateY(-10px); }
.domino.disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.domino-half { flex: 1; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); padding: 4px; }
.domino-half:first-child { border-bottom: 1px solid #999; }
.dot { background: var(--domino-dot); border-radius: 50%; width: 6px; height: 6px; align-self: center; justify-self: center; }

.modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.8); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.modal-content { background: var(--bg-panel); padding: 30px; border-radius: 10px; text-align: center; border: 2px solid #f1c40f; }

@media (max-width: 768px) {
    .room-layout { grid-template-columns: 1fr; }
    .chat-panel { max-height: 40vh; }
    .domino { width: 35px; height: 70px; }
}
/* Header Controls */
.header-controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Toast Notification */
.game-toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    background: var(--bg-panel);
    color: white;
    padding: 15px 30px;
    border-radius: 10px;
    font-weight: bold;
    font-size: 1.1rem;
    z-index: 9999;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
    transition: transform 0.3s ease;
    border: 2px solid var(--accent);
    text-align: center;
    min-width: 250px;
}

.game-toast.show {
    transform: translateX(-50%) translateY(0);
}

.game-toast.toast-turn {
    background: linear-gradient(135deg, #2ecc71, #27ae60);
    border-color: #2ecc71;
    animation: pulse 1s ease-in-out;
}

.game-toast.toast-error {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    border-color: #e74c3c;
}

.game-toast.toast-success {
    background: linear-gradient(135deg, #3498db, #2980b9);
    border-color: #3498db;
}

.game-toast.toast-info {
    background: linear-gradient(135deg, #9b59b6, #8e44ad);
    border-color: #9b59b6;
}

@keyframes pulse {
    0%, 100% { transform: translateX(-50%) translateY(0) scale(1); }
    50% { transform: translateX(-50%) translateY(0) scale(1.05); }
}

/* Highlight kartu yang bisa dimainkan */
.domino:not(.disabled):hover {
    transform: translateY(-15px);
    box-shadow: 0 5px 15px rgba(233, 69, 96, 0.5);
    border-color: #e94560;
}

/* Animasi kartu di board */
.board-domino {
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: scale(0.5);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Opponent active glow */
.opponent.active {
    animation: glow 1.5s ease-in-out infinite;
}

@keyframes glow {
    0%, 100% { box-shadow: 0 0 10px #f1c40f; }
    50% { box-shadow: 0 0 25px #f1c40f, 0 0 40px #f39c12; }
}

/* Responsive untuk mobile */
@media (max-width: 600px) {
    .game-toast {
        font-size: 0.9rem;
        padding: 12px 20px;
        min-width: 200px;
    }
}
/* ============================================
   DOMINO DESIGN - Gaya Fisik (Horizontal)
   ============================================ */

/* Kartu di tangan pemain - DIPERBESAR 11% */
.domino {
    width: 77px;      /* 70px + 11% */
    height: 38px;     /* 35px + 11% */
    background: #fff;
    border-radius: 6px;
    display: flex;
    flex-direction: row;
    border: 2px solid #ddd;
    cursor: pointer;
    position: relative;
    box-shadow: 2px 2px 8px rgba(0,0,0,0.3);
    transition: all 0.2s ease;
    overflow: hidden;
}

.domino:hover:not(.disabled) {
    transform: translateY(-10px);
    box-shadow: 0 5px 20px rgba(233, 69, 96, 0.6);
    border-color: #e94560;
}

.domino.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    filter: grayscale(50%);
}

.domino.selected {
    border-color: #f1c40f;
    box-shadow: 0 0 15px #f1c40f;
    transform: translateY(-15px);
}

/* Setiap setengah kartu */
.domino-half {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    padding: 5px;
    position: relative;
    box-sizing: border-box;
}

/* Garis pemisah di tengah */
.domino-half:first-child {
    border-right: 2px solid #999;
}

/* Titik domino - MERAH - DIPERBESAR 11% */
.dot {
    background: #e74c3c;
    border-radius: 50%;
    width: 8px;       /* 7px + 11% */
    height: 8px;      /* 7px + 11% */
    align-self: center;
    justify-self: center;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.3);
}

/* Domino di board - DIPERBESAR 11% */
.board-domino {
    width: 55px;      /* 50px + 11% */
    height: 27px;     /* 25px + 11% */
    display: inline-flex;
    flex-direction: row;
    background: #fff;
    border: 2px solid #666;
    border-radius: 4px;
    margin: 0 2px;
    box-shadow: 1px 1px 4px rgba(0,0,0,0.3);
    animation: slideIn 0.3s ease-out;
}

.board-domino .domino-half {
    padding: 4px;
}

.board-domino .domino-half:first-child {
    border-right: 2px solid #666;
}

.board-domino .dot {
    width: 6px;       /* 5px + 11% */
    height: 6px;      /* 5px + 11% */
}
/* ============================================
   MODAL PILIHAN KIRI/KANAN
   ============================================ */

.choice-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.2s ease;
}

.choice-modal-content {
    background: linear-gradient(135deg, #16213e, #0f3460);
    padding: 30px;
    border-radius: 15px;
    text-align: center;
    border: 3px solid #f1c40f;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    max-width: 90%;
    width: 400px;
}

.choice-modal-content h3 {
    color: #f1c40f;
    margin-bottom: 20px;
    font-size: 1.3rem;
}

.choice-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-bottom: 20px;
}

.choice-btn {
    flex: 1;
    padding: 20px;
    font-size: 1.1rem;
    border-radius: 10px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--bg-panel);
    color: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.choice-btn:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 20px rgba(0,0,0,0.3);
}

.choice-btn.left {
    border-color: #3498db;
    background: linear-gradient(135deg, #3498db, #2980b9);
}

.choice-btn.right {
    border-color: #2ecc71;
    background: linear-gradient(135deg, #2ecc71, #27ae60);
}

.choice-btn .arrow {
    font-size: 2rem;
}

.choice-btn .label {
    font-weight: bold;
}

.choice-cancel {
    background: transparent;
    border: 2px solid #e74c3c;
    color: #e74c3c;
    padding: 10px 30px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
}

.choice-cancel:hover {
    background: #e74c3c;
    color: white;
}

/* Preview kartu di modal */
.choice-preview {
    display: flex;
    justify-content: center;
    margin: 15px 0;
}

.choice-preview .domino {
    width: 80px;
    height: 40px;
    pointer-events: none;
}

.choice-preview .dot {
    width: 8px;
    height: 8px;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { transform: translateY(50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.choice-modal-content {
    animation: slideUp 0.3s ease;
}

/* Responsive */
@media (max-width: 600px) {
    .domino {
        width: 60px;
        height: 30px;
    }
    .dot {
        width: 6px;
        height: 6px;
    }
    .board-domino {
        width: 40px;
        height: 20px;
    }
    .board-domino .dot {
        width: 4px;
        height: 4px;
    }
    .choice-modal-content {
        padding: 20px;
        width: 90%;
    }
    .choice-btn {
        padding: 15px;
    }
}
/* ============================================
   DRAG & DROP STYLES
   ============================================ */

/* Kartu yang sedang di-drag */
.domino.dragging {
    opacity: 0.5;
    transform: scale(1.1);
    box-shadow: 0 10px 30px rgba(233, 69, 96, 0.8);
    z-index: 1000;
    cursor: grabbing;
}

/* Ghost image saat drag */
.domino.drag-ghost {
    position: fixed;
    pointer-events: none;
    z-index: 10000;
    transform: scale(1.2);
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    transition: transform 0.1s;
}

/* Area drop zone di board */
.drop-zone {
    position: absolute;
    width: 60px;
    height: 40px;
    border: 3px dashed rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    pointer-events: none;
}

.drop-zone.active {
    border-color: #f1c40f;
    background: rgba(241, 196, 15, 0.2);
    animation: pulse-border 1s ease-in-out infinite;
}

.drop-zone.left-zone {
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
}

.drop-zone.right-zone {
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
}

.drop-zone-label {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.7rem;
    font-weight: bold;
    text-transform: uppercase;
}

.drop-zone.active .drop-zone-label {
    color: #f1c40f;
}

@keyframes pulse-border {
    0%, 100% { border-color: #f1c40f; box-shadow: 0 0 10px rgba(241, 196, 15, 0.3); }
    50% { border-color: #f39c12; box-shadow: 0 0 20px rgba(241, 196, 15, 0.6); }
}

/* Board area dengan drop zones */
.board-area {
    position: relative;
    min-height: 200px;
}

/* Highlight kartu yang bisa di-drag */
.domino.draggable {
    cursor: grab;
}

.domino.draggable:hover {
    transform: translateY(-10px);
    box-shadow: 0 5px 20px rgba(233, 69, 96, 0.6);
}

.domino.draggable:active {
    cursor: grabbing;
}

/* Touch device optimization */
@media (hover: none) and (pointer: coarse) {
    .domino.draggable {
        touch-action: none;
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        user-select: none;
    }
}

/* Responsive drop zones */
@media (max-width: 600px) {
    .drop-zone {
        width: 50px;
        height: 35px;
    }
    .drop-zone.left-zone {
        left: 5px;
    }
    .drop-zone.right-zone {
        right: 5px;
    }
}
/* ============================================
   RESPONSIVE ANDROID & MOBILE
   ============================================ */

/* Tablet & Large Phone (max-width: 768px) */
@media (max-width: 768px) {
    .game-container {
        padding: 5px;
    }
    
    .game-header {
        padding: 8px;
        flex-wrap: wrap;
        gap: 5px;
    }
    
    .timer {
        font-size: 1.2rem;
    }
    
    .turn-info {
        font-size: 0.9rem;
    }
    
    .header-controls {
        gap: 5px;
    }
    
    .btn-small {
        padding: 6px 10px;
        font-size: 0.75rem;
    }
    
    .board-area {
        min-height: 150px;
        padding: 10px;
    }
    
    .opponents-area {
        padding: 5px;
        gap: 5px;
    }
    
    .opponent {
        padding: 8px;
        min-width: 70px;
        font-size: 0.85rem;
    }
    
    .my-area {
        padding: 10px;
    }
    
    .my-hand {
        gap: 6px;
        min-height: 50px;
        overflow-x: auto;
        padding-bottom: 5px;
    }
    
    .action-buttons {
        gap: 8px;
    }
    
    .action-buttons button {
        flex: 1;
        padding: 12px;
        font-size: 0.9rem;
    }
    
    .drop-zone {
        width: 50px;
        height: 35px;
    }
}

/* Phone Portrait (max-width: 480px) */
@media (max-width: 480px) {
    .game-header {
        padding: 6px;
    }
    
    .timer {
        font-size: 1rem;
    }
    
    .turn-info {
        font-size: 0.8rem;
    }
    
    .board-area {
        min-height: 120px;
        padding: 8px;
    }
    
    .opponents-area {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .opponent {
        min-width: 60px;
        padding: 6px;
        font-size: 0.75rem;
    }
    
    .opponent div[style*="font-size:1.5rem"] {
        font-size: 1.2rem !important;
    }
    
    .my-hand {
        gap: 4px;
        justify-content: flex-start;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
    }
    
    /* Scrollbar untuk Chrome/Safari */
    .my-hand::-webkit-scrollbar {
        height: 4px;
    }
    
    .my-hand::-webkit-scrollbar-track {
        background: rgba(0,0,0,0.1);
        border-radius: 2px;
    }
    
    .my-hand::-webkit-scrollbar-thumb {
        background: rgba(233, 69, 96, 0.5);
        border-radius: 2px;
    }
    
    .action-buttons {
        flex-direction: row;
    }
    
    .action-buttons button {
        padding: 10px;
        font-size: 0.85rem;
    }
    
    .game-toast {
        font-size: 0.85rem;
        padding: 10px 20px;
        min-width: 180px;
    }
    
    .choice-modal-content {
        padding: 15px;
        width: 95%;
    }
    
    .choice-btn {
        padding: 12px;
        font-size: 0.9rem;
    }
    
    .choice-btn .arrow {
        font-size: 1.5rem;
    }
}

/* Small Phone (max-width: 360px) */
@media (max-width: 360px) {
    .domino {
        width: 70px;
        height: 35px;
    }
    
    .dot {
        width: 7px;
        height: 7px;
    }
    
    .board-domino {
        width: 50px;
        height: 25px;
    }
    
    .board-domino .dot {
        width: 5px;
        height: 5px;
    }
    
    .domino-half {
        padding: 4px;
    }
    
    .my-hand {
        gap: 3px;
    }
}

/* Landscape Mode */
@media (max-height: 500px) and (orientation: landscape) {
    .game-container {
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    .game-header {
        width: 100%;
        order: 1;
    }
    
    .board-area {
        width: 60%;
        order: 2;
        min-height: 100px;
    }
    
    .opponents-area {
        width: 40%;
        order: 3;
        flex-direction: column;
        min-height: 100px;
    }
    
    .my-area {
        width: 100%;
        order: 4;
    }
    
    .my-hand {
        flex-wrap: nowrap;
        overflow-x: auto;
    }
}

/* Android-specific optimizations */
@supports (-webkit-touch-callout: none) {
    /* iOS Safari */
    .domino {
        -webkit-tap-highlight-color: transparent;
    }
}

/* Prevent text selection on drag */
.domino.draggable {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

/* Smooth scrolling for hand */
.my-hand {
    scroll-behavior: smooth;
}

/* Fix for Android Chrome address bar */
@supports (height: 100dvh) {
    .game-container {
        height: 100dvh;
    }
}