﻿body {
    margin: 0;
    font-family: "Helvetica", "Verdana", "Roboto", sans-serif;
}

h1 {
    margin: 0 0 15px;
    padding: 15px;
    color: #fff;
    font-size: 40px;
    font-weight: normal;
    text-align: center;
    background-color: chocolate;
}

form {
    display: flex;
    flex-flow: column nowrap;
    align-items: center;
}

.board {
    position: relative;
    width: 450px;
    height: 450px;
    margin-top:22px;
}

.field {
    position: absolute;
    top: 0;
    left: 15px;
    padding: 75px 0 0 0;
    box-sizing: border-box;
    width: 420px;
    height: 435px;
    overflow: hidden;
    cursor: not-allowed;
}

.grid {
    display: inline-flex;
    flex-flow: column wrap;
    position: relative;
    min-width: 420px;
    height: 360px;
    counter-reset: player 1;
}

.column {
    display: inline-flex;
    flex-flow: column wrap;
    height: 360px;
}

.front {
    position: absolute;
    top: 60px;
    border: 15px solid #DB874B;
    border-radius: 4px;
    box-sizing: border-box;
    width: 450px;
    height: 390px;
    pointer-events: none;
    background: radial-gradient(circle, transparent, transparent 18px, chocolate 20px, chocolate 23px, chocolate 23px, chocolate 36px, chocolate) center top/60px 60px;
}

/* Invisible inputs */
input {
    display: none;
    position: absolute;
    top: -90px;
    margin: 0;
    width: 60px;
    height: 450px;
    cursor: pointer;
    opacity: 0;
}

    input:indeterminate {
        display: initial;
    }
/* Inputs for red */
.column > input:nth-of-type(2n) {
    right: 360px;
}

.column > .column > input:nth-of-type(2n) {
    right: 300px;
}

.column > .column > .column > input:nth-of-type(2n) {
    right: 240px;
}

.column > .column > .column > .column > input:nth-of-type(2n) {
    right: 180px;
}

.column > .column > .column > .column > .column > input:nth-of-type(2n) {
    right: 120px;
}

.column > .column > .column > .column > .column > .column > input:nth-of-type(2n) {
    right: 60px;
}

.column > .column > .column > .column > .column > .column > .column > input:nth-of-type(2n) {
    right: 0;
}
/* Inputs for Blue */
.column > input:nth-of-type(2n+1) {
    left: 0;
}

.column > .column > input:nth-of-type(2n+1) {
    left: 60px;
}

.column > .column > .column > input:nth-of-type(2n+1) {
    left: 120px;
}

.column > .column > .column > .column > input:nth-of-type(2n+1) {
    left: 180px;
}

.column > .column > .column > .column > .column > input:nth-of-type(2n+1) {
    left: 240px;
}

.column > .column > .column > .column > .column > .column > input:nth-of-type(2n+1) {
    left: 300px;
}

.column > .column > .column > .column > .column > .column > .column > input:nth-of-type(2n+1) {
    left: 360px;
}

