html,
body {
  min-width: 0;
}

.gmg-content {
  padding: 14px 18px 36px;
  box-sizing: border-box;
}

.description {
  width: 100%;
  margin: 0;
}

h1 {
  color: #333;
  margin-bottom: 10px;
  text-align: center;
}

.control-panel {
  width: 100%;
  margin: 12px 0 18px;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
  padding: 12px;
  box-sizing: border-box;
}

.formula-field {
  display: block;
  font-size: 12px;
  color: #555;
  font-weight: 700;
  text-transform: uppercase;
}

.formula-field textarea {
  width: 100%;
  min-height: 74px;
  margin-top: 6px;
  box-sizing: border-box;
  border: 1px solid #c8c8c8;
  border-radius: 6px;
  padding: 10px;
  font-family: "Courier New", monospace;
  font-size: 14px;
  line-height: 1.35;
  resize: vertical;
}

.control-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}

.control-row label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #555;
  font-size: 13px;
  font-weight: 700;
}

.control-row input[type="range"] {
  accent-color: #0044ff;
}

.control-row select {
  appearance: none;
  min-width: 104px;
  border: 1px solid #b8bec8;
  border-radius: 6px;
  background:
    linear-gradient(45deg, transparent 50%, #4d5663 50%) right 13px center / 6px 6px no-repeat,
    linear-gradient(135deg, #4d5663 50%, transparent 50%) right 8px center / 6px 6px no-repeat,
    #fff;
  color: #20242a;
  padding: 7px 28px 7px 10px;
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
}

.control-row select:focus {
  border-color: #2456d6;
  box-shadow: 0 0 0 2px rgba(36, 86, 214, 0.16);
  outline: none;
}

.control-row button {
  border: 1px solid #c5c5c5;
  background: #f8f8f8;
  color: #222;
  border-radius: 6px;
  padding: 7px 11px;
  font-weight: 700;
  cursor: pointer;
}

.control-row button:hover {
  background: #ededed;
}

.control-row button.primary,
#autoBtn.running {
  border-color: #0044ff;
  background: #0044ff;
  color: #fff;
}

.debug-button {
  border-color: #9b6a00 !important;
  background: #fff8e6 !important;
  color: #5f3f00 !important;
}

.fixed-formula {
  border: 1px solid #ececec;
  border-radius: 6px;
  background: #fbfbfb;
  padding: 10px 12px;
  overflow-x: auto;
}

.fixed-formula div {
  min-width: max-content;
}

.main-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content;
  gap: 16px;
  align-items: start;
  width: 100%;
  margin: 0;
  height: auto;
  box-sizing: border-box;
  padding-bottom: 10px;
}

.left-col {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-width: 0;
}

.right-col {
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-self: start;
  justify-self: end;
  width: clamp(310px, 20vw, 380px);
  min-width: 0;
}

.game-container,
.side-panel {
  background: white;
  border: 1px solid #ddd;
  border-radius: 8px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
  padding: 5px;
  box-sizing: border-box;
  overflow: hidden;
  position: relative;
  width: 100%;
}

.large-interactive {
  flex: none;
  width: 100%;
  align-self: stretch;
  height: min(82dvh, 820px);
  min-height: 0;
}

.side-panel {
  flex: none;
  height: auto;
  overflow: visible;
}

.right-col .panel-body {
  height: auto;
  overflow: visible;
}

.log-panel {
  display: none;
}

.label-overlay {
  position: absolute;
  top: 5px;
  left: 10px;
  font-size: 12px;
  font-weight: bold;
  color: #777;
  background: rgba(255, 255, 255, 0.95);
  padding: 4px 8px;
  border-radius: 4px;
  pointer-events: none;
  border: 1px solid #eee;
  z-index: 10;
}

svg {
  display: block;
  width: 100%;
  height: 100%;
  user-select: none;
  touch-action: none;
  background: #fff;
  cursor: grab;
}

svg:active {
  cursor: grabbing;
}

.article-instance {
  pointer-events: none;
}

