/* Temple of Gu's four official colors: shared across the Living Table.
   The illustrated playfield is an independent art layer, not recolored by UI CSS. */
:root {
  color-scheme: dark;
  --temple-bg: #495A58;
  --temple-panel: #303636;
  --temple-accent: #FF5E1F;
  --temple-text: #FFFFFF;
  --line: color-mix(in srgb, var(--temple-text) 24%, transparent);
  --dim: color-mix(in srgb, var(--temple-text) 80%, var(--temple-panel));
  font-family: system-ui, sans-serif;
  background: var(--temple-bg);
  color: var(--temple-text);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--temple-bg); color: var(--temple-text); }
a { color: var(--temple-accent); text-underline-offset: .2em; }
a:hover { text-decoration-thickness: 2px; }
button, select, .file-action { font: inherit; }
button, .file-action {
  border: 1px solid var(--temple-accent);
  background: var(--temple-panel);
  color: var(--temple-text);
  border-radius: 8px;
  padding: .55rem .8rem;
  cursor: pointer;
}
button:hover, .file-action:hover {
  background: color-mix(in srgb, var(--temple-panel) 78%, var(--temple-accent));
}
button:focus-visible, select:focus-visible, input:focus-visible,
.hotspot:focus-visible, .token:focus-visible, a:focus-visible {
  outline: 3px solid var(--temple-accent);
  outline-offset: 3px;
}
/* Light text on orange is ~3.06:1, so orange buttons use WCAG large text (>=18.66px bold, 3:1). */
.primary { background: var(--temple-accent); border-color: var(--temple-accent); color: var(--temple-text); font-size: 1.1875rem; font-weight: 750; }
.primary:hover { background: var(--temple-accent); filter: brightness(.92); }
.eyebrow { letter-spacing: .16em; color: var(--temple-accent); font-size: .75rem; font-weight: 750; text-transform: uppercase; }
.mast {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  flex-wrap: wrap;
  padding: .6rem 1.5vw; border-bottom: 1px solid var(--line); background: var(--temple-panel);
}
.mast h1 { font-family: Georgia, serif; margin: .1rem 0; font-size: clamp(1.45rem, 2.4vw, 2.2rem); color: var(--temple-text); }
.mast p { margin: .3rem 0; }
.head-actions { display: flex; gap: .5rem; flex-wrap: wrap; flex: 0 0 auto; }
/* The file input stays in the tab order (covering its label) so Import is keyboard-operable. */
.file-action { position: relative; display: inline-block; }
.file-action input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; font-size: 0; }
.file-action:focus-within { outline: 3px solid var(--temple-accent); outline-offset: 2px; }
.layout { display: grid; grid-template-columns: minmax(0,1fr) minmax(270px,330px); gap: 1rem; padding: 1rem; max-width: 1900px; margin: auto; }
.table-section { min-width: 0; }
.fine { font-size: .82rem; color: var(--dim); }
.board-frame { border: 3px solid var(--temple-accent); overflow: hidden; background: var(--temple-panel); }
.board { position: relative; width: 100%; aspect-ratio: 4/3; touch-action: none; }
/* Existing 16:9 scene art temporarily fills the 4:3 playfield without cropping its interactive locations. Future scene art will be authored at 4:3. */
.board img { display: block; width: 100%; height: 100%; object-fit: fill; pointer-events: none; user-select: none; }
.hotspot, .token { position: absolute; transform: translate(-50%,-50%); z-index: 2; }
.hotspot {
  border: 2px solid var(--temple-accent); background: var(--temple-panel);
  border-radius: 50%; width: clamp(24px,3vw,39px); aspect-ratio: 1;
  display: grid; place-items: center; color: var(--temple-text);
  font-weight: 900; font-size: 1.1875rem; line-height: 1; box-shadow: 0 0 0 5px color-mix(in srgb, var(--temple-panel) 56%, transparent);
  padding: 0;
}
.hotspot:hover, .hotspot.active { background: var(--temple-accent); color: var(--temple-text); }
.token {
  width: clamp(28px,3.5vw,54px); height: clamp(28px,3.5vw,54px); padding: 0;
  border: 3px solid var(--temple-accent); border-radius: 50%;
  background: var(--temple-panel); color: var(--temple-text);
  font-family: Georgia, serif; font-weight: 900; font-size: clamp(1.1875rem,2vw,1.3rem);
  box-shadow: 0 3px 9px color-mix(in srgb, var(--temple-panel) 72%, transparent);
  cursor: grab; touch-action: none;
}
.token.selected { background: var(--temple-accent); color: var(--temple-text); outline: 3px solid var(--temple-text); outline-offset: 3px; z-index: 4; }
.token:active { cursor: grabbing; }
.movement {
  display: flex; gap: .45rem; align-items: center; flex-wrap: wrap;
  padding: .75rem; background: var(--temple-panel); border-radius: 0 0 12px 12px;
}
.sidebar { display: grid; gap: .8rem; align-content: start; }
.panel { border: 1px solid var(--line); background: var(--temple-panel); border-radius: 12px; padding: 1rem; }
.panel h2 { font-family: Georgia, serif; margin: .3rem 0; color: var(--temple-text); }
.panel p { line-height: 1.45; }
.panel label { display: block; margin: .5rem 0; }
.panel select {
  display: block; width: 100%; padding: .6rem; background: var(--temple-bg);
  color: var(--temple-text); border: 1px solid var(--line); border-radius: 6px; margin: .4rem 0 .8rem;
}
.panel input[type="number"] {
  display: block; width: 100%; padding: .6rem; margin: .4rem 0 .8rem;
  background: var(--temple-bg); color: var(--temple-text);
  border: 1px solid var(--line); border-radius: 6px; font: inherit;
}
.control-group + .control-group { border-top: 1px solid var(--line); margin-top: 1.25rem; padding-top: 1.25rem; }
.control-group > .eyebrow { margin: .3rem 0 .85rem; }
.panel button { margin: .2rem; }
.statline { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; }
.statline span { background: var(--temple-bg); border: 1px solid var(--line); padding: .5rem; border-radius: 6px; }
.object-button, .solo-button { display: block; width: 100%; text-align: left; }
.fine { border-left: 2px solid var(--temple-accent); padding-left: .7rem; }
footer { padding: 1rem; text-align: center; color: var(--temple-text); }
.footer-links { display: flex; align-items: center; justify-content: center; gap: .55rem; white-space: nowrap; }
@media(max-width:360px) { .footer-links { gap: .3rem; font-size: .875rem; } }
@media(max-width:1100px) { .layout { grid-template-columns: 1fr; } .sidebar { grid-template-columns: repeat(2,minmax(0,1fr)); } }
@media(max-width:600px) { .mast { display: block; padding: .65rem 1rem; } .head-actions { margin-top: .6rem; } .sidebar { grid-template-columns: 1fr; }  .movement span { width: 100%; } }

