:root {
  color-scheme: dark;
  --page: #090b10;
  --gold: #d9b574;
  --gold-dim: #80633d;
  --ink: #e9dfc9;
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--page);
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--ink);
  font-family: "Courier New", ui-monospace, monospace;
  background: #101522;
}

.app {
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  gap: clamp(6px, 1vh, 12px);
  width: 100%;
  height: 100vh;
  height: 100dvh;
  min-width: 0;
  min-height: 0;
  padding: 0;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  min-height: 34px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  border: 1px solid #665139;
  background: #211c1b;
  color: var(--gold);
  font-size: 13px;
  box-shadow: inset 0 -4px #100f13;
}

.brand-name {
  color: #e7ddca;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .18em;
}

.brand-name span { color: var(--gold-dim); }

.brand-caption {
  margin-top: 3px;
  color: #777780;
  font-size: 8px;
  letter-spacing: .1em;
}

.build-info {
  display: flex;
  align-items: center;
  gap: 7px;
  color: #a6a0a0;
  font-size: 9px;
  letter-spacing: .09em;
  white-space: nowrap;
}

.resolution, .mode-label {
  padding: 5px 7px;
  border: 1px solid #38343a;
  background: #111219;
  color: #d5c5a5;
}

.mode-label {
  border-color: #314238;
  background: #121b18;
  color: #9ab49d;
}

.game-area {
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  gap: 0;
  width: 100%;
  min-width: 0;
  min-height: 0;
}

.screen-bezel {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 0;
  background: #101522;
  box-shadow: none;
  overflow: hidden;
}

.screen-inner {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: #101522;
  box-shadow: none;
}

.game-hotspot-layer {
  position: absolute;
  z-index: 3;
  inset: 0;
  overflow: visible;
  pointer-events: none;
}

.game-hotspot {
  position: absolute;
  display: block;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid transparent;
  border-radius: 2px;
  background: transparent;
  color: transparent;
  font-size: 0;
  line-height: 0;
  text-indent: -9999px;
  white-space: nowrap;
  cursor: pointer;
  pointer-events: auto;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: transform 100ms ease, filter 100ms ease;
}

@media (hover: hover) and (pointer: fine) {
  .game-hotspot:hover {
    transform: translateY(-1px);
    filter: brightness(1.06);
  }
}

.game-hotspot:active {
  transform: scale(.98);
  filter: brightness(.94);
}

.game-hotspot:focus { outline: none; }
.game-hotspot:focus-visible {
  border-color: #e8c98f;
  outline: 1px solid #e8c98f;
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .game-hotspot { transition: none; }
}


#game-screen {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  outline: none;
}

.screen-caption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  min-height: 12px;
  padding: 0 2px;
  color: #76747b;
  font-size: 8px;
  letter-spacing: .1em;
  white-space: nowrap;
}

.fullscreen-button {
  position: fixed;
  z-index: 10000;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 32px;
  flex: 0 0 34px;
  padding: 0;
  border: 1px solid #514536;
  border-radius: 3px;
  background: #17151acc;
  color: #d9b574;
  backdrop-filter: blur(5px);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.fullscreen-button svg {
  display: block;
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: square;
  stroke-linejoin: miter;
}

.fullscreen-button .exit-icon { display: none; }
.fullscreen-button.is-active .enter-icon { display: none; }
.fullscreen-button.is-active .exit-icon { display: block; }

.fullscreen-button:active { background: #2b2522; }
.fullscreen-button:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}
.fullscreen-button:disabled {
  opacity: .4;
  cursor: not-allowed;
}

@media (max-width: 620px) {
  .fullscreen-button {
    top: max(8px, env(safe-area-inset-top));
    right: max(8px, env(safe-area-inset-right));
  }
}

@media (max-height: 480px) {
  .app { padding: 5px; }
}


/* Immersive fallback for mobile browsers without the Fullscreen API. */
body.fullscreen-fallback .app {
  position: fixed;
  inset: 0;
  z-index: 9999;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  gap: 0;
  padding: 0;
  background: #090b10;
}

body.fullscreen-fallback .game-area {
  grid-template-rows: minmax(0, 1fr);
  gap: 0;
}

body.fullscreen-fallback .screen-bezel {
  padding: 0;
  border: 0;
  box-shadow: none;
  background: #101522;
}

body.fullscreen-fallback .screen-inner {
  box-shadow: none;
}


.return-home-button {
  position: fixed;
  z-index: 10000;
  top: max(12px, env(safe-area-inset-top));
  left: max(12px, env(safe-area-inset-left));
  display: none;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 32px;
  padding: 0;
  border: 1px solid #514536;
  border-radius: 3px;
  background: #17151acc;
  color: #d9b574;
  font: 24px/1 "Courier New", monospace;
  cursor: pointer;
  backdrop-filter: blur(5px);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
body.dungeon-active .return-home-button { display: inline-flex; }
.return-home-button:active { background: #2b2522; transform: translateY(1px); }
.return-home-button:focus-visible { outline: 1px solid #e8c98f; outline-offset: 2px; }
body.dungeon-active .game-hotspot-layer { display: none; }


body.dungeon-active #game-screen {
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}


/* Melee action for keyboard, mouse, and touch players. */
.attack-button {
  position: fixed;
  z-index: 10001;
  right: max(14px, env(safe-area-inset-right));
  bottom: max(14px, env(safe-area-inset-bottom));
  display: none;
  align-items: center;
  justify-content: center;
  min-width: 72px;
  height: 38px;
  padding: 0 10px;
  border: 1px solid #80633d;
  border-radius: 3px;
  background: #211c1b;
  color: #f0dfbd;
  font: bold 10px/1 "Courier New", monospace;
  letter-spacing: .8px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
body.dungeon-active .attack-button { display: inline-flex; }
.attack-button:active { background: #3a2925; transform: translateY(1px); }
.attack-button:focus-visible { outline: 1px solid #e8c98f; outline-offset: 2px; }
