html,
body {
  width: 100%;
  height: 100%;
  padding: 0;
  margin: 0;
  font-family: sans-serif;
}

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

#turn {
  max-width: 451px;
  max-height: 30px;
  width: 100%;
  height: 100%;
  position: relative;
  float: right;
  border-radius: 5px;
  border: 1px solid rgb(0, 0, 0);
  border-style: inset;
  text-align: center;
  padding: 5px 0 0 0;
  background: #fff;
  transition: .85s linear;
}

.turnhighlight {
  background: #5cb85c !important;
  color: #fff;
}

#game {
  max-width: 504px;
  max-height: 504px;
  width: 100%;
  height: 100%;
  position: relative;
  margin: 20px auto;
}

.cellprefix {
  width: 100%;
  height: 100%;
  max-width: 50px;
  max-height: 50px;
  float: left;
  margin: 3px;
  padding: 15px 0 0 20px;
}

.gamecell {
  border: 1px solid #000;
  width: 100%;
  height: 100%;
  max-width: 50px;
  max-height: 50px;
  float: left;
  margin: 3px;
  transition: all 0.5s ease-in-out;
  border-radius: 5px;
  font-size: 30pt;
  padding: 0 0 0 6px;
  cursor: pointer;
  z-index: 1;
}

.gamecell:hover {
  color: #fff;
  background: rgba(37, 88, 228, 0.712);
  z-index: 2;
  transform: translate(10px, -10px);
  animation: neonBlueText 1.5s ease-in-out infinite alternate;
}

.grey {
  background: rgba(128, 128, 128, 0.801);
}

.green {
  /*background: green !important;*/
  background: rgb(65, 161, 73) !important;
}

.neonblue_txt {
  animation: neonBlueText 1.5s ease-in-out infinite alternate;
}

.neonorange_txt {
  animation: neonOrangeText 1.5s ease-in-out infinite alternate;
}

.neongreen_txt {
  animation: neonGreenText 1.5s ease-in-out infinite alternate;
}

/* --- N E O N    T E X T --- */
@keyframes neonBlueText {
  from {
    text-shadow: 0 0 10px #fff, 0 0 20px #fff, 0 0 30px #fff, 0 0 40px #228dff,
      0 0 70px #228dff, 0 0 80px #228dff, 0 0 100px #228dff, 0 0 150px #228dff;
  }
  to {
    text-shadow: 0 0 5px #fff, 0 0 10px #fff, 0 0 15px #fff, 0 0 20px #228dff,
      0 0 35px #228dff, 0 0 40px #228dff, 0 0 50px #228dff, 0 0 75px #228dff;
  }
}

@keyframes neonOrangeText {
  from {
    text-shadow: 0 0 10px #fff, 0 0 20px #fff, 0 0 30px #fff, 0 0 40px #ff9900,
      0 0 70px #ff9900, 0 0 80px #ff9900, 0 0 100px #ff9900, 0 0 150px #ff9900;
  }
  to {
    text-shadow: 0 0 5px #fff, 0 0 10px #fff, 0 0 15px #fff, 0 0 20px #ff9900,
      0 0 35px #ff9900, 0 0 40px #ff9900, 0 0 50px #ff9900, 0 0 75px #ff9900;
  }
}

@keyframes neonGreenText {
  from {
    text-shadow: 0 0 10px #fff, 0 0 20px #fff, 0 0 30px #fff, 0 0 40px #b6ff00,
      0 0 70px #b6ff00, 0 0 80px #b6ff00, 0 0 100px #b6ff00, 0 0 150px #b6ff00;
  }
  to {
    text-shadow: 0 0 5px #fff, 0 0 10px #fff, 0 0 15px #fff, 0 0 20px #b6ff00,
      0 0 35px #b6ff00, 0 0 40px #b6ff00, 0 0 50px #b6ff00, 0 0 75px #b6ff00;
  }
}
/* --- N E O N --- */

/* animation: neon 1.5s ease-in-out infinite alternate; */

@keyframes neonBlue {
  from {
    box-shadow: 0 0 10px #fff, 0 0 20px #fff, 0 0 30px #fff, 0 0 40px #228dff,
      0 0 70px #228dff, 0 0 80px #228dff, 0 0 100px #228dff, 0 0 150px #228dff;
  }
  to {
    box-shadow: 0 0 5px #fff, 0 0 10px #fff, 0 0 15px #fff, 0 0 20px #228dff,
      0 0 35px #228dff, 0 0 40px #228dff, 0 0 50px #228dff, 0 0 75px #228dff;
  }
}

