:root {
  --ink: #183a37;
  --muted: #183a37;
  --paper: #f5f6f1;
  --green: #24634c;
  --line: #d8e1d8;
  --orange: #d88051;
}
* {
  box-sizing: border-box;
}
html {
  scroll-behavior: smooth;
}
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font:
    17px/1.6 -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}
header,
main,
footer {
  max-width: 1440px;
  margin: auto;
  padding-left: 5%;
  padding-right: 5%;
}
header {
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}
a {
  color: inherit;
  text-decoration: none;
}
.brand {
  display: flex;
  align-items: center;
  font-size: 26px;
  font-weight: 750;
  letter-spacing: -1px;
}
.logo-icon {
  display: block;
  width: 76px;
  height: 76px;
  object-fit: contain;
  flex-shrink: 0;
}
.brand {
  gap: 8px;
}
@media (max-width: 680px) {
  .logo-icon {
    width: 64px;
    height: 64px;
  }
}

nav {
  display: flex;
  gap: 32px;
  font-size: 16px;
}
.badge {
  font-size: 14px;
  letter-spacing: 1.5px;
  border: 1px solid #bfd0bd;
  border-radius: 20px;
  padding: 5px 12px;
}
.intro {
  display: flex;
  justify-content: space-between;
  align-items: end;
  padding: 55px 0 36px;
}
.eyebrow {
  font-size: 14px;
  letter-spacing: 2.5px;
  font-weight: 700;
  color: var(--green);
  margin: 0 0 20px;
}
h1 {
  font-family: Georgia, serif;
  font-size: clamp(42px, 4.8vw, 70px);
  line-height: 1.07;
  letter-spacing: -2px;
  font-weight: 400;
  margin: 0;
}
.lede {
  color: var(--muted);
  margin: 22px 0 0;
  font-size: 17px;
}
.intro-note {
  border-left: 1px solid var(--line);
  padding-left: 24px;
  margin-bottom: 4px;
}
.intro-note span {
  font-size: 13px;
  letter-spacing: 2px;
  color: var(--green);
}
.intro-note p {
  font-size: 16px;
  color: var(--muted);
}
.studio {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  background: white;
  border: 1px solid var(--line);
  border-radius: 15px;
  overflow: hidden;
  scroll-margin-top: 20px;
}
.scene-column {
  background: #c8d9e7;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.scene-heading {
  padding: 20px 24px;
  display: flex;
  gap: 14px;
  justify-content: space-between;
  font-size: 15px;
  color: var(--ink);
}
.scene-heading i {
  display: inline-block;
  width: 6px;
  height: 6px;
  background: var(--green);
  border-radius: 50%;
  margin-right: 7px;
}
#saved {
  font-size: 14px;
}
#viewport {
  width: 100%;
  height: 470px;
  position: relative;
  touch-action: none;
}
#viewport canvas {
  width: 100%;
  height: 100%;
  display: block;
}
#loading {
  padding: 30px;
  text-align: center;
}
.scene-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  margin-top: auto;
  font-size: 14px;
  color: var(--ink);
}
.views {
  display: flex;
  gap: 4px;
}
button {
  font: inherit;
  font-size: 15px;
  cursor: pointer;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 12px;
  background: #fff;
  color: var(--ink);
}
button:hover {
  background: #edf2e9;
}
button:disabled {
  opacity: 1;
  color: var(--ink);
  background: #edf0eb;
  border-style: dashed;
  cursor: not-allowed;
}
button[aria-pressed="true"] {
  background: var(--green);
  color: white;
  border-color: var(--green);
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
#viewport:focus-visible {
  outline: 3px solid #df9d39;
  outline-offset: 3px;
}
aside {
  padding: 22px;
  border-left: 1px solid var(--line);
}
.panel-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  font-size: 13px;
  letter-spacing: 1.4px;
  color: var(--muted);
  margin-bottom: 20px;
}
.text-button {
  border: 0;
  padding: 0;
  font-size: 14px;
  letter-spacing: 0;
  text-decoration: underline;
}
h2 {
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.3px;
  margin: 0 0 8px;
}
.hint {
  font-size: 15px;
  color: var(--muted);
  line-height: 1.6;
  margin: 6px 0 14px;
}
label {
  display: flex;
  justify-content: space-between;
  font-size: 15px;
  margin-top: 12px;
}
output {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
input[type="range"] {
  width: 100%;
  accent-color: var(--green);
  height: 15px;
  margin: 8px 0;
}
input[type="checkbox"] {
  accent-color: var(--green);
}
.divider {
  border-top: 1px solid var(--line);
  margin: 22px 0;
}
.chinese {
  color: var(--muted);
  font-size: 15px;
  margin-left: 8px;
}
.point-buttons {
  display: flex;
  gap: 5px;
}
.point-buttons button {
  flex: 1;
  padding: 8px 4px;
  font-size: 14px;
}
.options {
  display: flex;
  justify-content: space-between;
  margin-bottom: 16px;
}
.options label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
}
.primary,
.record {
  width: 100%;
  margin: 5px 0;
}
.primary {
  background: var(--green);
  color: white;
  border: 0;
  padding: 12px;
}
.primary:hover {
  background: #194c39;
}
.record {
  background: transparent;
}
.about {
  padding: 50px 0;
}
.about h2 {
  font-family: Georgia, serif;
  font-weight: 400;
  font-size: 32px;
  margin-bottom: 20px;
}
.about > div {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 60px;
  max-width: 1000px;
}
.about p:not(.eyebrow) {
  color: var(--muted);
  font-size: 16px;
  margin: 0;
}
footer {
  border-top: 1px solid var(--line);
  padding-top: 22px;
  padding-bottom: 26px;
  display: flex;
  justify-content: space-between;
  font-size: 15px;
  color: var(--muted);
}
@media (max-width: 900px) {
  .intro-note {
    display: none;
  }
  .studio {
    grid-template-columns: minmax(0, 1fr);
  }
  aside {
    padding: 18px;
  }
  #viewport {
    height: 430px;
  }
}
@media (max-width: 680px) {
  header {
    height: 78px;
  }
  .brand {
    font-size: 22px;
  }
  nav {
    display: none;
  }
  .badge {
    font-size: 13px;
  }
  .intro {
    padding: 35px 0 28px;
  }
  h1 {
    letter-spacing: -1px;
  }
  .lede {
    font-size: 16px;
  }
  .studio {
    grid-template-columns: 1fr;
  }
  aside {
    border-left: 0;
    border-top: 1px solid var(--line);
    padding: 24px;
  }
  #viewport {
    height: 330px;
  }
  .scene-heading {
    padding: 16px;
    font-size: 14px;
    flex-wrap: wrap;
  }
  .scene-footer {
    padding: 14px;
  }
  .about > div {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  footer {
    gap: 20px;
    align-items: start;
  }
  footer span:last-child {
    max-width: 180px;
    text-align: right;
  }
}
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

