:root {
    --bg-color: #e0e0e0;
    --board-chassis: #f5f5f5;
    --quadrant-red: #d32f2f;
    --hole-dark: #b71c1c;
    --text-color: #333;
    --primary-color: #1976d2;
    --primary-hover: #1565c0;
    --secondary-bg: #f5f5f5;
    --input-border: #ccc;
    --focus-color: #1976d2;
}

body {
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
}

.container {
    text-align: center;
    background: white;
    padding: 2rem;
    border-radius: 20px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    max-width: 650px;
    width: 90%;
    margin-top: -20px;
    transition: max-width 0.3s ease;
}

h1 {
    margin-bottom: 1rem;
    color: #333;
    font-weight: 700;
    margin-top: 0;
    font-size: 2rem;
}

/* Tabs Styling */
.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    justify-content: center;
    background: #f0f0f0;
    padding: 5px;
    border-radius: 12px;
    display: inline-flex;
}

.tab-btn {
    padding: 10px 20px;
    border: none;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    color: #666;
    transition: all 0.2s ease;
    font-size: 1rem;
}

.tab-btn.active {
    background: white;
    color: var(--primary-color);
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.tab-btn:hover:not(.active) {
    background: rgba(255,255,255,0.5);
    color: #333;
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

.game-info {
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
    font-weight: 500;
}

.player-1 { color: #000; font-weight: bold; }
.player-2 { color: #d32f2f; font-weight: bold; }

.board-container {
    position: relative;
    width: 100%;
    max-width: 480px;
    aspect-ratio: 1 / 1;
    height: auto;
    margin: 0 auto 2rem;
}

/* Board & Pieces (Keeping original polished look) */
.pentago-board {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    background-color: var(--board-chassis);
    padding: 12px;
    border-radius: 16px;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    box-shadow: 
        0 8px 16px rgba(0,0,0,0.15),
        inset 0 1px 1px rgba(255,255,255,0.8);
    border: 1px solid #ccc;
}

.quadrant {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 6px;
    background-color: var(--quadrant-red);
    padding: 6px;
    border-radius: 8px;
    transition: transform 0.5s cubic-bezier(0.4, 0.0, 0.2, 1);
    box-shadow: 
        0 2px 4px rgba(0,0,0,0.2),
        inset 0 1px 1px rgba(255,255,255,0.3);
}

.cell {
    background-color: var(--hole-dark);
    border-radius: 50%;
    cursor: pointer;
    position: relative;
    width: 100%;
    height: 100%;
    box-shadow: 
        inset 2px 2px 5px rgba(0,0,0,0.6), 
        inset -1px -1px 2px rgba(255,255,255,0.1);
}

.cell::after {
    content: '';
    display: block;
    padding-bottom: 100%;
}

.cell.p1 {
    background-color: #333;
    background: radial-gradient(circle at 35% 35%, #666, #000);
    box-shadow: 2px 2px 5px rgba(0,0,0,0.5), inset 1px 1px 1px rgba(255,255,255,0.3);
    border: none;
    transform: scale(0.95);
    z-index: 2;
}

.cell.p2 {
    background-color: #f5f5f5;
    background: radial-gradient(circle at 35% 35%, #fff, #e0e0e0 40%, #bdbdbd 100%);
    box-shadow: 2px 2px 5px rgba(0,0,0,0.4), inset 1px 1px 1px rgba(255,255,255,0.8);
    border: none;
    transform: scale(0.95);
    z-index: 2;
}

.cell:hover:not(.p1):not(.p2) {
    background-color: #c62828;
    box-shadow: inset 2px 2px 5px rgba(0,0,0,0.7);
}

.rotation-controls {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.rotation-controls.hidden {
    display: none;
}

.rotate-btn {
    position: absolute;
    width: 36px;
    height: 36px;
    font-size: 18px;
    background: rgba(255, 255, 255, 0.4);
    color: #333;
    border: none;
    border-radius: 50%;
    opacity: 0.8;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-bottom: 2px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    cursor: pointer;
    pointer-events: auto;
    transition: all 0.2s ease;
    backdrop-filter: blur(2px);
}

.rotate-btn:hover {
    transform: scale(1.1);
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
    color: #d32f2f;
    opacity: 1;
}

.rotate-btn:disabled {
    opacity: 0.1;
    cursor: not-allowed;
    background: transparent;
    box-shadow: none;
}

.rotate-btn[data-q="0"] { top: 25.83%; left: 25.83%; margin-top: -18px; margin-left: -18px; }
.rotate-btn[data-q="1"] { top: 25.83%; left: 74.17%; margin-top: -18px; margin-left: -18px; }
.rotate-btn[data-q="2"] { top: 74.17%; left: 25.83%; margin-top: -18px; margin-left: -18px; }
.rotate-btn[data-q="3"] { top: 74.17%; left: 74.17%; margin-top: -18px; margin-left: -18px; }

/* Improved Controls & Inputs */
.controls {
    display: flex;
    flex-direction: column;
    gap: 15px;
    max-width: 400px;
    margin: 0 auto;
}

.game-settings, .player-names {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.setting-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

label {
    font-weight: 500;
    color: #555;
    font-size: 0.95rem;
}

input[type="text"], select {
    padding: 8px 12px;
    border: 1px solid var(--input-border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.95rem;
    transition: all 0.2s;
    outline: none;
    background: #fff;
}

input[type="text"]:focus, select:focus {
    border-color: var(--focus-color);
    box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.1);
}

input[type="text"]:disabled {
    background: #f5f5f5;
    color: #888;
}

/* Button Styles */
.primary-btn, .secondary-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    font-size: 1rem;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.primary-btn {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 4px 6px rgba(25, 118, 210, 0.2);
}

.primary-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 8px rgba(25, 118, 210, 0.3);
}

.primary-btn:active {
    transform: translateY(0);
}

.secondary-btn {
    background: white;
    color: #333;
    border: 1px solid #ddd;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.secondary-btn:hover {
    background: #f8f8f8;
    border-color: #ccc;
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

/* Online Setup specific */
.online-setup {
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    padding: 20px;
    background: #f9f9f9;
    border-radius: 16px;
    border: 1px solid #eee;
}

.online-row {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.flex-row {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    width: 100%;
}

.flex-input {
    flex: 1;
    min-width: 0; /* Allow shrinking if needed, preventing overflow */
}

.flex-btn {
    white-space: nowrap;
}

.code-box {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 100px;
    padding: 10px 15px;
    border: 2px dashed #bbb;
    border-radius: 10px;
    font-weight: 700;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 1.2rem;
    letter-spacing: 2px;
    color: var(--primary-color);
    background: #fff;
    margin: 0;
    height: 44px; /* Match button height approx */
    box-sizing: border-box;
}

#online-status {
    margin-top: 10px;
    font-weight: 600;
    min-height: 24px;
    color: #666;
}

/* Responsive */
@media (max-width: 600px) {
    .container {
        padding: 1rem;
        width: 95%;
    }
    
    .pentago-board {
        gap: 8px;
        padding: 8px;
    }
    
    .quadrant {
        gap: 4px;
        padding: 4px;
    }
    
    .rotate-btn {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }
    
    h1 {
        font-size: 1.5rem;
    }
    
    .online-row:not(.flex-row) {
        flex-direction: column;
        width: 100%;
    }
    
    .online-row:not(.flex-row) input, 
    .online-row:not(.flex-row) select, 
    .online-row:not(.flex-row) button {
        width: 100%;
    }
}