/*! * * * * * * * * * * * * * * * * * * * *\  
  CSShake :: shake-little
  v1.5.0
  CSS classes to move your DOM
  (c) 2015 @elrumordelaluz
  http://elrumordelaluz.github.io/csshake/
  Licensed under MIT
\* * * * * * * * * * * * * * * * * * * * */
.shake-little {
  display: inline-block;
  transform-origin: center center; }

.shake-freeze,
.shake-constant.shake-constant--hover:hover,
.shake-trigger:hover .shake-constant.shake-constant--hover {
  animation-play-state: paused; }

.shake-freeze:hover,
.shake-trigger:hover .shake-freeze, .shake-little:hover,
.shake-trigger:hover .shake-little {
  animation-play-state: running; }

@keyframes shake-little {
  2% {
    transform: translate(1px, 0px) rotate(0.5deg); }
  4% {
    transform: translate(1px, 0px) rotate(0.5deg); }
  6% {
    transform: translate(1px, 1px) rotate(0.5deg); }
  8% {
    transform: translate(0px, 0px) rotate(0.5deg); }
  10% {
    transform: translate(1px, 0px) rotate(0.5deg); }
  12% {
    transform: translate(0px, 0px) rotate(0.5deg); }
  14% {
    transform: translate(1px, 1px) rotate(0.5deg); }
  16% {
    transform: translate(0px, 1px) rotate(0.5deg); }
  18% {
    transform: translate(1px, 0px) rotate(0.5deg); }
  20% {
    transform: translate(0px, 1px) rotate(0.5deg); }
  22% {
    transform: translate(0px, 0px) rotate(0.5deg); }
  24% {
    transform: translate(0px, 0px) rotate(0.5deg); }
  26% {
    transform: translate(1px, 1px) rotate(0.5deg); }
  28% {
    transform: translate(0px, 1px) rotate(0.5deg); }
  30% {
    transform: translate(0px, 0px) rotate(0.5deg); }
  32% {
    transform: translate(1px, 1px) rotate(0.5deg); }
  34% {
    transform: translate(0px, 1px) rotate(0.5deg); }
  36% {
    transform: translate(0px, 1px) rotate(0.5deg); }
  38% {
    transform: translate(0px, 0px) rotate(0.5deg); }
  40% {
    transform: translate(1px, 0px) rotate(0.5deg); }
  42% {
    transform: translate(0px, 1px) rotate(0.5deg); }
  44% {
    transform: translate(0px, 1px) rotate(0.5deg); }
  46% {
    transform: translate(0px, 0px) rotate(0.5deg); }
  48% {
    transform: translate(1px, 0px) rotate(0.5deg); }
  50% {
    transform: translate(1px, 1px) rotate(0.5deg); }
  52% {
    transform: translate(0px, 0px) rotate(0.5deg); }
  54% {
    transform: translate(1px, 1px) rotate(0.5deg); }
  56% {
    transform: translate(0px, 1px) rotate(0.5deg); }
  58% {
    transform: translate(1px, 0px) rotate(0.5deg); }
  60% {
    transform: translate(1px, 1px) rotate(0.5deg); }
  62% {
    transform: translate(0px, 1px) rotate(0.5deg); }
  64% {
    transform: translate(0px, 0px) rotate(0.5deg); }
  66% {
    transform: translate(1px, 0px) rotate(0.5deg); }
  68% {
    transform: translate(0px, 0px) rotate(0.5deg); }
  70% {
    transform: translate(1px, 0px) rotate(0.5deg); }
  72% {
    transform: translate(1px, 1px) rotate(0.5deg); }
  74% {
    transform: translate(1px, 1px) rotate(0.5deg); }
  76% {
    transform: translate(0px, 0px) rotate(0.5deg); }
  78% {
    transform: translate(0px, 0px) rotate(0.5deg); }
  80% {
    transform: translate(1px, 0px) rotate(0.5deg); }
  82% {
    transform: translate(1px, 1px) rotate(0.5deg); }
  84% {
    transform: translate(0px, 1px) rotate(0.5deg); }
  86% {
    transform: translate(1px, 1px) rotate(0.5deg); }
  88% {
    transform: translate(1px, 1px) rotate(0.5deg); }
  90% {
    transform: translate(0px, 1px) rotate(0.5deg); }
  92% {
    transform: translate(1px, 0px) rotate(0.5deg); }
  94% {
    transform: translate(1px, 0px) rotate(0.5deg); }
  96% {
    transform: translate(1px, 0px) rotate(0.5deg); }
  98% {
    transform: translate(1px, 1px) rotate(0.5deg); }
  0%, 100% {
    transform: translate(0, 0) rotate(0); } }

