:root {
    --color-p1: #ef4444; /* Red */
    --color-p2: #3b82f6; /* Blue */
    --color-bg: #0f172a;
    --color-surface: #1e293b;
    --color-text: #f8fafc;
    --color-dot: #64748b;
    --color-line-empty: #334155;
    --color-line-hover: #475569;
    
    --dot-size: min(16px, 1.5vh);
    --box-size: min(60px, 6vh);
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--color-bg);
    color: var(--color-text);
    /* Prevent selection and scrolling on iPad */
    user-select: none;
    -webkit-user-select: none;
    overflow: hidden;
    touch-action: none; 
}

#app {
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.screen {
    display: none;
    width: 100%;
    height: 100%;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.screen.active {
    display: flex;
}

h1 {
    font-size: 3rem;
    font-weight: 800;
    margin-bottom: 2rem;
    text-align: center;
}

/* Setup Screen */
.setup-form {
    background: var(--color-surface);
    padding: 2rem;
    border-radius: 1rem;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
}

.input-group {
    margin-bottom: 1.5rem;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.p1-label { color: var(--color-p1); }
.p2-label { color: var(--color-p2); }

.input-group input {
    width: 100%;
    padding: 0.75rem;
    border-radius: 0.5rem;
    border: 2px solid var(--color-line-empty);
    background: var(--color-bg);
    color: var(--color-text);
    font-size: 1.1rem;
    font-family: 'Inter', sans-serif;
    outline: none;
    transition: border-color 0.2s;
}

.input-group input:focus {
    border-color: var(--color-dot);
}

.mode-buttons {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}

.mode-buttons .btn {
    flex: 1;
}

.btn {
    padding: 1rem;
    border: none;
    border-radius: 0.5rem;
    background: var(--color-text);
    color: var(--color-bg);
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s, background 0.2s;
    font-family: 'Inter', sans-serif;
}

.btn:active {
    transform: scale(0.95);
}

.btn:hover {
    background: #cbd5e1;
}

.btn-small {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    flex: none;
}

/* Game Screen */
#game-screen {
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 3rem;
}

.game-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

.powerup-bank {
    width: 150px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 1rem;
}

.powerup-btn {
    width: 100%;
    padding: 2rem 1rem;
    font-size: 1.25rem;
    font-weight: 800;
    text-align: center;
    border-radius: 1rem;
    border: none;
    cursor: pointer;
    opacity: 0.3;
    pointer-events: none;
    transition: all 0.3s ease;
    background: var(--color-surface);
    color: var(--color-text);
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
    display: none; 
}

.powerup-btn.visible {
    display: block;
}

.powerup-btn.active {
    opacity: 1;
    pointer-events: auto;
}

.powerup-btn.used {
    opacity: 0.1;
    pointer-events: none;
}

.p1-powerup.active {
    background: var(--color-p1);
    color: white;
    box-shadow: 0 0 20px var(--color-p1);
}

.p2-powerup.active {
    background: var(--color-p2);
    color: white;
    box-shadow: 0 0 20px var(--color-p2);
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 1rem 0;
}

.score-board {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-size: 1.5rem;
    font-weight: 800;
    background: var(--color-surface);
    border-bottom: 4px solid transparent;
    opacity: 0.5;
    transition: opacity 0.3s, border-color 0.3s;
}

.score-board.active-turn {
    opacity: 1;
}

.p1-score-board.active-turn { border-color: var(--color-p1); }
.p2-score-board.active-turn { border-color: var(--color-p2); }

.turn-indicator {
    font-size: 1.25rem;
    font-weight: 600;
}

.game-footer {
    padding: 1rem 0;
}

/* Grid */
.grid-container-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.grid-container {
    display: grid;
    /* 17 columns: 9 dots, 8 lines/boxes */
    grid-template-columns: repeat(8, var(--dot-size) var(--box-size)) var(--dot-size);
    grid-template-rows: repeat(8, var(--dot-size) var(--box-size)) var(--dot-size);
    gap: 0;
    background: var(--color-surface);
    padding: 2rem;
    border-radius: 1rem;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.dot {
    width: var(--dot-size);
    height: var(--dot-size);
    background-color: var(--color-dot);
    border-radius: 50%;
}

.line {
    background-color: var(--color-line-empty);
    cursor: pointer;
    transition: background-color 0.2s;
}

.line.horizontal {
    height: var(--dot-size);
    width: 100%;
}

.line.vertical {
    width: var(--dot-size);
    height: 100%;
}

.line:hover:not(.claimed) {
    background-color: var(--color-line-hover);
}

@keyframes claimP1 {
    0% { background-color: var(--color-p1); box-shadow: 0 0 15px var(--color-p1); }
    100% { background-color: white; box-shadow: 0 0 5px rgba(255,255,255,0.3); }
}

@keyframes claimP2 {
    0% { background-color: var(--color-p2); box-shadow: 0 0 15px var(--color-p2); }
    100% { background-color: white; box-shadow: 0 0 5px rgba(255,255,255,0.3); }
}

.line.claimed.p1 {
    animation: claimP1 1s forwards;
}

.line.claimed.p2 {
    animation: claimP2 1s forwards;
}

.line.claimed.arcade {
    background-color: white;
    box-shadow: 0 0 5px rgba(255,255,255,0.3);
}

.box {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 800;
    color: white;
}

.box.p1 {
    background-color: rgba(239, 68, 68, 0.2);
    color: var(--color-p1);
}

.box.p2 {
    background-color: rgba(59, 130, 246, 0.2);
    color: var(--color-p2);
}

/* Game Over Screen */
.final-scores {
    display: flex;
    gap: 3rem;
    margin-bottom: 3rem;
}

.score-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--color-surface);
    padding: 2rem 3rem;
    border-radius: 1rem;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    min-width: 200px;
}

.score-card .name {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 0.5rem;
}

.score-card .score {
    font-size: 4rem;
    font-weight: 800;
}

.p1-score-card {
    border-bottom: 8px solid var(--color-p1);
}

.p1-score-card .score {
    color: var(--color-p1);
}

.p2-score-card {
    border-bottom: 8px solid var(--color-p2);
}

.p2-score-card .score {
    color: var(--color-p2);
}

#winner-text {
    font-size: 4rem;
    text-shadow: 0 4px 10px rgba(0,0,0,0.5);
}


