* {
    font-family: "Nunito", system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
}

:root {
    --background-color: 26, 35, 59;
    --default-color: 43, 61, 94;
    --navy-blue: 16, 20, 49;

    --red: 242, 14, 74;
    --cyan: 13, 223, 242;
    --yellow: 241, 176, 55;
    --light-gray: 168, 190, 201;

    --rounded-border: 12px;
    --edge-height: 0.6rem;
}

/* Element selectors */

body {
    background-color: rgb(var(--background-color));
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

button {
    padding: 0;
    border: none;
    -webkit-tap-highlight-color: transparent;
}

button:hover {
    cursor: pointer;
}

input:-webkit-autofill {
    background-color: transparent !important; /* Removes autofill background */
    -webkit-box-shadow: 0 0 0px 1000px rgb(var(--yellow)) inset !important; /* Forces a white background */
  }

/* utility classes */

.base {
    position: relative;
}

.surface {
    
    position: relative;
    background-color: rgb(var(--surface-color));
    box-shadow: inset 0 0 2px 0 rgba(255, 255, 255, 0.2),
                inset 0 1px 2px 0 rgba(255, 255, 255, 0.3);
    border: 2px solid rgba(0, 0, 0, 0.3);
    border-radius: var(--rounded-border);
    width: 100%;
    height: 100%;
    transform: translateY(calc(var(--edge-height) / -2));
    transition:
      transform
      600ms
      cubic-bezier(.3, .7, .4, 1);
}

.edge {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgb(var(--surface-color));
    background-image: linear-gradient(
        to right, 
        rgba(0, 0, 0, 0.5) 0%, 
        rgba(0, 0, 0, 0.25) 8%, 
        rgba(0, 0, 0, 0.25) 92%,
        rgba(0, 0, 0, 0.5) 100%);
    padding: 0 0 0.6rem;
    border: 2px solid rgba(0, 0, 0, 0.5);
    border-radius: var(--rounded-border);
}

.shadow {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: var(--rounded-border);
    background: rgba(0, 0, 0, 0.25);
    transform: translateY(5px);
    filter: blur(3px);
    transition:
      transform
      600ms
      cubic-bezier(.3, .7, .4, 1);
}

button:hover .surface {
    transform: translateY(calc(var(--edge-height) * -1));
    transition: transform 250ms cubic-bezier(.3, .7, .4, 1.5);
}

button:active .surface {
    transform: translateY(-2px);
    transition: transform 34ms;
}

button:hover .shadow {
    transform: translateY(8px);
    transition: transform 250ms cubic-bezier(0.3, 0.7, 0.4, 1.5);
}

button:active .shadow {
    transform: translateY(1px);
    background: rgb(var(--yellow));
    transition: transform 34ms;
}

/* element classes */

body > .main-container {
    height: 100vh;
    z-index: 2;
}

.main-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4rem;
    padding: 1.5rem;
    width: min(350px, 100%);
}

.scoreboard {
    --surface-color: var(--default-color);
    width: 100%;
    border-radius: var(--rounded-border);
    box-shadow: 0 0 1px 2px rgb(var(--yellow)),
                0 calc(var(--edge-height) / -2) 1px 2px rgb(var(--yellow));
}

.scoreboard-icon {
    width: 1.6rem;
}

.scoreboard-icon.o-icon {
    transform: scale(1.1)
               translateY(-5%);
}

.scoreboard .surface {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: auto 1fr;
    row-gap: 0.2rem;
    padding: 0.5rem;

    transform: translateY(calc(var(--edge-height) / -2));
}

.scoreboard-header {
    text-align: center;
    text-shadow: 0 1px 1px rgba(255, 255, 255, 0.40),
                 0 -1px 1px rgba(0, 0, 0, 0.50);
    color: rgb(var(--yellow));
    font-weight: 900;
    overflow: hidden;
    text-overflow: ellipsis;
}

.scoreboard-screen {
    position: relative;
    grid-column: span 3;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    overflow: hidden;
    width: 100%;
    aspect-ratio: 5 / 2;
    border-radius: 10px;
    background-color: rgb(var(--navy-blue));
}

.scoreboard-screen * {
    color: white;
}

