body,
button,
div,
h1,
h3,
main,
p,
section,
span {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

a,
a:visited {
  color: #f2caa3;
  text-decoration: underline;
}

body {
  background-color: #232333;
  font-family: "Tiny5", sans-serif;
  margin: auto;
  padding: 2px;
  width: 100vw;
  max-width: 960px;
  max-height: 100vh;
  overflow: hidden;
  touch-action: manipulation;
}

button {
  font-family: "Tiny5", sans-serif;
}

h1,
h2,
h3 {
  color: white;
  font-family: "Jacquard 12", system-ui;
}

h1 {
  font-size: 2.25rem;
}

h3 {
  font-size: 2rem;
}

section {
  width: 100%;
}

#main {
  margin: auto;
  height: 100vh;
  position: relative;
}

#level-up {
  color: white;
  position: absolute;
  top: 10%;
  left: 10%;
  right: 10%;
  background-color: #35354d;
  border-radius: 8px;
  padding: 16px;
  z-index: 20;

  display: flex;
  flex-direction: column;
}

#inventory {
  position: absolute;
  inset: 10%;
  background-color: #35354d;
  border-radius: 8px;
  padding: 16px;
  z-index: 20;

  display: flex;
  flex-direction: column;
}

#game {
  height: 100%;
  width: 100%;

  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  position: relative;
}

#title {
  color: white;
  position: absolute;
  left: 50%;
  top: 10vh;
  z-index: 15;
  transform: translateX(-50%);
  pointer-events: none;
}

#viewport {
  flex-shrink: 0;
  aspect-ratio: 11/11;
  max-width: 75vh;
  max-height: 75vh;

  display: grid;
  grid-template-columns: repeat(11, 1fr [col-start]);
  grid-template-rows: repeat(11, 1fr [row-start]);
  gap: 2px;

  overflow: hidden;
}

#xp {
  margin-bottom: 16px;
}

#xp .bar {
  height: 8px;
}

#xp-bar .fill {
  background-color: #0ac848;
}

#vitals {
  height: 10px;

  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  margin-bottom: 16px;
}

#health .fill {
  background-color: #a82a00;
}

#mana .fill {
  background-color: #0359d3;
}

#stamina .fill {
  background-color: #05752a;
}

#actions {
  aspect-ratio: 11/1;

  display: grid;
  grid-template-columns: repeat(11, 1fr [col-start]);
  gap: 2px;
  margin-bottom: 16px;
}

#logs {
  color: white;
  white-space: pre-line;
  overflow-y: auto;
}

.action {
  background-color: #6b6b84;
  border-radius: 8px;

  position: relative;
}

.action::after {
  color: black;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

.action.selected {
  background-color: #9abb9a;
}

.action[data-action="none"] {
  background-color: #454555;
}

.action[data-action="examine"]::after {
  content: "visibility";
}

.action[data-action="interact"]::after {
  content: "touch_app";
}

.action[data-action="left"]::after {
  content: "front_hand";
  transform: scaleX(-1) translate(50%, -50%);
}

.action[data-action="move"]::after {
  content: "open_with";
}

.action[data-action="right"]::after {
  content: "front_hand";
}

.action[data-action="settings"]::after {
  content: "settings";
}

.action span {
  position: absolute;
  background-color: #454555;
  background-size: cover;
  background-repeat: no-repeat;
  image-rendering: pixelated;
  border-radius: 2px;
  cursor: pointer;
  aspect-ratio: 1/1;
  width: 16px;
}

.action .se {
  bottom: -8px;
  right: 0;
}

.bar {
  flex: 1;

  position: relative;
  background-color: #454555;

  display: flex;
  align-items: center;
  justify-content: center;
}

.bar .fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 75%;
}

.bar .bar-text {
  color: white;
  z-index: 10;
}

.bold {
  font-weight: bold;
}

.close-button {
  background-color: #ff5555;
  border-radius: 4px;
  color: black;
  cursor: pointer;
}

.contents {
  flex: 1 0 auto;

  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: flex-start;
}

