@font-face {
  font-family: 'Lato';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../vendor/fonts/lato-latin-400-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Source Sans Pro';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../vendor/fonts/source-sans-pro-latin-400-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Source Sans Pro';
  font-style: normal;
  font-weight: 900;
  font-display: swap;
  src: url('../vendor/fonts/source-sans-pro-latin-900-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'FontAwesome';
  src: url('../fonts/fontawesome-webfont.eot?v=3.0.1');
  src: url('../fonts/fontawesome-webfont.eot?#iefix&v=3.0.1') format('embedded-opentype'),
    url('../fonts/fontawesome-webfont.woff?v=3.0.1') format('woff'),
    url('../fonts/fontawesome-webfont.ttf?v=3.0.1') format('truetype');
  font-weight: normal;
  font-style: normal;
}
/* ============================
   General Styles
=============================== */
html {
  font-size: 1em;
}

body {
  font: 1em 'Source Sans Pro', sans-serif;
  margin: 0;
  background: #000;
  background-size: cover;
  color: #fff;
  touch-action: none; /* Prevent browser zooming/scrolling */
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden; /* Prevent scrollbars */
}

a {
  color: #fff;
  text-decoration: none;
}

table {
  border-collapse: collapse;
  border-spacing: 0;
}

th {
  padding: 0;
  font-weight: normal;
}

td {
  padding: 0;
}

/* ============================
   Header Styles
=============================== */
h1 {
  color: #fff;
  font-size: 2rem;
  margin: 0.65em 0;
}

h3 {
  margin: 0;
  text-transform: uppercase;
  font-weight: normal;
  text-align: center;
}

.menu > ul {
  margin: 0;
  padding: 0;
}

.button,
.menu li {
  display: block;
}

.button,
.menu li a {
  font: 1.25rem 'Lato', sans-serif;
  display: inline-block;
  width: 50%;
  color: #fff;
  border: 2px solid #fff;
  border-radius: 5px;
  padding: 0.3rem 0.6rem 0.4rem;
  margin: 0.5em;
  background: #000;
  cursor: pointer;
}

.button {
  margin: 0;
}

/* FontAwesome icons */
[class^="icon-"],
[class*=" icon-"] {
  font-family: FontAwesome;
  font-weight: normal;
  font-style: normal;
  text-decoration: inherit;
  margin: 0 0.4em 0 0;
  -webkit-font-smoothing: antialiased;
}

.icon-cog:before {
  content: '\f021';
}

/* ============================
   Content Section
=============================== */
#content {
  position: relative;
  background: rgba(0, 0, 0, 0.7);
  display: block; /* Flex item */
}

/* ============================
   Canvas Styles
=============================== */
#sprite {
  display: none;
}

#a,
#b,
#c {
  position: relative;
  overflow: hidden;
  float: left;
}

#b {
  border: 1px solid #fff;
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.5);
  z-index: 3;
  padding: 0;
  position: relative;
}

/* Retro CRT effects */
#b::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: repeating-linear-gradient(
    transparent,
    transparent 2px,
    rgba(255, 255, 255, 0.03) 2px,
    rgba(255, 255, 255, 0.03) 4px
  );
  pointer-events: none;
  z-index: 1;
}

@keyframes flicker {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.98; }
}

/* The flicker runs on the scanline layer only, so the board's canvases are
   not re-composited at full opacity changes every frame. */
#b::before {
  animation: flicker 0.15s infinite linear;
}

#bgStack,
#hold,
#preview,
#stack {
  position: absolute;
  z-index: 2;
}

#active {
  position: absolute;
  z-index: 3;
}

#msg {
  font: 900 4rem 'Source Sans Pro', sans-serif;
  color: #fff;
  position: absolute;
  text-align: center;
  width: 100%;
  line-height: 642px;
  margin: 0;
  z-index: 4;
}

#d {
  float: left;
}

/* ============================
   Stats Section
=============================== */
#stats {
  display: block;
  position: absolute;
}

#stats tbody,
#stats tr {
  display: block;
  width: 100%;
  padding: 0 0.5rem;
}