/* Fill the remaining desktop column height with writing space, not an empty gap.
   The image, controls, and sidebar retain their own dimensions and positions. */
@media (min-width:1101px) {
  .table-section { display: flex; flex-direction: column; }
  .field-journal { display: flex; flex-direction: column; flex: 1 1 auto; }
  #field-journal-notes { flex: 1 1 auto; }
}

/* Scene 01: full-width writing desk below the board, roomy enough for two paragraphs. */
.field-journal {
  margin-top: 1.25rem;
  padding: clamp(1rem,2vw,1.5rem);
  background: var(--temple-panel);
  border: 1px solid var(--line);
  border-top: 3px solid var(--temple-accent);
  border-radius: 12px;
}
.journal-heading { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; margin-bottom: .9rem; }
.journal-heading .eyebrow { margin: 0 0 .35rem; }
.journal-heading h2 { margin: 0; color: var(--temple-text); font: 1.75rem Georgia,serif; }
.journal-tag { color: var(--temple-accent); font-size: .75rem; font-weight: 750; letter-spacing: .14em; white-space: nowrap; }
#field-journal-notes {
  display: block;
  width: 100%;
  height: clamp(340px, 44vh, 560px);
  min-height: 340px;
  padding: 1rem 1.1rem;
  background: var(--temple-bg);
  color: var(--temple-text);
  border: 1px solid var(--line);
  border-radius: 8px;
  font: 1.08rem/1.7 system-ui,sans-serif;
  resize: vertical;
  overflow-y: auto;
  overflow-wrap: anywhere;
}
#field-journal-notes::placeholder { color: var(--dim); opacity: .9; }
#field-journal-notes:focus-visible { outline: 3px solid var(--temple-accent); outline-offset: 3px; }
.journal-footer { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: .5rem 1.5rem; }
.journal-footer p { margin: .8rem 0 0; color: var(--dim); font-size: .82rem; }
#journal-status { color: var(--temple-text); }
@media(max-width:600px) {
  .journal-heading h2 { font-size: 1.5rem; }
  #field-journal-notes { height: 340px; padding: .75rem; font-size: 1rem; }
}

/* Immersive map (double-click / double-tap only; there is no visible button).
   The board is sized at 4:3 and, while immersive, the Scene Journal sits in a
   side column BESIDE it (landscape) or BELOW it (portrait), never over the
   map, so no hotspot or token is ever covered. Outside immersive view the
   column is empty and takes no space. */
.board-frame { position: relative; }
.frame-bar { display: none; }
.board-frame:fullscreen, .board-frame.is-pseudo-fullscreen {
  width: 100vw; height: 100vh; height: 100dvh; border: 0; margin: 0;
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(15rem, 22rem); grid-template-rows: 100%;
  background: var(--temple-panel); overflow: hidden;
}
.board-frame.is-pseudo-fullscreen { position: fixed; inset: 0; z-index: 1000; }
.board-frame:fullscreen .board, .board-frame.is-pseudo-fullscreen .board {
  align-self: center; justify-self: center; width: 100%; max-width: 133.33333vh; max-width: 133.33333dvh; height: auto; aspect-ratio: 4 / 3;
}
.board-frame:fullscreen .board img, .board-frame.is-pseudo-fullscreen .board img { object-fit: fill; }
.board-frame:fullscreen .frame-bar, .board-frame.is-pseudo-fullscreen .frame-bar {
  display: flex; gap: .6rem; padding: .45rem .6rem; background: var(--temple-panel);
  flex-direction: column; justify-content: flex-start; align-items: stretch; border-top: 0; border-left: 1px solid var(--line); overflow: auto; min-height: 0;
}
.board-frame:fullscreen #scene-panel, .board-frame.is-pseudo-fullscreen #scene-panel { margin: 0; }
@media (orientation: portrait) {
  .board-frame:fullscreen, .board-frame.is-pseudo-fullscreen { grid-template-columns: 100%; grid-template-rows: auto minmax(0, 1fr); }
  .board-frame:fullscreen .board, .board-frame.is-pseudo-fullscreen .board { align-self: start; }
  .board-frame:fullscreen .frame-bar, .board-frame.is-pseudo-fullscreen .frame-bar { border-left: 0; border-top: 1px solid var(--line); }
}
body.has-pseudo-fullscreen { overflow: hidden; }
