* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #0f172a;
    min-height: 100vh;
    margin: 0;
    padding: 0;
    color: #f1f5f9;
    overflow-x: hidden;
    -webkit-user-select: none;
    -moz-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

.container {
    width: 100%;
    min-height: 100vh;
    padding: 4px;
    display: flex;
    flex-direction: column;
    margin: 0;
    box-sizing: border-box;
    overflow-x: hidden;
}

h1 {
    text-align: center;
    margin: 8px 0;
    color: #f1f5f9;
    font-size: 1.5rem;
    font-weight: 600;
    flex-shrink: 0;
}

.game-board {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    min-height: 0;
    margin-bottom: 8px;
}

.board-grid {
    display: grid;
    gap: 4px;
    padding: 8px;
    background: rgba(30, 41, 59, 0.5);
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.2);
    justify-content: center;
    align-content: center;
    width: 100%;
    max-width: calc(100vw - 16px);
    box-sizing: border-box;
}

.grid-cell {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.slot {
    position: relative;
    border: 2px solid rgba(148, 163, 184, 0.4);
    border-radius: 8px;
    transition: all 0.2s ease;
    display: flex;
    background: rgba(51, 65, 85, 0.3);
}

.slot.vertical {
    width: 55px;
    height: 110px;
    flex-direction: column;
}

.slot.horizontal {
    width: 110px;
    height: 55px;
    flex-direction: row;
}

.slot:hover {
    border-color: #63b3ed;
    box-shadow: 0 0 8px rgba(99, 179, 237, 0.6);
}

.slot-half {
    flex: 1;
    border: 1px solid rgba(148, 163, 184, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.slot.horizontal .slot-half.left {
    border-right: 2px solid rgba(148, 163, 184, 0.4);
}

.slot.vertical .slot-half.top {
    border-bottom: 2px solid rgba(148, 163, 184, 0.4);
}

/* Diamond-shaped region markers */
.region-marker {
    width: 40px;
    height: 40px;
    transform: rotate(45deg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #0f172a;
    font-size: 16px;
    font-weight: 700;
    border: 2px solid rgba(255, 255, 255, 0.9);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
    z-index: 10;
}

.region-marker span {
    transform: rotate(-45deg);
}

.dominoes-container {
    flex-shrink: 0;
    margin-bottom: 8px;
}

.dominoes {
    display: flex;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 8px;
}

.domino {
    border: 2px solid rgba(148, 163, 184, 0.6);
    border-radius: 8px;
    background: #f8fafc;
    position: relative;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    transition: all 0.2s ease;
    display: flex;
}

.domino.vertical {
    width: 55px;
    height: 110px;
    flex-direction: column;
}

.domino.horizontal {
    width: 110px;
    height: 55px;
    flex-direction: row;
}

.domino.clickable {
    cursor: pointer;
}

.domino.clickable:active {
    transform: scale(0.95);
}

.domino.selected {
    border-color: #22c55e;
    box-shadow: 0 0 12px rgba(34, 197, 94, 0.4);
    transform: scale(1.02);
}

.domino.placed {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 5;
    background: rgba(248, 250, 252, 0.7);
    opacity: 0.75;
}

.domino-half {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    padding: 4px;
    position: relative;
}

.domino.placed .domino-half {
    background: rgba(248, 250, 252, 0.5);
}

.domino.vertical .domino-half.top {
    border-bottom: 1px solid rgba(148, 163, 184, 0.4);
}

.domino.horizontal .domino-half.left {
    border-right: 1px solid rgba(148, 163, 184, 0.4);
}

.dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: transparent;
    margin: auto;
}

.dot.visible {
    background: #0f172a;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.controls {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin: 8px 0;
    flex-shrink: 0;
}

button {
    background: #3b82f6;
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s ease;
    flex: 1;
    max-width: 120px;
    min-height: 44px;
}

button:active {
    transform: scale(0.95);
    background: #2563eb;
}

.status {
    text-align: center;
    padding: 8px;
    background: rgba(30, 41, 59, 0.5);
    border-radius: 8px;
    font-weight: 500;
    color: #cbd5e1;
    border: 1px solid rgba(148, 163, 184, 0.2);
    font-size: 13px;
    line-height: 1.3;
    flex-shrink: 0;
    margin-bottom: 8px;
}

/* Responsive design */
@media (max-width: 600px) {
    .container {
        margin: 5px;
        padding: 10px;
        max-width: 100vw;
    }

    h1 {
        font-size: 1.6rem;
        margin-bottom: 10px;
    }

    .game-board {
        margin-bottom: 15px;
        min-height: auto;
    }

    .board-grid {
        padding: 15px;
        gap: 4px;
    }

    .slot.vertical {
        width: 50px;
        height: 100px;
    }

    .slot.horizontal {
        width: 100px;
        height: 50px;
    }

    .dominoes-container {
        margin-bottom: 15px;
    }

    .dominoes {
        gap: 12px;
        padding: 8px;
        justify-content: center;
        flex-wrap: wrap;
    }

    .domino.vertical {
        width: 50px;
        height: 100px;
    }

    .domino.horizontal {
        width: 100px;
        height: 50px;
    }

    .domino-half {
        padding: 3px;
    }

    .dot {
        width: 6px;
        height: 6px;
    }

    .region-marker {
        width: 50px;
        height: 50px;
        font-size: 16px;
    }

    .controls {
        flex-direction: row;
        gap: 10px;
        margin-bottom: 10px;
        justify-content: center;
    }

    button {
        width: 120px;
        padding: 10px 16px;
        font-size: 14px;
        min-height: 44px;
    }

    .status {
        padding: 8px 12px;
        font-size: 14px;
        margin-bottom: 10px;
    }
}

/* Animations */
@keyframes successPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

@keyframes errorShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-2px); }
    75% { transform: translateX(2px); }
}

/* Success and error feedback */
.domino.success {
    animation: successPulse 0.5s ease-in-out;
}

.slot-half.condition-met {
    box-shadow: inset 0 0 8px rgba(34, 197, 94, 0.8);
    border-color: #22c55e;
    animation: successPulse 0.6s ease-in-out;
}

.slot-half.condition-failed {
    box-shadow: inset 0 0 8px rgba(239, 68, 68, 0.8);
    border-color: #ef4444;
    animation: errorShake 0.6s ease-in-out;
}

/* Drag and drop states */
.domino.dragging {
    opacity: 0.6;
    transform: scale(1.05);
    z-index: 1000;
    pointer-events: none;
}

.slot.drop-zone-valid {
    background: rgba(34, 197, 94, 0.15) !important;
    border-color: #22c55e;
    box-shadow: 0 0 16px rgba(34, 197, 94, 0.6);
    transform: scale(1.05);
}

.slot.drop-zone-invalid {
    background: rgba(239, 68, 68, 0.15) !important;
    border-color: #ef4444;
    box-shadow: 0 0 16px rgba(239, 68, 68, 0.6);
    transform: scale(0.95);
}

.drag-clone {
    opacity: 0.8;
    transform: scale(1.1);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}