.slide-screen {
    position: absolute;
    width: 100%;
    height: 100%;
    transition: transform 0.5s ease-in-out;
}

.screen-edge {
    position: absolute;
    top: 0;
    width: 100%;
    height: 100%;
    box-shadow: inset 0 0 4px 10px rgb(var(--navy-blue));
    pointer-events: none;
}

.tally-screen {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    grid-template-rows: 1fr 1fr;
    grid-auto-flow: column;
    column-gap: 1rem;
    row-gap: 0.5rem;

    padding: 0.5rem 0;
}

.game-over-screen {
    top: -120%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;

    font-family: "Teko", system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
}

.cpu-thinking-screen {
    top: 120%;
    display: flex;
    justify-content: center;
    align-items: center;
}

#screen-message {
    font-family: "Teko", system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    font-size: 2rem;
}

.game-over-screen * {
    font-family: inherit;
}

#game-over-message {
    font-size: 2rem;
    margin: -0.2rem;
}

#next-round-button {
    font-size: 1.5rem;
    background: none;
    color: rgb(var(--yellow));
    padding: 0 1rem;
    border: 2px solid rgb(var(--yellow));
    border-radius: 5px;
    transition: all 0.3s ease;
}

#next-round-button:hover {
    box-shadow: 0px 0px 8px rgb(var(--yellow));
    filter: brightness(110%);
    transition: all 0.3s ease;
}

#next-round-button:active {
    box-shadow: none;
}

.score-container {
    grid-row: span 3;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0 0;
}

.score {
    font-family: "Teko", system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    font-size: 4rem;
    margin: -1rem;
}

.info-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.5rem;
    align-items: center;
}

.info-label {
    font-size: 0.8rem;
}

.info {
    font-family: "Teko", system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    font-size: 1.5rem;
    font-weight: bold;
    margin: -0.8rem;
}

.tile-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.2rem;
    row-gap: 2rem;
    width: 100%;
}

.tile {
    --surface-color: var(--default-color);
    aspect-ratio: 10 / 9;
    border: none;
    border-radius: var(--rounded-border);
    background: none;
}

.tile .surface {
    height: 100%;
    display: grid;
    place-content: center;
}

.tile-icon {
    display: none;
    width: 2.5rem;
    filter: drop-shadow(0 1px 0 rgba(255, 255, 255, 0.4))
            drop-shadow(0 -1px 0 rgba(0, 0, 0, 0.8));
}

.red-surface {
    --surface-color: var(--red);
    box-shadow: 0 0 10px  rgb(var(--red), 0.25);
}

.cyan-surface {
    --surface-color: var(--cyan);
    box-shadow: 0 0 10px  rgb(var(--cyan), 0.15);
}

.x-icon {
    fill: rgb(var(--red));
}

.o-icon {
    fill: rgb(var(--cyan));
}

.dark-icon {
    fill: rgb(var(--navy-blue));
}

#quit-button {
    --surface-color: var(--light-gray);
}

#reset-button {
    --surface-color: var(--yellow);
}

.button-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    width: 100%;
    height: 4rem;
}

.action-button {
    align-items: center;
    background: none;
    border-radius: var(--rounded-border);
}

.action-button .surface {
    display: flex;
    justify-content: center;
    align-items: center;
}

.button-text {
    font-family: "Nunito", system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    font-size: 1.3rem;
    font-weight: 800;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.60),
                 0 -1px 0 rgba(0, 0, 0, 0.50);
    color: rgb(var(--navy-blue));
}

dialog {
    width: 100vw;
    height: 100vh;
    z-index: 100;
    background-color: rgb(var(--background-color));
    border: none;
    padding: 0;
    margin: 0;
    position: fixed;
    top: 0;
    left: 0;
}

dialog > .main-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    height: 100vh;
    text-align: center;
}

.mark-menu {
    --surface-color: var(--default-color);
    border-radius: var(--rounded-border);
    box-shadow: 0 0 1px 2px rgb(var(--yellow)),
                0 calc(var(--edge-height) / -2) 1px 2px rgb(var(--yellow));
    width: 100%;
}

.mark-menu .surface {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto auto;
    column-gap: 1.5rem;
    row-gap: 0.5rem;
    width: 100%;
    padding: 0.8rem 1.5rem 0.5rem;
}

