:root {
  font-family: system-ui, sans-serif;
  color-scheme: dark;
  background: #121923;
  color: #f0f2f5;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  padding: clamp(0.5rem, 1.5vw, 1.5rem);
}
main { width: min(100%, 1200px); margin: 0 auto; }
h1 { margin: 0; font-size: clamp(1.15rem, 2.5vw, 1.8rem); }
p { margin: 0; line-height: 1.45; }
small { color: #b9c4d1; line-height: 1.4; }
.field-preview {
  display: grid;
  gap: 0.55rem;
  width: 100%;
}
.field-canvas {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  height: auto;
  background: #111822;
  border: 1px solid #607080;
  border-radius: 3px;
  touch-action: none;
  overscroll-behavior: contain;
  outline-offset: 3px;
}
.field-canvas:focus-visible { outline: 2px solid #d1e6ff; }
.field-status { min-height: 1.45em; font-variant-numeric: tabular-nums; }
@media (orientation: landscape) and (max-height: 560px) {
  body { padding: 0.25rem; }
  .field-preview { gap: 0.2rem; }
  .field-canvas { width: min(100%, calc((100dvh - 4.4rem) * 16 / 9)); margin: 0 auto; }
  .field-preview h1 { font-size: 1rem; }
  .field-preview p, .field-preview small { font-size: 0.72rem; }
}

/* I2 controls are ordinary semantic actions, never alternative engine state. */
.field-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
}
.field-toolbar button {
  min-height: 2.4rem;
  min-width: 5.3rem;
  padding: 0.5rem 0.8rem;
  border: 1px solid #697f96;
  border-radius: 0.4rem;
  background: #24354a;
  color: inherit;
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
}
.field-toolbar button:disabled { opacity: 0.55; cursor: not-allowed; }
.field-toolbar button:focus-visible, .grandia-dialogue-panel button:focus-visible {
  outline: 2px solid #c5e1fa;
  outline-offset: 2px;
}
.field-feedback { min-height: 1.4em; font-size: 0.9rem; }
.field-dialogue-host { position: relative; z-index: 4; }
.grandia-dialogue-panel {
  position: fixed;
  z-index: 10;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(95vw, 35rem);
  max-height: 82dvh;
  overflow: auto;
  padding: 1rem;
  background: #18283b;
  border: 2px solid #8ca9c8;
  border-radius: 0.7rem;
  box-shadow: 0 0 0 100vmax #0009;
  display: grid;
  gap: 0.9rem;
}
.grandia-dialogue-panel[hidden] { display: none; }
.grandia-dialogue-content { display: flex; flex-direction: column; gap: 0.5rem; }
.grandia-dialogue-actions, .grandia-dialogue-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}
.grandia-dialogue-panel button {
  min-height: 2.7rem;
  padding: 0.6rem 0.8rem;
  border: 1px solid #7f9fc5;
  border-radius: 0.4rem;
  background: #2c425c;
  color: inherit;
  font: inherit;
  touch-action: manipulation;
}
@media (orientation: landscape) and (max-height: 560px) {
  .field-toolbar { gap: 0.2rem; justify-content: center; }
  .field-toolbar button { min-height: 1.9rem; font-size: 0.75rem; padding: 0.2rem 0.45rem; }
  .grandia-dialogue-panel { padding: 0.6rem; max-height: 94dvh; gap: 0.4rem; }
  .grandia-dialogue-panel button { min-height: 2rem; padding: 0.4rem; }
}

/* SYSTEMS-04 receipt-verified notice is view-only and never captures field touches. */
.grandia-inventory-award-notice:not([hidden]) {
  position: fixed;
  z-index: 9;
  top: max(0.75rem, env(safe-area-inset-top, 0px));
  right: max(0.75rem, env(safe-area-inset-right, 0px));
  max-width: min(24rem, 88vw);
  padding: 0.7rem 0.95rem;
  border: 1px solid #a7c99a;
  border-radius: 0.5rem;
  background: #1d3b2d;
  color: #f0f6eb;
  box-shadow: 0 0.3rem 1.3rem #0009;
  pointer-events: none;
  overflow-wrap: anywhere;
}
@media (orientation: landscape) and (max-height: 560px) {
  .grandia-inventory-award-notice:not([hidden]) {
    font-size: 0.8rem;
    top: max(0.25rem, env(safe-area-inset-top, 0px));
    right: max(0.25rem, env(safe-area-inset-right, 0px));
  }
}

/* LEAD P-08: SYSTEMS-05 inventory view in the same CORE chapter host.
   A true modal intentionally occludes the field only while open. */
.field-inventory-host { position: relative; z-index: 12; }
.grandia-inventory-menu[hidden] { display: none; }
.grandia-inventory-menu:not([hidden]) {
  position: fixed;
  z-index: 12;
  inset: auto;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: grid;
  gap: 0.6rem;
  width: min(95vw, 42rem);
  max-height: 88dvh;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 1rem;
  color: #f0f2f5;
  background: #17273a;
  border: 2px solid #8ca9c8;
  border-radius: 0.7rem;
  box-shadow: 0 0 0 100vmax #000b;
}
.grandia-inventory-menu-body {
  display: grid;
  gap: 0.55rem;
}
.grandia-inventory-menu-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
}
.grandia-inventory-menu-group h3 {
  flex-basis: 100%;
  font-size: 0.93rem;
  margin: 0.2rem 0 0;
}
.grandia-inventory-menu button {
  min-height: 2.5rem;
  padding: 0.5rem 0.7rem;
  font: inherit;
  color: inherit;
  background: #2b405d;
  border: 1px solid #789abd;
  border-radius: 0.35rem;
  touch-action: manipulation;
  cursor: pointer;
}
.grandia-inventory-menu button:disabled { opacity: 0.45; cursor: not-allowed; }
.grandia-inventory-menu button:focus-visible {
  outline: 2px solid #e5f4ff;
  outline-offset: 2px;
}
@media (orientation: landscape) and (max-height: 560px) {
  .grandia-inventory-menu:not([hidden]) {
    max-height: 95dvh;
    padding: 0.45rem;
    gap: 0.25rem;
  }
  .grandia-inventory-menu button { min-height: 2rem; padding: 0.3rem 0.45rem; }
}