.empty-hand {
  background-image: url("images/empty-hand.png");
}

.entity {
  display: none;
  animation-fill-mode: backwards;
  background-size: cover;
  background-repeat: no-repeat;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
  position: absolute;
  inset: 0;
  z-index: 1;
}

.entity.highlight {
  display: block !important;
}

.entity span {
  color: white;
  font-family: sans-serif;
  font-size: 10px;
  position: absolute;
}

.entity .ne {
  top: -0.7em;
  right: 0;
}

.entity .nw {
  top: -0.7em;
  left: 0;
}

.entity .se {
  bottom: -0.7em;
  right: 0;
}

.entity .sw {
  bottom: -0.7em;
  left: 0;
}

.fade {
  opacity: 0;
  animation: fade-anim 5s ease forwards;
}

@keyframes fade-anim {
  0% {
    opacity: 0;
  }
  50% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

.hidden {
  display: none !important;
}

.in-range {
  cursor: pointer;
  position: relative;
}

.in-range::after {
  content: "";
  position: absolute;
  inset: 0;
  background-color: green;
  opacity: 0.25;
}

.inventory-button {
  aspect-ratio: 1/1;
  background-color: #454555;
  background-repeat: no-repeat;
  background-size: cover;
  border: 1px solid #232333;
  border-radius: 4px;
  cursor: pointer;
  image-rendering: pixelated;
  margin-right: 6px;
  padding: 4px;
  position: relative;
  width: calc((100% - 30px) / 6);
}

.inventory-button[data-count]::after {
  background-color: #454555;
  border-radius: 2px;
  color: white;
  content: attr(data-count);
  font-family: sans-serif;
  font-size: 10px;
  padding: 2px 4px;
  position: absolute;
  bottom: -0.7em;
  right: -0.5em;
}

.log.danger {
  color: #ff5555;
}

.log.end.player {
  color: #30a8dd;
}

.log.safe {
  color: #55ff55;
}

.log.start.player {
  color: #55ccff;
}

.log.warn {
  color: #ffeb33;
}

.memory {
  opacity: 0.5;
}

.no-highlight {
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  -webkit-touch-callout: none;
}

.pip {
  flex: 1 1 auto;
  border-radius: 4px;
  background-color: #454555;
}

.pip::after {
  color: white;
  font-size: 12px;
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
}

.pip:disabled {
  opacity: 0.2;
}

.pip.bonus {
  opacity: 0.5;
}

.pip.bonus,
.pip.filled {
  background-color: #0ac848;
}

.pip.minus {
  background-color: #a82a00;
  border: none;
  position: relative;
}

.pip.minus::after {
  content: "remove";
}

.pip.plus {
  background-color: #05752a;
  border: none;
  position: relative;
}

.pip.plus::after {
  content: "add";
}

.submit {
  border: none;
  color: white;
  border-radius: 8px;
  font-size: 1.2rem;
  background-color: #05752a;
  padding: 4px 0;
  width: 100%;
}

.submit:disabled {
  background-color: #454555;
}

.stat {
  width: 100%;
}

.stat-bar {
  height: 3vh;
  display: flex;
  gap: 2px;
  align-items: stretch;
  justify-content: space-between;
}

.tile {
  aspect-ratio: 1 / 1;
  background-color: black;
  background-size: cover;
  background-repeat: no-repeat;
  image-rendering: pixelated;
  position: relative;
}

.tile::before {
  content: " ";
  background-color: red;
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.tile:has(.entity.highlight)::before {
  opacity: 0.5;
}

.tile:has(.entity.highlight) > .entity:not(.highlight) {
  display: none !important;
}

.top-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  border-bottom: 1px solid #232333;
  justify-content: space-between;
  padding-bottom: 4px;
}

.vbox {
  display: flex;
  flex-direction: column;
  align-items: start;
  justify-content: start;
  padding: 8px 0;
}

.vbox > * {
  margin-bottom: 8px;
}

.vbox > *:last-child {
  margin-bottom: 0;
}