#info {
  margin: 0 0 8px;
  font-size: 15px;
  font-weight: bold;
  color: #444;
  min-height: 34px;
  flex: 0 0 auto;
  display: block;
  text-align: center;
  line-height: 1.3;
  overflow: visible;
  padding: 4px 10px;
  box-sizing: border-box;
  white-space: normal;
  overflow-wrap: anywhere;
}

#info mjx-container {
  margin: 0;
}

.legend-container {
  margin-top: 5px;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #fff;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid #eee;
}

.legend-title {
  font-size: 12px;
  color: #777;
  margin-bottom: 5px;
  font-weight: bold;
  text-transform: uppercase;
}

.legend-row {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 9px;
  font-size: 12px;
  color: #555;
}

.article-citation {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid #ddd;
  color: #555;
  font-size: 13px;
  line-height: 1.45;
}

.article-citation strong {
  color: #333;
}

.article-citation cite {
  font-style: italic;
}

.legend-node {
  display: inline-block;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 2px solid #222;
}

.legend-node.blue {
  background: #064bff;
}

.legend-node.red {
  background: #f51616;
}

.legend-node.empty {
  width: 6px;
  height: 6px;
  border: 0;
  background: #000;
  margin: 0 6px;
}

.legend-line,
.legend-ring {
  display: inline-block;
}

.legend-line {
  width: 32px;
  height: 0;
  border-top: 3px solid #b000b5;
}

.legend-line.active {
  border-top-color: #f0a400;
}

.legend-ring {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  box-sizing: border-box;
  background: transparent;
}

.legend-ring.legal {
  border: 2px solid #149447;
}

.legend-ring.source {
  border: 2px dashed #2456d6;
}

.legend-ring.source.strategy {
  border-color: #2456d6;
}

.legend-ring.source.red-strategy {
  border-color: #c20b0b;
}

.legend-ring.capture {
  border: 2px dashed #f0a400;
}

.panel-body {
  padding: 34px 10px 10px;
  height: 100%;
  overflow: auto;
  box-sizing: border-box;
  font-size: 13px;
}