/* Native-language links stay available at every screen size. */
.languages {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px;
  max-width: 1440px;
  margin: auto;
  padding: 10px 5%;
  font-size: 15px;
  border-bottom: 1px solid var(--line);
}
.languages a {
  padding: 6px 10px;
  border-radius: 6px;
}
.languages a:hover {
  background: #e7eee5;
}
.languages a[aria-current="page"] {
  background: var(--green);
  color: white;
}
h1 {
  max-width: 820px;
  text-wrap: balance;
}
.intro {
  gap: 32px;
}
.intro-note {
  min-width: 180px;
  border-left: 0;
  border-inline-start: 1px solid var(--line);
  padding-left: 0;
  padding-inline-start: 24px;
}
header {
  gap: 20px;
  height: auto;
  min-height: 100px;
  padding-block: 20px;
  flex-wrap: wrap;
}
header nav {
  flex-wrap: wrap;
  gap: 12px 24px;
}
.brand {
  flex-shrink: 0;
}
.badge {
  text-align: center;
}
.panel-title {
  gap: 12px;
  letter-spacing: 0.5px;
}
.text-button {
  flex-shrink: 0;
}
.point-buttons {
  flex-wrap: wrap;
}
.point-buttons button {
  min-width: 60px;
  overflow-wrap: anywhere;
}
.options {
  flex-wrap: wrap;
  gap: 8px;
}
aside {
  min-width: 0;
  border-left: 0;
  border-inline-start: 0;
  border-top: 1px solid var(--line);
}
output {
  direction: ltr;
  unicode-bidi: isolate;
}
input[type="range"] {
  direction: ltr;
}
[dir="rtl"] h1 {
  letter-spacing: 0;
  line-height: 1.35;
}
[dir="rtl"] .eyebrow,
[dir="rtl"] .badge,
[dir="rtl"] .intro-note span {
  letter-spacing: 0;
}
select:focus-visible {
  outline: 3px solid #df9d39;
  outline-offset: 3px;
}
@media (max-width: 680px) {
  .languages {
    display: flex;
    justify-content: start;
    font-size: 15px;
    gap: 3px;
  }
  .languages a {
    padding: 6px 8px;
  }
  header {
    min-height: 78px;
    padding-block: 16px;
    gap: 12px;
  }
  .badge {
    max-width: 130px;
    letter-spacing: 0.5px;
  }
  aside {
    border-inline-start: 0;
  }
  footer {
    flex-wrap: wrap;
  }
  footer span:last-child {
    text-align: start;
    max-width: 100%;
  }
}

