:root{
  /* Authoring space (matches client.js BASE_W/H) */
  --base-w: 1920;
  --base-h: 1080;

  /* Layout */
  --gap: 10px;

  /* Center column rows (in authored px) */
  --top-h: 400px;
  --hud-h: 260px;
  --input-h: 72px;

  /* Theme */
  --bg0: #061423;
  --outline2: rgba(120,190,255,.35);
  --boxA: rgba(10,38,63,.72);
  --boxB: rgba(14,52,86,.66);
  --inner: rgba(4,18,32,.50);

  --text: #d8ecff;
  --muted: #a7d2ff;
  --accent: #ffb44a;

  --radius: 12px;
  --radius2: 10px;
  --bw: 1px;
  --p: 6px;

  /* written by client.js; safe default */
  --s: 1;
}

*{ box-sizing: border-box; }

html, body{
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  padding: 10px;
}

body{
  font-family: Arial, Helvetica, sans-serif;
  background: radial-gradient(1200px 800px at 50% 0%, #0b2a46 0%, var(--bg0) 60%, #030912 100%);
  color: var(--text);
}

/* =========================================================
   VIEWPORT + SCALE CONTRACT
   client.js sets #aa_stage width/height = BASE*s
   CSS scales #aa_scale by --s
   ========================================================= */

#aa_shell{
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden; /* only clipping boundary */
}

/* IMPORTANT:
   - keep visible so transform rounding cannot crop edges
   - size is controlled by JS inline styles */
#aa_stage{
  position: relative;
  overflow: visible;
}

/* Authored surface */
#aa_scale{
  width: calc(var(--base-w) * 1px);
  height: calc(var(--base-h) * 1px);

  transform: scale(var(--s));
  transform-origin: top left;

  overflow: visible; /* do not crop at transform boundary */
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
}

/* =========================================================
   OUTER GRID: 3 columns
   Left + Right span full height
   Center is its OWN grid (no display:contents dependency)
   ========================================================= */

#aa_grid{
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;

  display: grid;
  grid-template-columns: 30fr 40fr 30fr;
  grid-template-rows: 1fr;
  gap: var(--gap);
  align-items: stretch;
}

/* Left and right are direct children of #aa_grid */
#aa_left_panel{ grid-column: 1; grid-row: 1; }
#aa_right_panel{ grid-column: 3; grid-row: 1; }

/* Center column becomes a real grid with 4 rows */
#aa_center_col{
  grid-column: 2;
  grid-row: 1;

  display: grid;
  grid-template-rows:
    var(--top-h)
    var(--hud-h)
    1fr
    var(--input-h);
  gap: var(--gap);

  min-width: 0;
  min-height: 0;
}

/* Place center children into the center grid rows */
#aa_top_split{ grid-row: 1; }
#aa_hud_panel{ grid-row: 2; }
#aa_memory_panel{ grid-row: 3; }
#aa_input_panel{ grid-row: 4; }

/* Top split (movement + sensory) */
#aa_top_split{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gap);
  min-width: 0;
  min-height: 0;
}

/* =========================================================
   SHARED PANEL STYLING
   ========================================================= */

.aa_box{
  border: var(--bw) solid var(--outline2);
  background: linear-gradient(180deg, var(--boxB), var(--boxA));
  border-radius: var(--radius);
  overflow: hidden;

  min-width: 0;
  min-height: 0;

  display: flex;
  flex-direction: column;
}

.aa_label{
  padding: 4px 6px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .4px;
  color: rgba(216,236,255,.82);
  text-transform: lowercase;
  user-select: none;
}

/* KEY: body must be flex-fill for scroll areas to fill available height */
.aa_body{
  padding: 0 var(--p) var(--p) var(--p);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.25;

  min-width: 0;
  min-height: 0;

  flex: 1;
  display: flex;
  flex-direction: column;
}

/* KEY: scroll area must flex-fill the body */
.aa_scroll{
  background: var(--inner);
  border: var(--bw) solid rgba(120,190,255,.18);
  border-radius: var(--radius2);
  padding: var(--p);

  overflow: auto;
  min-width: 0;
  min-height: 0;

  flex: 1;
  color: var(--text);
}

/* =========================================================
   HUD
   ========================================================= */

#aa_hud_panel{ padding-bottom: 0; }

#aa_hud_title{
  text-align: center;
  font-size: 18px;
  font-weight: 900;
  letter-spacing: .6px;
  margin: 0;
  padding: 2px 0;
  color: rgba(216,236,255,.92);
}

#aa_hud_strip{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px 10px;
  padding: 0 6px 4px 6px;
  font-size: 13px;
  font-weight: 800;
  min-width: 0;
}

.kv{ display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; min-width: 0; }
.k{ color: var(--accent); font-weight: 900; }
.v{ color: var(--text); font-weight: 900; }

/* Hero takes remaining height in HUD panel */
#aa_hud_hero{
  margin: 4px 6px 6px 6px;
  padding: var(--p);
  border-radius: var(--radius2);
  background: rgba(4,18,32,.55);
  border: var(--bw) solid rgba(120,190,255,.18);

  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow: auto;
}

/* =========================================================
   MEMORY / PROOF
   ========================================================= */

#aa_memory_list{
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.mem_item{
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(4,18,32,.55);
  border: var(--bw) solid rgba(120,190,255,.22);
  color: #e6f2ff;
  font-weight: 900;
  font-size: 14px;
  flex: 0 0 auto;
  align-self: flex-start;
}

/* =========================================================
   INPUT
   ========================================================= */

/* Input panel body should not try to consume extra height */
#aa_input_panel .aa_body{
  flex: 0;
  padding-top: 0;
}

#aa_input{
  width: 100%;
  height: 44px;
  padding: 10px 10px;

  border-radius: 10px;
  border: var(--bw) solid rgba(120,190,255,.35);
  background: rgba(4,18,32,.55);
  color: var(--text);

  font-size: 15px;
  font-weight: 800;
  outline: none;
  min-width: 0;
}

#aa_input:focus{
  border-color: rgba(120,190,255,.75);
  box-shadow: 0 0 0 3px rgba(47,121,199,.18);
}
#aa_debug{
  position: absolute;
  top: 6px;
  left: 6px;
  z-index: 9999;
  padding: 6px 8px;
  border-radius: 8px;
  font: 12px/1.2 monospace;
  color: #fff;
  background: rgba(0,0,0,.65);
  border: 1px solid rgba(255,255,255,.25);
  pointer-events: none;
}




/* Main wrapper for interface */
#interface-wrapper {
  display: flex;
  flex-direction: row;
  width: 100%;
  height: 100%;
  padding: 10px; /* Outer padding around the interface */
  box-sizing: border-box; /* Ensure padding is applied correctly */
}

/* Walls for resizing */
#left-wall, #right-wall {
  width: 3px; /* Wall thickness */
  background-color: #fff; /* Wall color */
  cursor: ew-resize; /* Change the cursor to indicate resizing */
}

/* The main UI area between the walls */
#main-ui {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden; /* Ensure no overflow outside of the main UI */
}

/* This will handle resizing of the walls dynamically */
#interface-wrapper {
  display: flex;
  flex-direction: row;
  width: 100%;
  height: 100%;
  padding: 10px;
}

/* Main UI content area */
#main-ui {
  display: flex;
  flex-direction: column;
  width: calc(100% - 6px); /* 100% width minus wall thickness (3px on each side) */
  height: 100%;
  overflow: hidden; /* Prevent overflow */
  padding: 10px; /* Padding inside the main content area */
}