#stats th {
  text-transform: uppercase;
  display: inline-block;
  width: 100%;
  vertical-align: top;
}

#stats td {
  font-size: 280%;
  font-weight: 900;
  text-align: center;
  line-height: 1;
  display: inline-block;
  width: 100%;
}

#time {
  text-align: center;
  font-weight: 900;
  font-size: 1.125em;
  display: block;
}

/* ============================
   Menu Styles
=============================== */
.menu {
  text-align: center;
  width: 100%;
  height: 100%;
  overflow-y: auto;
  margin-top: -200%;
  position: absolute;
  background: rgba(0, 0, 0, 0);
  top: 0;
  z-index: 50;
  opacity: 0;
  transition: opacity 0.8s ease-out, background 0.4s ease-out 0.3s, margin 0.4s ease-out;
}

.menu.on {
  background: rgba(0, 0, 0, 0.8);
  opacity: 1;
  margin: 0;
}

#go,
#pause {
  background: none;
  transition: opacity 0.8s ease-out;
}

#go ul,
#pause ul {
  width: 100%;
  position: absolute;
  bottom: 2em;
}

/* ============================
   Controls Section
=============================== */
#controls {
  margin: 0 auto 1em;
}

#controls th {
  font-weight: bold;
  text-align: left;
  line-height: 1.6;
}

#controls td {
  font-weight: bold;
  cursor: pointer;
  display: block;
  margin: 0.2em 0 0.2em 2em;
  text-align: center;
  width: 6em;
  line-height: 1.6;
  background: #111;
  border-radius: 5px;
}

#controls td:hover {
  background: #191919;
}

#controls td:active {
  background: #1a1a1a;
}

/* ============================
   Settings Section
=============================== */
#settings {
  margin: 0 0 1em;
}

#settings b {
  text-align: left;
  display: inline-block;
  width: 7em;
}

#settings span {
  text-align: center;
  font-weight: bold;
  display: inline-block;
  width: 5em;
  margin: 0.3em 0;
}

.left,
.right {
  font-family: FontAwesome;
  cursor: pointer;
  -webkit-font-smoothing: antialiased;
  transition: all 0.1s ease-out;
}

.left:hover,
.right:hover {
  color: #4da6ee;
}

.left:before {
  content: '\f022';
}

.right:before {
  content: '\f023';
}

/* ============================
   Layout
=============================== */
#content {
  display: flex;
  align-items: stretch;
}

#d,
#c {
  flex: none;
  position: relative;
}

#d {
  display: flex;
  flex-direction: column;
}

#stats {
  position: static;
  margin-top: auto;
  padding-bottom: 0.5em;
}

#stats tbody,
#stats tr {
  padding: 0;
}

#a,
#b,
#c {
  float: none;
  flex: none;
}

#a {
  padding: 0;
}

h3 {
  line-height: 2;
}

/* ============================
   Mode menu
=============================== */
.menu a small {
  display: block;
  font-size: 0.6em;
  opacity: 0.75;
  line-height: 1.3;
}

.menu a small.best {
  color: #8fd3ff;
  opacity: 1;
}

.menu a small.best:empty {
  display: none;
}

.menu h1 {
  margin: 0.4em 0;
}

.menu li a {
  width: 75%;
  margin: 0.3em;
  padding: 0.25rem 0.5rem 0.35rem;
}

.menu-row {
  display: flex;
  justify-content: center;
}

.menu-row a {
  width: 36%;
}

.go-note {
  position: absolute;
  width: 100%;
  bottom: 9.5em;
  margin: 0;
  font-weight: 900;
}

#msg .action {
  font-size: 40%;
  letter-spacing: 0.05em;
}

/* Theme shortcut notification */
.theme-toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.9);
  color: white;
  padding: 20px 30px;
  border-radius: 8px;
  font-family: 'Source Sans Pro', sans-serif;
  font-size: 1.2rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 2px;
  z-index: 10000;
  border: 1px solid rgba(255, 255, 255, 0.2);
  animation: fadeInOut 2s ease;
}