.hands-section {
  margin-block: 28px;
  padding: 24px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 15px;
  scroll-margin-top: 20px;
}
.hands-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}
.hands-heading .eyebrow {
  margin-bottom: 8px;
}
.hand-panel {
  border: 1px solid var(--line);
  border-inline-start: 4px solid #c93e39;
  border-radius: 8px;
  padding: 16px;
  margin: 20px 0 0;
  min-width: 0;
}
.hand-B {
  border-inline-start-color: #24764e;
}
.hand-panel legend {
  padding-inline: 8px;
  font-weight: 650;
  font-size: 17px;
}
.hand-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.hand-actions label {
  margin: 0;
  margin-inline-end: auto;
  align-items: center;
  gap: 8px;
}
.hand-position,
.hand-rotation {
  display: grid;
  grid-template-columns:
    minmax(0, 1fr) minmax(100px, 1fr) minmax(0, 1fr)
    minmax(100px, 1fr) minmax(0, 1fr) minmax(100px, 1fr);
  align-items: center;
  gap: 8px 16px;
}
.hand-position label,
.hand-rotation label {
  margin: 0;
  gap: 12px;
  flex-wrap: wrap;
}
.hand-position {
  margin-block: 16px;
}
.hand-rotation {
  grid-template-columns: minmax(0, 1fr) minmax(90px, 1fr) minmax(0, 1fr) minmax(
      90px,
      1fr
    );
  padding-top: 12px;
}
.hand-panel summary {
  cursor: pointer;
  font-size: 15px;
  color: var(--green);
  padding-block: 8px;
}
.hand-panel input[type="range"] {
  min-width: 0;
}
@media (max-width: 900px) {
  .hand-position {
    grid-template-columns: minmax(0, 1fr) minmax(100px, 2fr);
  }
}
@media (max-width: 680px) {
  .hands-section {
    padding: 20px;
  }
  .hand-panel {
    padding: 12px;
  }
  .hand-rotation {
    grid-template-columns: minmax(0, 1fr) minmax(80px, 1fr);
  }
  .hands-heading {
    align-items: start;
  }
}
/* Keep the scene full width; controls follow below it. */
.studio {
  overflow: clip;
  align-items: start;
}
.scene-column {
  position: static;
  align-self: start;
}
aside .hands-section {
  padding: 20px 0 0;
  margin-block: 22px 0;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
}
aside .hands-heading {
  flex-wrap: wrap;
}
aside .hands-heading h2 {
  font-size: 21px;
}
aside .hand-position,
aside .hand-rotation {
  grid-template-columns: minmax(0, 1fr) minmax(70px, 1fr);
  gap: 8px;
}
aside .hand-panel {
  padding: 12px;
}
.vertical-drag {
  justify-content: start;
  gap: 8px;
  align-items: center;
}
@media (max-width: 680px) {
  .scene-column {
    position: static;
  }
}
.hands-link {
  text-decoration: underline;
  font-weight: 600;
}

