/* world.css — the game screen: canvas, on-screen pad, dialog, directory. */

html, body { height: 100%; }
body { overflow: hidden; background: var(--ink); }

.world {
  position: relative;
  height: 100svh;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* --- Top bar ------------------------------------------------------- */

.world__bar {
  position: relative;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  padding: 10px var(--gutter);
  background: rgba(23, 18, 42, 0.92);
  border-bottom: 2px solid var(--panel-edge);
}
.world__bar a, .world__bar button {
  font-family: var(--font-pixel);
  font-size: 10px;
}
.world__home { color: var(--text-dim); text-decoration: none; padding: 8px 0; }
.world__home:hover { color: var(--lamp); }
.world__bar-actions { display: flex; gap: 8px; }
.world__bar .btn { min-height: 40px; padding: 9px 14px; font-size: 10px; }

/* --- Stage --------------------------------------------------------- */

.world__stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
}

#stage {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  touch-action: none;           /* the pad handles touch, not the browser */
}
#stage:focus-visible { outline: 3px solid var(--lamp); outline-offset: -3px; }

.world__loading {
  position: absolute;
  inset: 0;
  margin: 0;                    /* a <p>'s default margin would leak the canvas */
  display: grid;
  place-items: center;
  font-family: var(--font-pixel);
  font-size: 11px;
  color: var(--text-dim);
  background: var(--ink);
}

/* The "press Enter" prompt. */
.world__hint {
  position: absolute;
  margin: 0;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  z-index: 3;
  padding: 10px 16px;
  max-width: calc(100% - 32px);
  text-align: center;
  font-family: var(--font-pixel);
  font-size: 10px;
  line-height: 1.6;
  color: var(--text);
  background: rgba(23, 18, 42, 0.94);
  border: 2px solid var(--lamp);
  border-radius: var(--radius);
}

/* An explicit display:* above beats the UA stylesheet's [hidden] rule,
   so these have to opt back out by hand. */
.world__loading[hidden], .world__hint[hidden] { display: none; }

/* --- On-screen pad ------------------------------------------------- */
/* Shown only where the primary input is a finger. */

.pad { display: none; }

@media (pointer: coarse) {
  .pad {
    display: block;
    position: absolute;
    inset: auto 0 0 0;
    z-index: 4;
    padding: 0 18px 22px;
    pointer-events: none;
  }
  .pad__cluster {
    display: grid;
    grid-template-columns: repeat(3, 56px);
    grid-template-rows: repeat(3, 56px);
    gap: 4px;
    width: max-content;
    pointer-events: auto;
  }
  .pad__btn {
    display: grid;
    place-items: center;
    font-size: 20px;
    color: var(--text);
    background: rgba(42, 33, 69, 0.85);
    border: 2px solid var(--panel-edge);
    border-radius: var(--radius);
    -webkit-tap-highlight-color: transparent;
    user-select: none;
  }
  .pad__btn[data-on] { background: var(--lamp); color: var(--ink); }
  .pad__up    { grid-area: 1 / 2; }
  .pad__left  { grid-area: 2 / 1; }
  .pad__right { grid-area: 2 / 3; }
  .pad__down  { grid-area: 3 / 2; }

  .pad__action {
    position: absolute;
    right: 18px;
    bottom: 40px;
    width: 76px;
    height: 76px;
    border-radius: 50%;
    pointer-events: auto;
    font-family: var(--font-pixel);
    font-size: 11px;
    color: var(--ink);
    background: var(--lamp);
    border: 3px solid var(--lamp-deep);
  }
  .world__hint { bottom: 200px; }
}

/* --- Dialog -------------------------------------------------------- */

.dlg { position: fixed; inset: 0; z-index: 20; }
.dlg[hidden] { display: none; }

.dlg__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 8, 20, 0.78);
  border: 0;
  width: 100%;
  cursor: pointer;
}

.dlg__panel {
  position: relative;
  z-index: 1;
  max-width: 720px;
  margin: 0 auto;
  max-height: 100svh;
  max-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 3px solid var(--lamp);
  border-radius: var(--radius);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
}
@media (min-width: 760px) {
  .dlg__panel { margin: 5vh auto; max-height: 90vh; }
}

.dlg__head {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 2px solid var(--panel-edge);
}
.dlg__head h2 {
  margin: 0;
  font-family: var(--font-pixel);
  font-size: 12px;
  line-height: 1.6;
  color: var(--lamp);
}
.dlg__close {
  flex: 0 0 auto;
  min-width: 44px;
  min-height: 44px;
  font-size: 20px;
  color: var(--text);
  background: var(--panel-soft);
  border: 2px solid var(--panel-edge);
  border-radius: var(--radius);
  cursor: pointer;
}
.dlg__close:hover { border-color: var(--lamp); }

.dlg__body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 18px;
}
.dlg__lead { margin: 0 0 8px; color: var(--text); font-size: 1.04rem; }
.dlg__block { margin-top: 26px; }
.dlg__block h3 { margin: 0; font-size: 1.05rem; }
.dlg__meta {
  margin: 4px 0 0;
  font-size: 0.88rem;
  color: var(--text-quiet);
  font-variant-numeric: tabular-nums;
}
.dlg__block ul { margin: 12px 0 0; padding-left: 1.15em; }
.dlg__block li { margin-bottom: 11px; color: var(--text-dim); }
.dlg__block li::marker { color: var(--grass); }
.dlg__note {
  margin: 12px 0 0;
  padding: 10px 12px;
  font-size: 0.92rem;
  color: var(--text-dim);
  background: var(--panel-soft);
  border-left: 3px solid var(--lamp);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.dlg__links {
  margin: 26px 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 20px;
}
.dlg__links a { padding: 6px 0; display: inline-block; }

/* --- Text directory ------------------------------------------------ */

.dir {
  position: relative;
  z-index: 5;
  padding: 10px var(--gutter) 12px;
  background: rgba(23, 18, 42, 0.92);
  border-top: 2px solid var(--panel-edge);
}
.dir__title {
  margin: 0 0 8px;
  font-size: 0.86rem;
  color: var(--text-quiet);
}
.dir__list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.dir__btn {
  min-height: 40px;
  padding: 8px 14px;
  font-family: var(--font-body);
  font-size: 0.92rem;
  color: var(--text);
  background: var(--panel-soft);
  border: 2px solid var(--panel-edge);
  border-radius: var(--radius);
  cursor: pointer;
}
.dir__btn:hover { border-color: var(--lamp); }

@media (pointer: coarse) {
  /* The pad owns the bottom of the screen on touch devices. */
  .dir { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .dlg__panel { box-shadow: none; }
}

/* The construction banner rides in the top bar on roomy screens. On a
   phone it would wrap the bar to three rows and eat a third of the map,
   so it stays behind on the start screen, which everyone passes through. */
.world__bar .construction { font-size: 8px; padding: 7px 11px; }

@media (max-width: 620px) {
  .world__bar .construction { display: none; }
}