.empty-panel {
  color: #777;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.formula-list,
.assignment-list,
.trace-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.formula-list li,
.assignment-list li,
.trace-list li {
  border-bottom: 1px solid #eee;
  padding: 6px 0;
}

.formula-list li {
  line-height: 1.55;
}

.formula-list li.satisfied {
  color: #143f25;
}

.formula-list li.pending {
  color: #595959;
}

.clause-status {
  display: block;
  color: #666;
  font-size: 12px;
  margin-top: 3px;
}

.clause-status.ready {
  color: #126534;
}

.clause-status.waiting {
  color: #7a5b00;
}

.trace-list li.current {
  color: #0044ff;
  font-weight: 700;
}

.trace-list li.done {
  color: #666;
}

.trace-panel {
  font-size: 12px;
}

.formula-math {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: visible;
  padding: 8px 0 10px;
}

.formula-math mjx-container {
  max-width: 100%;
  margin: 0 !important;
  padding: 2px 0;
}

.clause-latex {
}

.edge {
  stroke: #555;
  stroke-width: 2;
  fill: none;
}

.edge.connection {
  stroke: #b000b5;
  stroke-width: 2;
}

.edge.auxiliary {
  stroke: #18833a;
  stroke-width: 2;
}

.edge.long-path {
  stroke: #18833a;
  stroke-width: 2;
}

.edge.highlight {
  stroke: #f0a400;
  stroke-width: 5;
}

.zone {
  fill: none;
  stroke: #ff8a00;
  stroke-width: 1.5;
}

.zone.aux {
  stroke: #ff8a00;
}

.zone-label {
  font-family: "Times New Roman", serif;
  font-style: italic;
  font-size: 18px;
  fill: #777;
  pointer-events: none;
}

.node-circle {
  stroke: #222;
  stroke-width: 2;
}

.node {
  cursor: pointer;
}

.state-stone {
  stroke: #222;
  stroke-width: 0.45;
}

.state-stone.blue {
  fill: #0000ff;
}

.state-stone.red {
  fill: #ff0000;
}

.state-cover {
  fill: #f6f5f4;
  stroke: #f6f5f4;
  stroke-width: 0.8;
}

.state-empty-dot {
  fill: #000;
  stroke: none;
}

.state-empty-connector {
  stroke: #000;
  stroke-width: 0.45;
  stroke-linecap: round;
  pointer-events: none;
}

.play-ring {
  fill: none;
  stroke-width: 1.7;
  pointer-events: none;
}

.play-ring.source {
  stroke: #2456d6;
  stroke-dasharray: 2.4 1.6;
}

.play-ring.source.strategy {
  stroke: #2456d6;
}

.play-ring.red-source {
  stroke: #c20b0b;
  stroke-dasharray: 2.4 1.6;
}

.play-ring.strategy-target {
  stroke: #2456d6;
  stroke-dasharray: 2.4 1.6;
}

.play-ring.legal {
  stroke: #149447;
}

.play-ring.legal.off-strategy {
  stroke: #2456d6;
  stroke-dasharray: 2.4 1.6;
}

.play-ring.capture {
  stroke: #f0a400;
  stroke-dasharray: 2 1.4;
}

.hit-target {
  fill: transparent;
  stroke: none;
  cursor: pointer;
  pointer-events: all;
}

.node-circle.blue {
  fill: #064bff;
}

.node-circle.red {
  fill: #f51616;
}

.node-circle.empty {
  fill: #fff;
}

.node-circle.highlight {
  stroke: #f0a400;
  stroke-width: 5;
}

.node-circle.selected {
  stroke: #111;
  stroke-width: 5;
}

.node-circle.legal-target {
  stroke: #149447;
  stroke-width: 5;
}

.node-circle.capture-target {
  stroke: #f0a400;
  stroke-width: 5;
  stroke-dasharray: 4 3;
}

.node-circle.highlight.blue,
.node-circle.highlight.red {
  filter: drop-shadow(0 0 4px rgba(240, 164, 0, 0.6));
}

.node-label {
  font-family: "Times New Roman", serif;
  font-size: 13px;
  fill: #111;
  pointer-events: none;
}

.phase-label {
  font-size: 12px;
  fill: #666;
  pointer-events: none;
}

.error-box {
  color: #9a1111;
  background: #fff4f4;
  border: 1px solid #f0c5c5;
  padding: 8px;
  border-radius: 6px;
}

.result-blue {
  color: #0044ff;
  font-weight: 800;
}

.result-red {
  color: #c20b0b;
  font-weight: 800;
}

.actor-blue {
  color: #0044ff;
}

.actor-red {
  color: #c20b0b;
}

.bad-choice {
  color: #a01212;
}

.assignment-list .assignment-equation {
  color: #222;
  font-size: 13px;
  font-weight: 700;
}

.assignment-list .assignment-target {
  color: #777;
  font-size: 12px;
  margin-left: 6px;
}

.result-modal[hidden] {
  display: none;
}

.result-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(14, 19, 25, 0.46);
  z-index: 100;
  padding: 24px;
  box-sizing: border-box;
}

.result-modal-card {
  width: min(420px, 100%);
  background: #fff;
  border: 1px solid #d5d5d5;
  border-radius: 8px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.24);
  padding: 22px;
  text-align: center;
}

.result-modal-card h3 {
  margin: 0 0 10px;
  color: #0044ff;
  font-size: 24px;
}

.result-modal-card p {
  margin: 0 0 18px;
  color: #333;
  line-height: 1.4;
}

.result-modal-card button {
  border: 1px solid #0044ff;
  background: #0044ff;
  color: #fff;
  border-radius: 6px;
  padding: 8px 16px;
  font-weight: 700;
  cursor: pointer;
}

.result-modal.red-win .result-modal-card h3 {
  color: #d71920;
}

.result-modal.red-win .result-modal-card button {
  border-color: #d71920;
  background: #d71920;
}

@media (max-width: 1000px) {
  .main-layout {
    display: flex;
    flex-wrap: wrap;
    height: auto;
  }

  .left-col,
  .right-col {
    flex: 0 0 100%;
    width: 100%;
    height: auto;
  }

  .large-interactive {
    flex: none;
    height: clamp(220px, 38vh, 340px);
  }

  .side-panel {
    flex: none;
    height: 260px;
  }

  .side-panel:last-child {
    height: 340px;
  }
}