.linked-editor {
  padding: 16px 20px 8px;
  background: #f8faf6;
  border-bottom: 1px solid var(--line);
}
.linked-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
}
.linked-toolbar h2 {
  font-size: 21px;
  margin: 0;
  margin-inline-end: auto;
}
.linked-toolbar label {
  font-size: 15px;
  margin: 0;
}
.linked-toolbar select {
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  color: var(--ink);
  background: white;
  font: inherit;
  font-size: 16px;
}
.linked-editor .hint {
  font-size: 15px;
  margin: 8px 0;
}
.linked-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
  gap: 8px;
}
.linked-grid > div {
  min-width: 0;
}
.linked-grid h3 {
  font-size: 15px;
  margin: 5px 0;
}
.linked-grid svg {
  width: 100%;
  display: block;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  touch-action: none;
  cursor: crosshair;
  direction: ltr;
}
.linked-grid svg:focus-visible {
  outline: 3px solid #d39a35;
  outline-offset: 2px;
}
.plane-axis {
  font: 18px sans-serif;
  fill: var(--ink);
}
.plane-marker {
  cursor: grab;
}
.plane-marker.selected > circle:nth-child(2) {
  stroke: #173d35;
  stroke-width: 3;
}
.plane-marker.selected > circle:first-child {
  fill: #ffffff99;
  stroke: #173d35;
  stroke-width: 1;
}
#viewport {
  height: 310px;
}
@media (max-width: 900px) {
  .scene-column {
    position: static;
  }
}
@media (max-width: 680px) {
  .linked-grid {
    grid-template-columns: 1fr;
  }
  .linked-grid svg {
    max-height: 210px;
  }
  #viewport {
    height: 330px;
  }
}
@media (max-height: 850px) {
  .scene-column {
    position: static;
  }
}

aside .control-section {
  padding: 12px 0 0;
  margin: 0;
  border: 0;
}
aside .control-section + .control-section {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.control-section > summary {
  cursor: pointer;
  color: var(--ink);
  padding-block: 5px 12px;
}
.control-section > summary::marker {
  color: var(--green);
}
.control-section > summary h2 {
  display: inline;
  margin: 0;
  font-size: 21px;
}
.control-section > summary:focus-visible {
  outline: 2px solid #d39a35;
  outline-offset: 4px;
  border-radius: 4px;
}
.control-section .hands-heading {
  margin-block: 8px 14px;
}
.linked-editor > summary {
  cursor: pointer;
  padding-block: 2px 10px;
  color: var(--ink);
}
.linked-editor > summary h2 {
  display: inline;
  font-size: 21px;
  margin: 0;
}
.linked-editor > summary:focus-visible {
  outline: 2px solid #d39a35;
  outline-offset: 4px;
  border-radius: 4px;
}
.linked-editor > summary::marker {
  color: var(--green);
}
.linked-toolbar {
  justify-content: flex-end;
}
.scene-column:has(> .linked-editor:not([open])) #viewport {
  height: clamp(330px, 60vh, 600px);
}
#court-form input,
#court-form select {
  width: 100%;
  max-width: 100%;
  margin-top: 6px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: white;
  font: inherit;
}
#court-form input {
  direction: ltr;
}
.court-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}
.court-buttons button {
  flex: 1 1 120px;
}

/* The court always spans the studio; controls never take a side column. */
.studio > aside {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
  align-items: start;
}
.studio > aside > .panel-title {
  grid-column: 1 / -1;
  margin-bottom: 0;
  flex-wrap: wrap;
}
.studio > aside > .control-section {
  min-width: 0;
  margin: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
}
#viewport,
.scene-column:has(> .linked-editor:not([open])) #viewport {
  height: clamp(360px, 58vh, 720px);
}
@media (max-width: 800px) {
  .studio > aside {
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
    padding: 16px;
  }
  #viewport,
  .scene-column:has(> .linked-editor:not([open])) #viewport {
    height: clamp(300px, 52vh, 560px);
  }
}