/* Disc */
.disc {
    position: relative;
    top: 0;
    width: 60px;
    height: 60px;
    color: #fff;
    background: radial-gradient(circle, currentcolor 12px, #666 13px, currentcolor 14px, currentcolor 21px, #666 22px, transparent 23px, transparent) center/60px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s, top 0s 0.2s, color 0s 0.2s;
}

/* Red's turn */
input:hover + .disc {
    color: #ff010b;
    opacity: 1;
    transition: opacity 0.2s, top 0s;
}

input:checked + .disc {
    color: #ff010b;
    opacity: 1;
}
/* Blue's turn */
input:hover + input + .disc {
    color: Blue;
    opacity: 1;
    transition: opacity 0.2s, top 0s;
}

input:checked + input + .disc {
    color: Blue;
    opacity: 1;
}

/* Height and time of disc fall per row */
input:hover + .disc:nth-of-type(1),
input:hover + input + .disc:nth-of-type(1) {
    top: -75px;
}

input:checked + .disc:nth-of-type(1),
input:checked + input + .disc:nth-of-type(1) {
    transition: top 0.14s cubic-bezier(0.56, 0, 1, 1);
}

input:hover + .disc:nth-of-type(2),
input:hover + input + .disc:nth-of-type(6n+2) {
    top: -135px;
}

input:checked + .disc:nth-of-type(2),
input:checked + input + .disc:nth-of-type(2) {
    transition: top 0.19s cubic-bezier(0.56, 0, 1, 1);
}

input:hover + .disc:nth-of-type(3),
input:hover + input + .disc:nth-of-type(3) {
    top: -195px;
}

input:checked + .disc:nth-of-type(3),
input:checked + input + .disc:nth-of-type(3) {
    transition: top 0.23s cubic-bezier(0.56, 0, 1, 1);
}

input:hover + .disc:nth-of-type(4),
input:hover + input + .disc:nth-of-type(4) {
    top: -255px;
}

input:checked + .disc:nth-of-type(4),
input:checked + input + .disc:nth-of-type(4) {
    transition: top 0.26s cubic-bezier(0.56, 0, 1, 1);
}

input:hover + .disc:nth-of-type(5),
input:hover + input + .disc:nth-of-type(5) {
    top: -315px;
}

input:checked + .disc:nth-of-type(5),
input:checked + input + .disc:nth-of-type(5) {
    transition: top 0.29s cubic-bezier(0.56, 0, 1, 1);
}

input:hover + .disc:nth-of-type(6n),
input:hover + input + .disc:nth-of-type(6n) {
    top: -375px;
}

input:checked + .disc:nth-of-type(6n),
input:checked + input + .disc:nth-of-type(6n) {
    transition: top 0.32s cubic-bezier(0.56, 0, 1, 1);
}

/* Fix stuck disc */
input:checked + .disc,
input:checked + input + .disc {
    top: 0 !important;
}

/* Tracking turns */
input:checked + .disc {
    counter-increment: player 2;
}

input:checked + input + .disc {
    counter-increment: player -2;
}

.grid::after {
    content: counter(player, lower-roman);
    display: inline-block;
    max-width: 840px;
    min-width: 420px;
    letter-spacing: 375px;
    font-family: monospace;
    font-size: 1px;
    overflow: hidden;
}

/* Draw outcome */
form:valid .column > .column > .column > .column > .column > .column > .column > .column::after {
    content: "It's a draw !!";
    z-index: 1;
    position: absolute;
    left: 0;
    top: -75px;
    width: 420px;
    height: 435px;
    visibility: visible;
    color: chocolate;
    font-size: 55px;
    text-align: center;
    line-height: 60px;
    cursor: initial;
    pointer-events: auto;
    animation: outcome 1.5s;
    margin-top: -8px;
}

/* Red column win */
input:checked + .disc + input + input:checked + .disc + input + input:checked + .disc + input + input:checked ~ .column::after,
/* Red row win */
input:nth-of-type(2):checked ~ .column > input:nth-of-type(2):checked ~ .column > input:nth-of-type(2):checked ~ .column > input:nth-of-type(2):checked ~ .column::after,
input:nth-of-type(4):checked ~ .column > input:nth-of-type(4):checked ~ .column > input:nth-of-type(4):checked ~ .column > input:nth-of-type(4):checked ~ .column::after,
input:nth-of-type(6):checked ~ .column > input:nth-of-type(6):checked ~ .column > input:nth-of-type(6):checked ~ .column > input:nth-of-type(6):checked ~ .column::after,
input:nth-of-type(8):checked ~ .column > input:nth-of-type(8):checked ~ .column > input:nth-of-type(8):checked ~ .column > input:nth-of-type(8):checked ~ .column::after,
input:nth-of-type(10):checked ~ .column > input:nth-of-type(10):checked ~ .column > input:nth-of-type(10):checked ~ .column > input:nth-of-type(10):checked ~ .column::after,
input:nth-of-type(12):checked ~ .column > input:nth-of-type(12):checked ~ .column > input:nth-of-type(12):checked ~ .column > input:nth-of-type(12):checked ~ .column::after,
/* Red diagonal win */
input:nth-of-type(2):checked ~ .column > input:nth-of-type(4):checked ~ .column > input:nth-of-type(6):checked ~ .column > input:nth-of-type(8):checked ~ .column::after,
input:nth-of-type(4):checked ~ .column > input:nth-of-type(6):checked ~ .column > input:nth-of-type(8):checked ~ .column > input:nth-of-type(10):checked ~ .column::after,
input:nth-of-type(6):checked ~ .column > input:nth-of-type(8):checked ~ .column > input:nth-of-type(10):checked ~ .column > input:nth-of-type(12):checked ~ .column::after,
input:nth-of-type(8):checked ~ .column > input:nth-of-type(6):checked ~ .column > input:nth-of-type(4):checked ~ .column > input:nth-of-type(2):checked ~ .column::after,
input:nth-of-type(10):checked ~ .column > input:nth-of-type(8):checked ~ .column > input:nth-of-type(6):checked ~ .column > input:nth-of-type(4):checked ~ .column::after,
input:nth-of-type(12):checked ~ .column > input:nth-of-type(10):checked ~ .column > input:nth-of-type(8):checked ~ .column > input:nth-of-type(6):checked ~ .column::after {
    content: "Red wins !! :";
    z-index: 2;
    position: absolute;
    left: 0;
    top: -75px;
    width: 420px;
    height: 435px;
    visibility: visible;
    color: #ff010b;
    font-size: 55px;
    text-align: center;
    line-height: 60px;
    cursor: initial;
    pointer-events: auto;
    animation: outcome 1s;
    margin-top:-8px;
}

/* Blue column win */
input:checked + input + .disc + input:checked + input + .disc + input:checked + input + .disc + input:checked ~ .column::after,
/* Blue row win */
input:nth-of-type(1):checked ~ .column > input:nth-of-type(1):checked ~ .column > input:nth-of-type(1):checked ~ .column > input:nth-of-type(1):checked ~ .column::after,
input:nth-of-type(3):checked ~ .column > input:nth-of-type(3):checked ~ .column > input:nth-of-type(3):checked ~ .column > input:nth-of-type(3):checked ~ .column::after,
input:nth-of-type(5):checked ~ .column > input:nth-of-type(5):checked ~ .column > input:nth-of-type(5):checked ~ .column > input:nth-of-type(5):checked ~ .column::after,
input:nth-of-type(7):checked ~ .column > input:nth-of-type(7):checked ~ .column > input:nth-of-type(7):checked ~ .column > input:nth-of-type(7):checked ~ .column::after,
input:nth-of-type(9):checked ~ .column > input:nth-of-type(9):checked ~ .column > input:nth-of-type(9):checked ~ .column > input:nth-of-type(9):checked ~ .column::after,
input:nth-of-type(11):checked ~ .column > input:nth-of-type(11):checked ~ .column > input:nth-of-type(11):checked ~ .column > input:nth-of-type(11):checked ~ .column::after,
/* Blue diagonal win */
input:nth-of-type(1):checked ~ .column > input:nth-of-type(3):checked ~ .column > input:nth-of-type(5):checked ~ .column > input:nth-of-type(7):checked ~ .column::after,
input:nth-of-type(3):checked ~ .column > input:nth-of-type(5):checked ~ .column > input:nth-of-type(7):checked ~ .column > input:nth-of-type(9):checked ~ .column::after,
input:nth-of-type(5):checked ~ .column > input:nth-of-type(7):checked ~ .column > input:nth-of-type(9):checked ~ .column > input:nth-of-type(11):checked ~ .column::after,
input:nth-of-type(7):checked ~ .column > input:nth-of-type(5):checked ~ .column > input:nth-of-type(3):checked ~ .column > input:nth-of-type(1):checked ~ .column::after,
input:nth-of-type(9):checked ~ .column > input:nth-of-type(7):checked ~ .column > input:nth-of-type(5):checked ~ .column > input:nth-of-type(3):checked ~ .column::after,
input:nth-of-type(11):checked ~ .column > input:nth-of-type(9):checked ~ .column > input:nth-of-type(7):checked ~ .column > input:nth-of-type(5):checked ~ .column::after {
    content: "Blue wins !! :";
    z-index: 2;
    position: absolute;
    left: 0;
    top: -75px;
    width: 420px;
    height: 435px;
    visibility: visible;
    color: Blue;
    font-size: 55px;
    text-align: center;
    line-height: 60px;
    background: linear-gradient(#fff 60px, transparent 60px, transparent);
    cursor: initial;
    pointer-events: auto;
    animation: outcome 1s;
    margin-top: -8px;
}

/* Button style */
button {
    margin: 20px auto;
    border: none;
    border-radius: 2px;
    padding: 12px 18px;
    font-size: 16px;
    text-transform: uppercase;
    cursor: pointer;
    color: #fff;
    background: chocolate center;
    box-shadow: 0 0 4px chocolate;
    outline: none;
    transition: background 0.5s;
}

    button:hover {
        background: chocolate radial-gradient(circle, transparent 1%, chocolate 1%) center/15000%;
    }

    button:active {
        background-color: chocolate;
        background-size: 100%;
        transition: background 0s;
    }

@keyframes outcome {
    0% {
        opacity: 0;
    }

    35% {
        opacity: 0;
    }

    100% {
        opacity: 1;
    }
}

@media screen and (max-width: 1000px) {
    form{
        margin-top:100px;
    }

    h1{
        font-size:63px;
        padding:53px;
    }

    button{
        font-size:68px;
        margin-top:172px;
        padding:40px;
    }
}