:root {
    --bg-color: #f0f2f5;
    --text-color: #333;
    --primary-color: #4a90e2;
    --red-player: #e74c3c;
    --blue-player: #3498db;
    --dot-color: #2c3e50;
    --line-inactive: #e0e0e0;
    --line-hover: #bdc3c7;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

#app {
    width: 100%;
    max-width: 600px;
    padding: 20px;
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    position: relative;
    overflow: hidden;
}

.screen {
    display: none;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.screen.active {
    display: flex;
}

h1 {
    margin-bottom: 30px;
    color: var(--dot-color);
}

.form-group {
    width: 100%;
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
}

select, input[type="range"] {
    width: 100%;
    padding: 10px;
    border-radius: 5px;
    border: 1px solid #ddd;
}

.range-control {
    display: flex;
    align-items: center;
    gap: 15px;
}

.radio-group {
    display: flex;
    gap: 20px;
}

.radio-group label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-weight: normal;
    cursor: pointer;
}

button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 8px;
    font-size: 1.1em;
    cursor: pointer;
    transition: background 0.2s;
    margin-top: 10px;
}

button:hover {
    background-color: #357abd;
}

/* Game Board */
.header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.scoreboard {
    display: flex;
    justify-content: space-around;
    width: 100%;
    margin-bottom: 20px;
    font-size: 1.2em;
    font-weight: bold;
}

.player-score.player-red { color: var(--red-player); }
.player-score.player-blue { color: var(--blue-player); }
.player-score.active { text-decoration: underline; transform: scale(1.1); transition: transform 0.2s; }

#game-board-container {
    display: flex;
    justify-content: center;
    padding: 20px;
    background: #fafafa;
    border-radius: 10px;
}

.game-board {
    display: grid;
    /* Grid template will be set via JS */
}

.dot {
    width: 12px;
    height: 12px;
    background-color: var(--dot-color);
    border-radius: 50%;
    z-index: 2;
}

.h-line, .v-line {
    background-color: var(--line-inactive);
    transition: background-color 0.2s;
    position: relative;
    cursor: pointer;
}

.h-line {
    height: 12px; /* same as dot size for easy grid alignment, but visual line is thinner */
    width: 100%;
}

.h-line::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    height: 4px; /* Visual thickness */
    background-color: inherit;
    transform: translateY(-50%);
    border-radius: 2px;
}

.v-line {
    width: 12px;
    height: 100%;
}

.v-line::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 0;
    width: 4px; /* Visual thickness */
    height: 100%;
    background-color: inherit;
    transform: translateX(-50%);
    border-radius: 2px;
}

.h-line:not(.taken):hover, .v-line:not(.taken):hover {
    background-color: var(--line-hover);
}

.h-line.taken.red, .v-line.taken.red { background-color: var(--red-player); }
.h-line.taken.blue, .v-line.taken.blue { background-color: var(--blue-player); }

.box {
    width: 100%;
    height: 100%;
    border-radius: 5px;
}

@keyframes pop {
    0% { transform: scale(0.8); opacity: 0.5; }
    100% { transform: scale(1); opacity: 1; }
}

.box.red { 
    background-color: rgba(231, 76, 60, 0.3); 
    animation: pop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.box.blue { 
    background-color: rgba(52, 152, 219, 0.3); 
    animation: pop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    justify-content: center;
    align-items: center;
    z-index: 10;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 10px;
    text-align: center;
}

#winner-text {
    margin-bottom: 20px;
    color: var(--dot-color);
}
