/* Moria touch layer — moria.iveoapps.no
   Design: terminal-purisme (hvit/svart) + én aksent (rav #ffb000, klassisk CRT).
   Spillet i midten m/kamera som følger @, kontrolldekk nederst. */

:root {
  --accent: #ffb000;
  --accent-dim: #8a6200;
  --surface: #111;
  --line: #2a2a2a;
  --deck-h: 204px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

html, body {
  margin: 0 !important;
  padding: 0 !important;
  background: #000 !important;
  overflow: hidden !important;
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block !important;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}

/* --- lag: meldingslinje / spill / status / dekk --- */
#mt-msg, #mt-status {
  position: fixed;
  left: 0; right: 0;
  font: 12px/1.5 ui-monospace, Menlo, monospace;
  padding: 4px 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  z-index: 30;
  background: rgba(0,0,0,.92);
}
#mt-msg { top: 0; color: #fff; border-bottom: 1px solid var(--line); min-height: 22px; }
#mt-status { bottom: calc(var(--deck-h) + var(--safe-b)); color: var(--accent); border-top: 1px solid var(--line); display: flex; gap: 14px; }
#mt-status span b { color: #fff; font-weight: 600; }

#mt-frame {
  position: fixed;
  top: 23px;
  left: 0; right: 0;
  bottom: calc(var(--deck-h) + var(--safe-b) + 23px);
  width: 100%;
  height: calc(100% - var(--deck-h) - var(--safe-b) - 46px);
  border: 0;
  background: #000;
  z-index: 10;
}

/* --- kontrolldekk --- */
#mt-deck {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: calc(var(--deck-h) + var(--safe-b));
  padding: 8px 10px calc(8px + var(--safe-b));
  box-sizing: border-box;
  background: linear-gradient(#0b0b0b, #050505);
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: 156px 1fr;
  grid-template-rows: 32px 156px;
  gap: 8px;
  z-index: 40;
}

/* systemrad øverst i dekket, full bredde */
#mt-sysrow {
  grid-column: 1 / -1;
  display: flex;
  gap: 6px;
}
#mt-sysrow .mt-btn { flex: 1; height: 32px; font-size: 12px; }

/* d-pad */
#mt-dpad {
  position: relative;
  width: 156px;
  height: 156px;
}
#mt-dpad button {
  position: absolute;
  width: 48px; height: 48px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--accent);
  font: 20px ui-monospace, Menlo, monospace;
  display: grid;
  place-items: center;
  padding: 0;
}
#mt-dpad button:active { background: var(--accent); color: #000; }
.dp-nw { top: 0; left: 0; }   .dp-n { top: 0; left: 54px; }   .dp-ne { top: 0; left: 108px; }
.dp-w { top: 54px; left: 0; } .dp-c { top: 54px; left: 54px; color: #555 !important; }
.dp-e { top: 54px; left: 108px; }
.dp-sw { top: 108px; left: 0; } .dp-s { top: 108px; left: 54px; } .dp-se { top: 108px; left: 108px; }

/* kommandoknapper */
#mt-cmds {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: 1fr;
  gap: 6px;
  align-self: stretch;
}

.mt-btn {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: #ddd;
  font: 13px/1.2 ui-monospace, Menlo, monospace;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 0;
}
.mt-btn small { color: var(--accent-dim); font-size: 10px; }
.mt-btn:active { background: var(--accent); color: #000; }
.mt-btn:active small { color: #000; }

/* --- bokstav-grid (modal) --- */
#mt-keys {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.88);
  z-index: 60;
  display: none;
  flex-direction: column;
  justify-content: flex-end;
  padding: 0 8px calc(10px + var(--safe-b));
  box-sizing: border-box;
}
#mt-keys.open { display: flex; }
#mt-keys .mt-krow { display: flex; gap: 5px; margin-top: 5px; }
#mt-keys button {
  flex: 1;
  height: 44px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #fff;
  font: 16px ui-monospace, Menlo, monospace;
  padding: 0;
}
#mt-keys button:active { background: var(--accent); color: #000; }
#mt-keys button.mt-wide { flex: 1.6; font-size: 12px; color: var(--accent); }
#mt-keys button.mt-on { background: var(--accent-dim); }
