[class~="404-game"] {
  --tetris-hud-width: 140px;
  margin: 0;
  color: var(--tc-text);
  flex-direction: column;
  overflow: visible;
  touch-action: manipulation;
  font-size: 16px;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  display: flex;
  justify-content: center;
  align-items: center;
  font-family: var(--tc-font-mono);
}

[class~="404-game"] button,
[class~="404-game"] a {
  font-family: inherit;
}

[class~="404-game"] .center {
  display: flex;
  justify-content: center;
  align-items: center;
}

[class~="404-game"] .msg {
  position: relative;
  text-align: left;
  line-height: 2em;
  width: 100%;
  max-width: 470px;
  margin-bottom: 10px;
  padding: 10px 16px;
  box-sizing: border-box;
  border: double 5px var(--tc-border);
  border-radius: 10px;
  transform: translateZ(0);
  font-family: var(--tc-font-mono);
}

[class~="404-game"] .msg,
[class~="404-game"] .msg * {
  text-shadow: none;
}

[class~="404-game"] .msg span {
  visibility: hidden;
  animation: typeIn 0s forwards;
  font-family: var(--tc-font-mono);
}

@keyframes typeIn {
  to {
    visibility: visible;
  }
}

[class~="404-game"] .screen {
  width: 100%;
  max-width: 480px;
}

[class~="404-game"] canvas {
  position: relative;
  top: 0;
  left: 0;
  margin-bottom: 0;
  image-rendering: pixelated;
  width: 100%;
}


/* Original layout positioning */
[class~="404-game"] .ctrlr {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  justify-items: center;
  align-items: center;
  margin-top: 0;
  width: 100%;
}

[class~="404-game"] .dpad {
  justify-self: start;
}

[class~="404-game"] .face {
  justify-self: end;
}

/* Controls (matched to Tetris touch controls) */
[class~="404-game"] .controls {
  margin-top: 0.75rem;
  display: flex;
  gap: 2rem;
  justify-content: center;
  flex-wrap: wrap;
  align-items: center;
}

[class~="404-game"] .controls + .controls {
  margin-top: 2rem;
}

[class~="404-game"] .controls--keys {
  width: min(520px, 100%);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0;
  box-sizing: border-box;
  gap: 2rem;
}

[class~="404-game"] .controls--touch {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, var(--tetris-hud-width));
  padding: 0;
  box-sizing: border-box;
  column-gap: 1rem;
  row-gap: 2rem;
  align-items: end;
}

[class~="404-game"] .controls--touch .btn {
  width: 100%;
  touch-action: none;
}

[class~="404-game"] .controls--keys .btn {
  width: auto;
  touch-action: none;
}

[class~="404-game"] .controls--keys .touch-key {
  border-radius: 4rem;
  min-height: 2.25rem;
  padding: 0.125rem 1rem;
  font-size: 0.875rem;
  text-transform: uppercase;
}

[class~="404-game"] .start-key {
  border-radius: 4rem;
  min-height: 2.25rem;
  padding: 0.125rem 1rem;
  font-size: 0.875rem;
  text-transform: uppercase;
}