@keyframes fadeInOut {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
  20% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  80% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
}

/* ============================
   Touch screens
   The layout (cell size, panel widths, margins) is computed in resize();
   these rules style the pieces it places.
=============================== */
.touch-only {
  display: none;
}

html.tt-touch,
html.tt-touch body {
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

html.tt-touch body {
  height: 100vh;
  height: 100dvh;
  position: fixed;
  inset: 0;
}

.tt-touch #touchPause {
  flex: none;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin: 8px auto 0;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  touch-action: manipulation;
}

#touchPause svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 3;
  stroke-linecap: round;
}

.tt-touch #a {
  cursor: pointer;
}

.tt-touch h3 {
  font-size: 12px;
  line-height: 24px;
  letter-spacing: 0.04em;
}

.tt-touch #stats th {
  font-size: 12px;
  line-height: 1.3;
}

.tt-touch #stats td {
  font-size: 100%;
  white-space: nowrap;
}

.tt-touch #stats #time {
  font-size: 12px;
  padding-top: 2px;
}

.tt-touch #stats tr {
  margin-bottom: 4px;
}

/* Tall phones: hold, stats and pause in a strip above the board and queue. */
#content.tt-strip {
  flex-wrap: wrap;
  border-radius: 8px 8px 0 0;
}

#content.tt-strip #d {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) 44px;
  grid-template-rows: 18px auto;
  align-content: center;
  align-items: center;
  column-gap: 8px;
  padding: 0 6px;
  box-sizing: border-box;
}

#content.tt-strip #d > h3 {
  grid-area: 1 / 1;
  line-height: 18px;
}

#content.tt-strip #a {
  grid-area: 2 / 1;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
}

#content.tt-strip #touchPause {
  grid-area: 1 / 3 / 3 / 4;
  margin: 0;
}

#content.tt-strip #replay {
  display: none !important;
}

#content.tt-strip #stats {
  grid-area: 1 / 2 / 3 / 3;
  margin: 0;
  padding: 0;
  min-width: 0;
}

#content.tt-strip #stats tbody {
  display: flex;
  justify-content: space-around;
  align-items: center;
  width: auto;
}

#content.tt-strip #stats tr {
  width: auto;
  margin: 0;
  min-width: 0;
}

#content.tt-strip #stats tr:nth-child(4) {
  display: none;
}

#content.tt-strip #stats #time {
  font-size: 13px;
}

/* On-screen buttons */
#pad {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 60;
  justify-content: space-between;
  align-items: flex-end;
  gap: 8px;
  padding: 0 max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  pointer-events: none;
}

.tt-touch.tt-playing:not(.tt-nobuttons) #pad {
  display: flex;
}

.pad-group {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 84px));
  grid-auto-rows: var(--pad-row, 56px);
  gap: 8px;
  flex: 0 1 50%;
}

.pad-right {
  justify-content: end;
}

#pad button {
  pointer-events: auto;
  touch-action: none;
  display: grid;
  place-items: center;
  min-width: 0;
  padding: 0;
  border: 1px solid rgba(250, 204, 21, 0.3);
  border-radius: 12px;
  background: rgba(18, 19, 26, 0.72);
  color: #fff;
  font: 900 16px/1 'Source Sans Pro', sans-serif;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: background-color 60ms ease;
}

#pad button[data-pressed] {
  background: #facc15;
  border-color: #facc15;
  color: #09090b;
}

#pad svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

#pad .pad-drop {
  grid-column: span 2;
}

#pad .pad-rot {
  font-size: 30px;
  font-weight: 400;
  text-transform: none;
}

.tt-landscape #pad {
  padding-bottom: max(12px, env(safe-area-inset-bottom));
}

.tt-landscape .pad-group {
  grid-template-columns: repeat(2, 56px);
  flex: none;
}

