* {
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #263d2e;
  font-family: Georgia, "Times New Roman", serif;
}

body {
  overscroll-behavior: none;
}

#game {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 500px;
  overflow: hidden;
  background: #a9cddd;
  isolation: isolate;
}

#game canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
  touch-action: none;
}

#loading {
  position: absolute;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: #f1dfb7;
  background:
    radial-gradient(ellipse at center, rgba(83,111,72,.65), transparent 65%),
    #1d3027;
  transition: opacity .8s ease;
}

.loading-title {
  font-size: clamp(22px, 4vw, 38px);
  letter-spacing: 4px;
  text-align: center;
}

.loading-subtitle {
  font-size: 13px;
  letter-spacing: 2px;
  opacity: .75;
}

.loading-track {
  width: 190px;
  height: 4px;
  margin-top: 12px;
  overflow: hidden;
  border-radius: 5px;
  background: rgba(255,255,255,.15);
}

.loading-fill {
  width: 40%;
  height: 100%;
  border-radius: 5px;
  background: #d7bd82;
  animation: loadingMove 1.4s ease-in-out infinite alternate;
}

@keyframes loadingMove {
  from { transform: translateX(-10%); }
  to { transform: translateX(160%); }
}

#forgotten-kingdom-ui {
  position: absolute;
  inset: 0;
  z-index: 10;
  overflow: hidden;
  pointer-events: none;
  color: #f4ead5;
  font-family: Georgia, "Times New Roman", serif;
}

.fk-panel {
  color: #f4ead5;
  background: linear-gradient(145deg, rgba(29,40,32,.94), rgba(17,25,22,.94));
  border: 1px solid rgba(211,190,139,.55);
  border-radius: 9px;
  box-shadow: 0 5px 22px rgba(0,0,0,.35);
}

.fk-title-panel {
  position: absolute;
  top: 14px;
  left: 14px;
  padding: 11px 16px;
}

.fk-game-title {
  color: #e7d2a3;
  font-size: 19px;
  letter-spacing: 2px;
}

.fk-subtitle {
  margin-top: 3px;
  font-size: 10px;
  letter-spacing: 1.5px;
  opacity: .7;
}

.fk-quest-panel {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 260px;
  padding: 13px;
}

.fk-section-label {
  color: #d9bd80;
  font-size: 11px;
  letter-spacing: 1.7px;
}

.fk-quest-name {
  margin-top: 8px;
  font-size: 17px;
}

.fk-quest-description {
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.55;
  opacity: .85;
}

.fk-objective {
  margin-top: 10px;
  padding-top: 9px;
  border-top: 1px solid rgba(211,190,139,.2);
  color: #c6d49e;
  font-size: 11px;
  line-height: 1.5;
}

.fk-location {
  position: absolute;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 15px;
  letter-spacing: 2px;
  text-shadow: 0 2px 6px #000;
  white-space: nowrap;
}

.fk-controls {
  position: absolute;
  bottom: 14px;
  left: 14px;
  padding: 9px 12px;
  font-size: 11px;
  line-height: 1.8;
}

.fk-actions {
  position: absolute;
  top: 112px;
  left: 14px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  pointer-events: auto;
}

.fk-button {
  min-width: 105px;
  padding: 8px 12px;
  color: #f4ead5;
  background: rgba(28,40,32,.92);
  border: 1px solid rgba(211,190,139,.55);
  border-radius: 6px;
  font: 12px Georgia, serif;
  cursor: pointer;
  text-align: left;
}

.fk-button:hover {
  background: rgba(76,93,60,.98);
}

.fk-interaction {
  position: absolute;
  bottom: 105px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 17px;
  border: 1px solid rgba(225,204,155,.6);
  border-radius: 7px;
  background: rgba(20,28,24,.94);
  font-size: 14px;
  white-space: nowrap;
  display: none;
}

.fk-message {
  position: absolute;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  width: min(520px, 88%);
  padding: 15px 18px;
  text-align: center;
  display: none;
}

.fk-message-title {
  margin-bottom: 7px;
  color: #e9d4a6;
  font-size: 18px;
}

.fk-message-text {
  font-size: 13px;
  line-height: 1.65;
  opacity: .92;
}

.fk-dialogue-name {
  margin-bottom: 5px;
  color: #c9d9a0;
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.fk-modal-backdrop {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(7,12,9,.66);
  pointer-events: auto;
}

.fk-modal {
  width: min(560px, 95%);
  max-height: 80%;
  overflow: auto;
  padding: 20px;
}

.fk-modal h2 {
  margin: 0 0 12px;
  color: #e9d4a6;
  font-size: 22px;
  font-weight: normal;
}

.fk-modal p, .fk-modal li {
  font-size: 13px;
  line-height: 1.7;
}

.fk-modal button {
  margin-top: 12px;
  padding: 9px 18px;
  color: #f4ead5;
  background: #536a46;
  border: 1px solid #c5ae7c;
  border-radius: 5px;
  font: 13px Georgia, serif;
  cursor: pointer;
}

.fk-inventory-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0;
  list-style: none;
}

.fk-inventory-list li {
  padding: 7px 10px;
  border: 1px solid rgba(211,190,139,.35);
  border-radius: 5px;
  background: rgba(255,255,255,.06);
}

@media (max-width: 650px) {
  .fk-quest-panel {
    top: auto;
    right: 10px;
    bottom: 12px;
    width: min(235px, 58%);
  }

  .fk-title-panel {
    top: 10px;
    left: 10px;
  }

  .fk-game-title {
    font-size: 14px;
  }

  .fk-location {
    top: 78px;
    font-size: 11px;
  }

  .fk-controls {
    bottom: 12px;
    left: 10px;
    font-size: 10px;
  }

  .fk-actions {
    top: 100px;
    left: 10px;
  }

  .fk-button {
    min-width: 88px;
    padding: 7px 9px;
    font-size: 11px;
  }

  .fk-interaction {
    bottom: 125px;
    font-size: 12px;
  }
}
