* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --pink:   #ff6eb4;
    --purple: #a855f7;
    --blue:   #38bdf8;
    --yellow: #fbbf24;
    --green:  #34d399;
    --orange: #fb923c;
    --bg:     #fdf4ff;
}

body {
    font-family: 'Nunito', sans-serif;
    background: linear-gradient(135deg, #fdf4ff 0%, #eff6ff 50%, #f0fdf4 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.container {
    width: 100%;
    max-width: 640px;
    text-align: center;
}

.title {
    font-family: 'Fredoka One', cursive;
    font-size: clamp(1.8rem, 6vw, 3rem);
    background: linear-gradient(90deg, var(--pink), var(--purple), var(--blue));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 1.2rem;
    filter: drop-shadow(0 2px 4px rgba(168,85,247,0.2));
}

/* Settings */
.settings {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.8rem;
    flex-wrap: wrap;
    background: white;
    border-radius: 20px;
    padding: 1rem 1.2rem;
    box-shadow: 0 4px 20px rgba(168,85,247,0.12);
    margin-bottom: 1.2rem;
}

.setting-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
}

.setting-group label {
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--purple);
}

.counter {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.counter-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--pink), var(--purple));
    color: white;
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    line-height: 1;
    transition: transform 0.1s, box-shadow 0.1s;
    box-shadow: 0 2px 8px rgba(168,85,247,0.3);
}

.counter-btn:hover { transform: scale(1.1); }
.counter-btn:active { transform: scale(0.95); }

.counter span {
    font-family: 'Fredoka One', cursive;
    font-size: 1.4rem;
    color: #4b0082;
    min-width: 28px;
    display: inline-block;
}

.start-btn {
    background: linear-gradient(135deg, var(--green), var(--blue));
    color: white;
    border: none;
    border-radius: 50px;
    padding: 0.6rem 1.4rem;
    font-family: 'Fredoka One', cursive;
    font-size: 1.1rem;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(52,211,153,0.4);
    transition: transform 0.15s, box-shadow 0.15s;
}

.start-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(52,211,153,0.5); }
.start-btn:active { transform: translateY(0); }

/* Status */
.status {
    font-family: 'Fredoka One', cursive;
    font-size: clamp(1.1rem, 4vw, 1.5rem);
    color: #5b21b6;
    margin-bottom: 1rem;
    min-height: 2rem;
}

.x-color { color: var(--pink); }
.o-color { color: var(--blue); }

/* Board */
.board-wrap {
    display: flex;
    justify-content: center;
    margin-bottom: 1rem;
}

.board {
    display: grid;
    gap: 8px;
    background: linear-gradient(135deg, var(--purple), var(--pink));
    padding: 10px;
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(168,85,247,0.3);
}

.cell {
    background: white;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-family: 'Fredoka One', cursive;
    font-size: 2rem;
    transition: background 0.15s, transform 0.1s;
    user-select: none;
    aspect-ratio: 1;
    min-width: 48px;
    min-height: 48px;
}

.cell:hover:not(.taken) {
    background: #fdf4ff;
    transform: scale(1.05);
}

.cell.x {
    color: var(--pink);
    text-shadow: 0 2px 8px rgba(255,110,180,0.4);
}

.cell.o {
    color: var(--blue);
    text-shadow: 0 2px 8px rgba(56,189,248,0.4);
}

.cell.taken { cursor: default; }

.cell.winner {
    background: linear-gradient(135deg, var(--yellow), var(--orange));
    animation: pulse 0.5s ease infinite alternate;
}

@keyframes pulse {
    from { transform: scale(1); }
    to   { transform: scale(1.08); }
}

/* Restart */
.restart-btn {
    background: linear-gradient(135deg, var(--orange), var(--yellow));
    color: white;
    border: none;
    border-radius: 50px;
    padding: 0.7rem 1.8rem;
    font-family: 'Fredoka One', cursive;
    font-size: 1.1rem;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(251,146,60,0.4);
    transition: transform 0.15s;
    margin-top: 0.5rem;
}

.restart-btn:hover { transform: translateY(-2px); }

/* Overlay */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(90,20,120,0.55);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.overlay-box {
    background: white;
    border-radius: 28px;
    padding: 2.5rem 3rem;
    text-align: center;
    box-shadow: 0 20px 60px rgba(168,85,247,0.4);
    animation: popIn 0.35s cubic-bezier(0.34,1.56,0.64,1);
}

@keyframes popIn {
    from { transform: scale(0.5); opacity: 0; }
    to   { transform: scale(1);   opacity: 1; }
}

.overlay-emoji {
    font-size: 4rem;
    margin-bottom: 0.5rem;
    animation: bounce 0.6s ease infinite alternate;
}

@keyframes bounce {
    from { transform: translateY(0); }
    to   { transform: translateY(-12px); }
}

.overlay-msg {
    font-family: 'Fredoka One', cursive;
    font-size: 2rem;
    background: linear-gradient(90deg, var(--pink), var(--purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 1.2rem;
}

@media (max-width: 480px) {
    .settings { gap: 0.6rem; padding: 0.8rem; }
    .cell { min-width: 36px; min-height: 36px; font-size: 1.4rem; }
    .board { gap: 5px; padding: 7px; }
}