.menu-label, .first-move-reminder {
    grid-column: span 2;
    text-align: center;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.5);
}

.first-move-reminder {
    height: 1.5rem;
    font-size: 0.8rem;
    font-weight: 400;
    display: flex;
    justify-content: center;
    align-items: end;
}

.option {
    display: flex;
    justify-content: center;

    background-color: rgb(var(--navy-blue));
    aspect-ratio: 1;
    border-radius: 10px;
}

.option-icon {
    width: 35%;
    fill: #98B0DD;
    transition: all 0.2s ease;
}

.option:hover .option-icon {
    filter: drop-shadow(0 0 2px rgb(var(--yellow))) 
            brightness(130%);
}

.logo {
    width: 4rem;
    aspect-ratio: 1;
    margin: -1rem;
}

.new-game-buttons-container {
    display: flex;
    width: 100%;
    flex-direction: column;
    gap: 2rem;
}

.new-game-button {
    width: 100%;
    background: none;
}

.new-game-button .surface {
    font-size: 1.2rem;
    font-weight: 900;
    text-shadow: 0 1px 1px rgba(255, 255, 255, 0.7),
                 0 -1px 1px black;
    padding: 1rem;
    color: rgb(var(--navy-blue));
}

.new-game-cpu {
    --surface-color: var(--cyan);
}

.new-game-player {
    --surface-color: var(--red);
}

.name-form {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 3rem;
    --surface-color: var(--default-color);
}

.form-card {
    border-radius: var(--rounded-border);
    box-shadow: 0 0 1px 2px rgb(var(--yellow)),
                0 calc(var(--edge-height) / -2) 1px 2px rgb(var(--yellow));
}

.form-card .surface{
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem 1.8rem 2rem;
    gap: 1rem;
}

.name-form label {
    width: 100%;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.5);
    display: flex;
    flex-direction: column;
    justify-content: center;
    text-align: center;
    gap: 0.5rem;
}

.name-form input {
    color: white;
    border: none;
    border-radius: 10px;
    padding: 0.8rem 1rem;
    background-color: rgb(var(--navy-blue));
    transition: box-shadow 0.5s ease;
}

.name-form input:hover {
    box-shadow: inset 0 3px 2px rgba(0, 0, 0, 0.5),
                0 1px 2px rgba(255, 255, 255, 0.3);
    transition: box-shadow 300ms ease;
}

.name-form input:focus-visible {
    outline: none;
    outline: 2px solid rgba(var(--yellow), 0.489);
}

button[type="submit"] {
    background: none;
}

button[type="submit"] .surface {
    font-size: 1.2rem;
    font-weight: 900;
    text-shadow: 0 1px 1px rgba(255, 255, 255, 0.7),
                 0 -1px 1px black;
    padding: 1rem;
    color: rgb(var(--navy-blue));
}

/* state classes */

.red {
    fill: rgb(var(--red));
    color: rgb(var(--red));
}

.cyan {
    fill: rgb(var(--cyan));
    color: rgb(var(--cyan));
}

.selected-option {
    box-shadow: inset 0 0 2px 3px rgb(var(--yellow));
    transition: all 10ms ease;
}

.selected-option svg {
    filter: brightness(130%);
}

#credit {
    position: absolute;
    display: flex;
    align-items: center;
    gap: 6px;
    justify-content: center;
    bottom: 1.5rem;
    color: rgb(var(--yellow));
}

#credit img {
    width: 1rem;
}

#credit a {
    font-size: inherit;
    font-family: inherit;
    color: inherit;
    text-decoration: none;
}


#credit a:hover {
    filter: brightness(110);
    transition: all 0.5s ease;
}

@media (hover: none) and (pointer: coarse) {

    @keyframes click {
        0%, 100% {
            transform: translateY(calc(var(--edge-height) / -1));
        }

        10% {
            transform: translateY(-2px);
        }
    }

    button .surface {
        transform: translateY(calc(var(--edge-height) / -1));
    }

    .tile:hover .surface {
        transition: unset;
        transform: translateY(calc(var(--edge-height) / -1));
    }

    .tile:active .surface {
        animation: click 0.6s;
    }
}