* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
    width: 100%; height: 100%;
    overflow: hidden;
    background: #1a1a2e;
    font-family: 'Segoe UI', Arial, sans-serif;
    touch-action: none;
    user-select: none;
}

#wrap { display: flex; flex-direction: column; width: 100%; height: 100%; align-items: center; }

#board-container {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    width: 100%;
    min-height: 0;
}

#board-canvas {
    display: block;
    background: #f0d9a8;
    box-shadow: 0 8px 40px rgba(0,0,0,0.5);
    border-radius: 4px;
    touch-action: none;
    cursor: pointer;
}

#toolbar {
    display: flex;
    gap: 6px;
    padding: 8px 10px;
    width: 100%;
    flex-wrap: wrap;
    justify-content: center;
    background: rgba(0,0,0,0.4);
}

.btn {
    padding: 10px 12px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s;
}

.btn:active { transform: scale(0.95); }

.btn-hint { background: #3c82c8; }
.btn-restart { background: #c83c3c; }
.btn-swap { background: #666; }
.btn-pgn { background: #3ca050; }
.btn-undo { background: #7c4dff; }
.btn-view { background: #2e7d32; }
.btn-view.active {
    background: #ff9800;
    box-shadow: 0 0 16px rgba(255, 152, 0, 1);
}
/* Nút Đổi biến — sáng/mờ */
.btn-change {
    background: #c8823c;
    opacity: 1;
    box-shadow: 0 0 12px rgba(200, 130, 60, 0.8);
}
.btn-change.dim {
    opacity: 0.35;
    box-shadow: none;
    background: #666;
}
.btn-change.glow {
    opacity: 1;
    box-shadow: 0 0 16px rgba(255, 180, 60, 1);
    background: #e8a04c;
}

#status {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    padding: 6px 20px;
    background: rgba(0,0,0,0.7);
    color: #fff;
    border-radius: 20px;
    font-size: 13px;
    z-index: 10;
    pointer-events: none;
}

#pgn-info {
    position: absolute;
    bottom: 10px;
    left: 10px;
    padding: 6px 12px;
    background: rgba(0,0,0,0.5);
    color: #ddd;
    border-radius: 6px;
    font-size: 12px;
    z-index: 10;
    pointer-events: none;
    max-width: 60%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    padding: 10px 24px;
    background: rgba(0,0,0,0.9);
    color: #fff;
    border-radius: 8px;
    font-size: 14px;
    opacity: 0;
    transition: all 0.3s;
    pointer-events: none;
    z-index: 100;
    max-width: 90%;
    text-align: center;
}

#toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

#loading {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: #1a1a2e;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #fff;
    z-index: 1000;
    transition: opacity 0.5s;
}

#loading.hidden { opacity: 0; pointer-events: none; }

.spinner {
    width: 60px; height: 60px;
    border: 5px solid #333;
    border-top-color: #4CAF50;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin { to { transform: rotate(360deg); } }

#error-log {
    position: fixed;
    top: 0; left: 0;
    width: 100%;
    padding: 10px;
    background: #c00;
    color: #fff;
    font-family: monospace;
    font-size: 12px;
    z-index: 2000;
    display: none;
    max-height: 40%;
    overflow: auto;
    white-space: pre-wrap;
}