[class~="404-game"] .touch-control {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

[class~="404-game"] .touch-key {
  min-width: 3rem;
  min-height: 3rem;
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 0.25rem;
  box-sizing: border-box;
  text-align: center;
  white-space: nowrap;
  flex-shrink: 0;
  gap: 0.125rem;
  align-self: center;
  margin: 0;
  background: var(--tc-background);
  border: 1px solid var(--tc-border);
  border-bottom: 3px solid var(--tc-border);
  border-radius: 0.5rem;
  color: var(--tc-text);
  font-weight: 400;
  text-decoration: none;
  overflow: visible;
  transition: background-color 0.15s ease, border-bottom-width 0.15s ease, transform 0.1s ease;
}

[class~="404-game"] .touch-key--icon {
  min-width: 4rem;
  min-height: 4rem;
  font-size: 0.95rem;
}

[class~="404-game"] .touch-control--dpad {
  align-items: flex-start;
  justify-self: start;
  width: 100%;
  align-self: end;
}

[class~="404-game"] .dpad {
  display: block;
  width: auto;
}

[class~="404-game"] .controls--touch .dpad .touch-key {
  width: 4rem;
}

[class~="404-game"] .dpad-key {
  min-width: 4rem;
  min-height: 4rem;
  border-radius: 0.4rem;
}

[class~="404-game"] .dpad-key--up {
  grid-column: 2;
  grid-row: 1;
}

[class~="404-game"] .dpad-key--left {
  grid-column: 1;
  grid-row: 2;
}

[class~="404-game"] .dpad-key--right {
  grid-column: 3;
  grid-row: 2;
}

[class~="404-game"] .dpad-key--down {
  grid-column: 2;
  grid-row: 2;
}

[class~="404-game"] .dir,
[class~="404-game"] .act,
[class~="404-game"] .start-key {
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  box-sizing: border-box;
  text-align: center;
  white-space: nowrap;
  flex-shrink: 0;
  gap: 0.125rem;
  align-self: center;
  background: var(--tc-background);
  border: 1px solid var(--tc-border);
  border-bottom: 3px solid var(--tc-border);
  color: var(--tc-text);
  font-weight: 400;
  text-decoration: none;
  overflow: visible;
  transition: background-color 0.15s ease, border-bottom-width 0.15s ease, transform 0.1s ease;
}

[class~="404-game"] .dir {
  min-width: 4rem;
  min-height: 4rem;
  padding: 0.25rem;
  border-radius: 0.4rem;
  margin: 2px 22px;
  font-size: 0.95rem;
}

[class~="404-game"] .act {
  min-width: 4rem;
  min-height: 4rem;
  padding: 0.25rem;
  border-radius: 4rem;
  margin: 5px;
  font-size: 0.95rem;
}

[class~="404-game"] .start-key {
  min-height: 2.25rem;
  padding: 0.125rem 1rem;
  border-radius: 4rem;
  font-size: 0.875rem;
  text-transform: uppercase;
  margin: 10px 5px;
}

[class~="404-game"] .touch-control--actions {
  align-items: flex-end;
  justify-self: end;
  width: auto;
  align-self: end;
}

[class~="404-game"] .touch-action-row {
  display: flex;
  align-items: flex-end;
  gap: 1rem;
  flex-wrap: nowrap;
  justify-content: flex-end;
}

[class~="404-game"] .touch-action-row .touch-key {
  width: 4rem;
}

[class~="404-game"] .touch-key i {
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

[class~="404-game"] .act-key {
  border-radius: 4rem;
}

[class~="404-game"] .touch-key::after,
[class~="404-game"] .dir::after,
[class~="404-game"] .act::after,
[class~="404-game"] .start-key::after {
  content: none;
}

[class~="404-game"] .touch-key:hover::after,
[class~="404-game"] .touch-key:focus::after,
[class~="404-game"] .touch-key:focus-visible::after,
[class~="404-game"] .dir:hover::after,
[class~="404-game"] .dir:focus::after,
[class~="404-game"] .dir:focus-visible::after,
[class~="404-game"] .act:hover::after,
[class~="404-game"] .act:focus::after,
[class~="404-game"] .act:focus-visible::after,
[class~="404-game"] .start-key:hover::after,
[class~="404-game"] .start-key:focus::after,
[class~="404-game"] .start-key:focus-visible::after {
  content: none;
  width: 0;
}

[class~="404-game"] a.start-key {
  border-bottom: 3px solid var(--tc-border);
  padding-bottom: 0;
}

[class~="404-game"] .touch-key:focus,
[class~="404-game"] .touch-key:focus-visible {
  color: var(--tc-text);
  border-color: var(--tc-border);
  outline: 1px solid var(--tc-border);
  outline-offset: 2px;
}

[class~="404-game"] .touch-key:focus:not(:focus-visible) {
  outline: none;
}

[class~="404-game"] .dir:focus,
[class~="404-game"] .dir:focus-visible,
[class~="404-game"] .act:focus,
[class~="404-game"] .act:focus-visible,
[class~="404-game"] .start-key:focus,
[class~="404-game"] .start-key:focus-visible {
  color: var(--tc-text);
  border-color: var(--tc-border);
  outline: 1px solid var(--tc-border);
  outline-offset: 2px;
}

[class~="404-game"] .dir:focus:not(:focus-visible),
[class~="404-game"] .act:focus:not(:focus-visible),
[class~="404-game"] .start-key:focus:not(:focus-visible) {
  outline: none;
}

[class~="404-game"] .touch-key:hover,
[class~="404-game"] .touch-key:active,
[class~="404-game"] .touch-key.is-pressed,
[class~="404-game"] .dir:hover,
[class~="404-game"] .dir:active,
[class~="404-game"] .dir.is-pressed,
[class~="404-game"] .act:hover,
[class~="404-game"] .act:active,
[class~="404-game"] .act.is-pressed,
[class~="404-game"] .start-key:hover,
[class~="404-game"] .start-key:active,
[class~="404-game"] .start-key.is-pressed,
[class~="404-game"] .pressed {
  background: var(--tc-halftone-300);
  color: var(--tc-text);
  border-color: var(--tc-border);
  border-bottom-width: 1px;
  transform: translateY(2px);
}

@media (max-width: 500px) {
  [class~="404-game"] {
    font-size: 0.8em;
  }

  [class~="404-game"] .screen,
  [class~="404-game"] .controls--touch {
    width: 90%;
  }

  [class~="404-game"] .msg {
    width: 90%;
  }

  [class~="404-game"] .msg p {
    margin: 2px;
  }
}

[class~="404-game"] .nojs {
  flex-direction: column;
  position: relative;
  top: 0;
  left: 0;
  margin: 10px 0 20px 0;
  width: 100%;
  height: 281px;
  background: #000;
  color: #fff;
  text-align: center;
  padding: 50px;
  box-sizing: border-box;
  border-radius: 5px;
}

[class~="404-game"] .ins {
  font-weight: bolder;
  animation: blink 1s infinite;
}

@keyframes blink {
  0% {
    color: #666;
  }
  50% {
    color: #fff;
  }
  100% {
    color: #666;
  }
}
