* {
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
}

html {
  /* Scale 1rem = 16px at 1920×1080; shrinks/grows proportionally on any DPI or window size */
  --kiosk-fluid-rem: min(calc(100vw / 120), calc(100vh / 77.5));
  font-size: var(--kiosk-fluid-rem);
  /* Whole-pixel root keeps rem-derived font sizes on the pixel grid (avoids mushy text). */
  font-size: round(nearest, var(--kiosk-fluid-rem), 1px);
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-family-base);
  background-color: #010101;
  background-image: url("../images/background.png");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  color: var(--color-text);
}

body {
  position: relative;
  overscroll-behavior: none;
}

.app-shell {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 0.75rem;
  padding: 1rem 1.25rem 0.625rem;
  position: relative;
  z-index: 1;
}

.app-header h1 {
  margin: 0;
  font-size: 1.8rem;
}

.app-header p {
  margin: 0.25rem 0 0;
  color: var(--color-subtle);
}

.app-content {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.25rem;
  align-items: stretch;
  align-content: stretch;
  position: relative;
  overflow: visible;
}

/* MapConfig WS log panel: outside app layout, centered overlay */
connection-panel {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 2000;
  width: min(26rem, calc(100vw - 2.5rem));
  height: 80%;
  max-height: 80vh;
  min-height: 0;
}

body.connection-panel-hidden connection-panel {
  display: none !important;
}

.app-footer {
  display: flex;
  gap: 1.2rem;
  font-family: var(--font-family-mono);
  color: var(--color-subtle);
  font-size: 0.85rem;
}

#widgetGrid {
  width: 100%;
  height: 100%;
  min-height: 0;
  align-self: stretch;
}

body.connection-panel-hidden #widgetGrid {
  margin-left: -1.25rem;
  margin-right: -1.25rem;
  margin-bottom: -0.625rem;

  width: calc(100% + 2.5rem);
  height: calc(100% + 0.625rem);
}

#kioskTopBar {
  top: 0;
  left: 0;
  right: 0;
  position: absolute;
  z-index: 1000;
}

#aiChatPanel {
  /* kiosk-top-bar2 header height (3rem) + 1rem gap before extra nav */
  top: calc(3rem + 1rem);
  left: 2.5rem;
  position: absolute;
  z-index: 1000;
}

/* Decorative canvas toolbar: right edge, vertically centered; img stays position static. */
.canvas-toolbar-layer {
  position: fixed;
  inset: 0;
  z-index: 1500;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 1.25rem;
  pointer-events: none;
}

.canvas-toolbar-img {
  position: static;
  display: block;
  width: auto;
  height: auto;
  max-height: min(42.5vh, 28rem);
}