/* Menus: full screen on touch screens, readable and easy to tap. */
.tt-touch .menu:not(#go):not(#pause) {
  position: fixed;
  inset: 0;
  width: auto;
  height: auto;
  margin: 0;
  padding: max(8px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  box-sizing: border-box;
  visibility: hidden;
  transition: opacity 0.3s ease-out, visibility 0s linear 0.3s;
  touch-action: pan-y;
  overscroll-behavior: contain;
}

.tt-touch .menu.on:not(#go):not(#pause) {
  visibility: visible;
  transition: opacity 0.3s ease-out;
}

.tt-touch .menu > * {
  max-width: 420px;
  margin-left: auto;
  margin-right: auto;
}

.tt-touch .menu li a,
.tt-touch .button {
  box-sizing: border-box;
  min-height: 48px;
  font-size: 1.15rem;
  touch-action: manipulation;
}

.tt-touch .menu li a {
  width: 86%;
  margin: 5px 0;
}

.tt-touch .menu-row {
  gap: 8px;
}

.tt-touch .menu-row a {
  width: 42%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tt-touch .menu a small {
  font-size: 12px;
}

.tt-touch .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 140px;
}

.tt-touch #settings > div {
  display: flex;
  align-items: center;
  justify-content: center;
}

.tt-touch #settings b {
  width: 7.5em;
}

.tt-touch #settings span {
  margin: 0;
}

.tt-touch #settings .left,
.tt-touch #settings .right {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin: 0;
  touch-action: manipulation;
}

html:not(.tt-touch) #Buttons {
  display: none;
}

.tt-touch .key-help,
.tt-touch #controls {
  display: none;
}

.tt-touch .touch-help {
  display: block;
  text-align: left;
  line-height: 1.45;
  padding: 0 4px;
}

/* Pause and game over: buttons below the board (portrait) or beside it (landscape). */
.tt-touch #go,
.tt-touch #pause {
  position: fixed;
  inset: 0;
  width: auto;
  height: auto;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  padding: 0 max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  box-sizing: border-box;
  visibility: hidden;
  overflow: hidden;
}

.tt-touch #go.on,
.tt-touch #pause.on {
  visibility: visible;
}

.tt-touch #pause.on {
  background: rgba(0, 0, 0, 0.55);
}

.tt-touch #go ul,
.tt-touch #pause ul,
.tt-touch .go-note {
  position: static;
}

.tt-touch #go ul,
.tt-touch #pause ul {
  display: flex;
  gap: 8px;
  width: 100%;
  max-width: 480px;
}

.tt-touch #go li,
.tt-touch #pause li {
  flex: 1;
  min-width: 0;
}

.tt-touch #go li a,
.tt-touch #pause li a {
  width: 100%;
  margin: 0;
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  line-height: 1.15;
}

.tt-touch .go-note {
  margin: 0 0 8px;
  text-shadow: 0 1px 3px #000;
}

.tt-landscape #go,
.tt-landscape #pause {
  justify-content: center;
  align-items: flex-end;
}

.tt-landscape #go ul,
.tt-landscape #pause ul,
.tt-landscape .go-note {
  flex-direction: column;
  width: min(180px, calc((100vw - var(--board-w, 200px)) / 2 - 24px));
}

.tt-landscape .go-note {
  text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  #b::before {
    animation: none;
  }
}

.tt-touch .menu li.menu-row {
  display: flex;
  justify-content: center;
}

/* Landscape phones: the modes in two columns so the menu fits the height. */
.tt-landscape .menu > ul {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 10px;
  max-width: 640px;
}

.tt-landscape .menu > ul li a {
  width: 100%;
  margin: 0;
}

.tt-landscape .menu li.menu-row a {
  width: 50%;
}

.tt-landscape .menu h1 {
  margin: 0.2em 0 0.3em;
}

.tt-landscape #stats tr:nth-child(4) {
  display: none;
}

.tt-touch .menu li.menu-row {
  width: 86%;
  margin: 0 auto;
}

.tt-touch .menu li.menu-row a {
  flex: 1;
  margin: 5px 0;
}

.tt-landscape #go > *,
.tt-landscape #pause > * {
  margin-right: 0;
}