/* A single large positioning canvas, with room for an expanding object list. */
.position-workspace {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  gap: 18px;
}
.position-main,
.position-objects {
  min-width: 0;
}
.position-workspace h3 {
  font-size: 17px;
  margin: 10px 0;
}
#position-object-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
#position-object-list button {
  text-align: start;
  min-height: 44px;
}
#position-object-list .object-hidden {
  border-style: dashed;
}
.position-tabs,
.position-tools,
.position-tools > div {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.position-tabs {
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}
.position-tabs [aria-selected="true"],
.position-workspace [aria-pressed="true"] {
  background: var(--green);
  color: white;
}
.position-tools {
  margin: 12px 0;
}
.position-tools button {
  min-height: 42px;
}
#plane-zoom-value {
  min-width: 52px;
  text-align: center;
}
.position-workspace .linked-grid {
  display: block;
}
.position-workspace [hidden] {
  display: none !important;
}
.position-workspace .linked-grid svg {
  height: clamp(350px, 55vh, 600px);
  max-height: none;
}
.position-workspace svg.is-panning,
.position-workspace svg.is-panning .plane-marker {
  cursor: grab;
}
.position-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
}
.position-fields label {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-content: stretch;
  gap: 6px;
  margin: 0;
  font-size: 15px;
}
.position-fields input {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--ink);
  font: inherit;
  font-size: 17px;
}
.position-fields button {
  grid-column: 1/-1;
  justify-self: start;
}
@media (max-width: 760px) {
  .position-workspace {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }
  #position-object-list {
    flex-direction: row;
    flex-wrap: wrap;
  }
  #position-object-list button {
    flex: 1 1 100px;
  }
  .position-workspace .linked-grid svg {
    height: 380px;
  }
  .position-fields {
    grid-template-columns: minmax(0, 1fr);
  }
}
.position-workspace svg line,
.position-workspace svg rect {
  vector-effect: non-scaling-stroke;
}
.position-workspace .plane-axis {
  pointer-events: none;
}

/* Bengali script needs natural glyph spacing and room for vowel marks. */
[lang="bn"] h1 {
  letter-spacing: 0;
  line-height: 1.3;
}
[lang="bn"] .eyebrow,
[lang="bn"] .badge,
[lang="bn"] .intro-note span {
  letter-spacing: 0;
}
/* Use the system Arabic-script face with space for Urdu's stacked marks. */
[lang="ur"] h1 {
  font-family: inherit;
  line-height: 1.6;
}

/* Scenario files and timeline follow the existing stacked control layout. */
#scenario-settings input:not([hidden]),
#scenario-settings textarea,
#scenario-settings select,
#players-settings select,
#players-settings input,
#timeline-settings select,
#timeline-settings input {
  max-width: 100%;
  width: 100%;
  box-sizing: border-box;
}
#scenario-settings textarea {
  font: inherit;
  color: #172b24;
  padding: 0.6rem;
  resize: vertical;
}
.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-block: 0.6rem;
}
#players-settings label,
#scenario-settings label,
#timeline-settings label {
  display: block;
  margin-block: 0.6rem 0.3rem;
}
#scenario-settings input:not([hidden]),
#scenario-settings select,
#players-settings input:not([type="range"]),
#players-settings select,
#timeline-settings input:not([type="range"]),
#timeline-settings select {
  font: inherit;
  color: #172b24;
  min-height: 44px;
  padding: 0.45rem;
}
#cloud-settings input {
  width: 100%;
  box-sizing: border-box;
  min-height: 44px;
  font: inherit;
  color: #172b24;
  padding: 0.45rem;
  margin-block: 0.3rem 0.7rem;
}
#cloud-list {
  list-style: none;
  margin: 0.5rem 0;
  padding: 0;
  display: grid;
  gap: 0.4rem;
}
#cloud-list button {
  width: 100%;
  text-align: start;
  overflow-wrap: anywhere;
}