.shake-little:hover,
.shake-trigger:hover .shake-little, .shake-little.shake-freeze, .shake-little.shake-constant {
  animation-name: shake-little;
  animation-duration: 100ms;
  animation-timing-function: ease-in-out;
  animation-iteration-count: infinite; }
/* --- Engine UI additions --- */
.selected-square { outline: 3px solid #f0b400; outline-offset: -3px; }
.last-move { box-shadow: inset 0 0 0 3px rgba(240, 180, 0, 0.7); }
.in-check { background: rgb(214, 69, 65) !important; }

#controls {
  clear: both;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  padding-top: 12px;
}
#controls select,
#newgame {
  padding: 6px 12px;
  cursor: pointer;
}

.promotion-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.promotion-box {
  background: #fff;
  border-radius: 8px;
  padding: 16px;
  text-align: center;
}
.promotion-choice {
  font-size: 36pt;
  margin: 8px 4px 0;
  padding: 0 10px;
  cursor: pointer;
  background: #f4f4f4;
  border: 1px solid #000;
  border-radius: 5px;
}
.promotion-choice:hover { background: #cfe3ff; }

/* Responsive layout for narrow screens and touch devices. */
@media (max-width: 560px) {
  #game {
    display: grid;
    grid-template-columns: clamp(22px, 7vw, 36px) repeat(8, minmax(0, 1fr));
    width: min(504px, calc(100vw - 16px));
    max-height: none;
    height: auto;
    margin: 12px auto;
    position: static;
  }

  .cellprefix {
    display: flex;
    align-items: center;
    justify-content: center;
    width: auto;
    height: auto;
    max-width: none;
    max-height: none;
    float: none;
    margin: 0;
    padding: 0;
    min-width: 0;
    aspect-ratio: 1;
    font-size: clamp(0.7rem, 2.8vw, 0.95rem);
  }

  .gamecell {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: auto;
    max-width: none;
    max-height: none;
    float: none;
    margin: 0;
    padding: 0;
    min-width: 0;
    aspect-ratio: 1;
    border-radius: 0;
    font-size: clamp(1.25rem, 8.5vw, 2.35rem);
    line-height: 1;
    touch-action: manipulation;
  }

  #turn {
    grid-column: 1 / -1;
    width: 100%;
    max-width: none;
    max-height: none;
    height: auto;
    position: static;
    float: none;
    box-sizing: border-box;
    margin-top: 10px;
    padding: 8px 6px;
    font-size: clamp(0.85rem, 3.4vw, 1rem);
    line-height: 1.3;
  }

  #controls {
    grid-column: 1 / -1;
    clear: none;
    width: 100%;
    box-sizing: border-box;
    gap: 8px;
    padding-top: 10px;
  }

  #controls select,
  #newgame {
    min-height: 40px;
    max-width: 100%;
    font-size: 0.875rem;
  }

  #controls select {
    flex: 1 1 135px;
  }

  /* Avoid persistent hover animations after a tap on touch screens. */
  .gamecell:hover {
    color: inherit;
    transform: none;
    animation: none;
  }

  .gamecell:not(.grey):not(.green):hover {
    background-color: transparent;
  }

  .gamecell.grey:hover {
    background-color: rgba(128, 128, 128, 0.801);
  }

  .gamecell.green:hover {
    background-color: rgb(65, 161, 73) !important;
  }

  .promotion-box {
    width: min(92vw, 360px);
    padding: 12px;
  }

  .promotion-choice {
    font-size: clamp(2rem, 10vw, 2.8rem);
    margin: 8px 2px 0;
    padding: 0 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .gamecell,
  .neonblue_txt,
  .neonorange_txt,
  .neongreen_txt,
  .shake-little {
    animation: none !important;
    transition: none !important;
  }
}
