.field {
  position: relative;
  width: 100%;
  aspect-ratio: 270 / 160;
  overflow: hidden;
  border-radius: 6px;
  background: transparent;
  border: none;
  touch-action: none;
}
.field.vertical { aspect-ratio: 160 / 270; container-type: size; }
.field, .field * { touch-action: none; }

.field-background {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  z-index: 0;
  pointer-events: none;
}
.field.vertical .field-background {
  top: 50%; right: auto; bottom: auto; left: 50%;
  width: 100cqh; height: 100cqw;
  transform-origin: center center;
  transform: translate(-50%, -50%) rotate(90deg);
}

.field-marking { display: none !important; }

.guides-layer { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }
.guides-layer .guide-lane { stroke: rgba(255, 255, 255, 0.55); stroke-width: 2px; stroke-dasharray: 2 6; stroke-linecap: round; }
.guides-layer .guide-third { stroke: none; }
.guides-layer .guide-third.defensive { fill: rgba(31, 99, 209, 0.13); }
.guides-layer .guide-third.middle { fill: rgba(240, 201, 76, 0.1); }
.guides-layer .guide-third.attacking { fill: rgba(215, 66, 63, 0.13); }
.guides-layer .guide-third-line { stroke: rgba(255, 255, 255, 0.35); stroke-width: 1.5px; }

.shapes-fill-layer { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }

.draw-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: auto;
}

.draw-layer > path:not(.stroke-hit-area),
.draw-layer > polygon,
.draw-layer > circle:not(.stroke-hit-area):not(.anchor-handle):not(.control-handle),
.draw-layer > rect:not(.stroke-hit-area),
.draw-layer > line { pointer-events: none; }

.draw-layer .stroke-hit-area { fill: none; stroke: transparent; pointer-events: stroke; cursor: pointer; }
.draw-layer circle.stroke-hit-area,
.draw-layer rect.stroke-hit-area { fill: transparent; stroke: transparent; pointer-events: all; }

.draw-layer .stroke-selected { filter: drop-shadow(0 0 4px rgba(240, 201, 76, 0.95)); }
.draw-layer .anchor-handle,
.draw-layer .control-handle { pointer-events: all; }
.draw-layer .anchor-handle { fill: #f0c94c; stroke: #fff; stroke-width: 2; cursor: grab; }
.draw-layer .control-handle { fill: #3b82f6; stroke: #fff; stroke-width: 2; cursor: grab; }

.field.erase-mode .draw-layer { pointer-events: auto; cursor: crosshair; touch-action: none; }
.field.erase-mode .players-layer { pointer-events: none; }
.field.draw-mode .draw-layer,
.field.move-mode .draw-layer,
.field.erase-mode .draw-layer { pointer-events: auto; }
.field.draw-mode .players-layer { pointer-events: none; }

.field-grid { display: grid; grid-template-columns: 82px minmax(0, 1fr); gap: 8px; }
.field-grid label { display: grid; gap: 5px; color: var(--muted); font-size: 0.78rem; font-weight: 700; }
.field-grid input, .field-grid select { width: 100%; }

/* Bewegungs-Pfeile: liegen zwischen Feld und Zeichenebene,
   aber unter den Spielern. */
.moves-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
}

/* Im Move-Modus gibt es keinen Zeichen-Cursor */
.field:not(.draw-mode) .draw-layer { cursor: default; }

/* ============================================================
   Texte auf dem Board
   ============================================================ */
.board-text rect { cursor: move; }
.board-text text { user-select: none; }
.board-text.selected rect {
  filter: drop-shadow(0 0 3px rgba(240, 201, 76, 0.7));
}

/* Inline-Editor */
.text-inline-editor {
  position: absolute;
  transform: translate(0, 0);
  min-height: 1.2em;
  min-width: 80px;
  padding: 2px 4px;
  margin: 0;
  border: 1.5px dashed #17211b;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.95);
  color: var(--ink);
  font-family: "Inter", "Roboto", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-weight: 600;
  letter-spacing: 0.2px;
  line-height: 1.25;
  resize: none;
  outline: none;
  z-index: 100;
  pointer-events: auto;
  overflow: hidden;
  white-space: pre-wrap;
}
.text-inline-editor:focus {
  outline: none;
}

/* Text-Toolbar */
.text-toolbar {
  position: absolute;
  transform: translate(0, -110%);
  display: flex;
  gap: 6px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 6px;
  box-shadow: 0 4px 12px rgba(30, 46, 37, 0.18);
  z-index: 50;
  pointer-events: auto;
  white-space: nowrap;
}
.text-toolbar-group {
  display: inline-flex;
  gap: 3px;
  padding-right: 6px;
  border-right: 1px solid var(--line);
}
.text-toolbar-group:last-of-type {
  border-right: 0;
  padding-right: 0;
}
.text-toolbar-btn {
  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  border-radius: 4px;
  background: #e7eee9;
  color: var(--ink);
  font-size: 0.72rem;
  font-weight: 800;
  cursor: pointer;
}
.text-toolbar-btn:hover { background: #d5e0da; }
.text-toolbar-btn.is-active { background: var(--ink); color: #fff; }
.text-toolbar-btn.danger { background: #f7e8e6; color: var(--danger); }
.text-color-swatch {
  width: 18px;
  height: 18px;
  padding: 0;
  border-radius: 999px;
  border: 2px solid rgba(23, 33, 27, 0.2);
  cursor: pointer;
}
.text-color-swatch.is-active {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
}

/* TML: sitzt oberhalb des Editors, ohne die Tastatur zu überlappen */
.text-toolbar {
  transform: translate(0, -100%) translateY(-6px);
  z-index: 80;
}

/* Inline-Editor ganz oben, volle Interaktivität */
.text-inline-editor {
  z-index: 100 !important;
  pointer-events: auto !important;
  user-select: text !important;
  -webkit-user-select: text !important;
  cursor: text;
}

/* TML oberhalb des Editors */
.text-toolbar {
  transform: translate(0, -100%) translateY(-8px) !important;
  z-index: 90 !important;
}

/* Inline-Editor: moderne Systemschrift */
.text-inline-editor {
  font-family: "Inter", "Roboto", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-weight: 600;
  letter-spacing: 0.2px;
}

/* Auswahlrahmen: gestrichelt schwarz (nicht gelb) */
.board-text.selected rect {
  stroke: #17211b !important;
  stroke-width: 1.5 !important;
  stroke-dasharray: 4 3 !important;
  filter: none !important;
}

/* Inline-Editor: gut lesbare Systemschrift, größer */
.text-inline-editor {
  font-family: "Inter", "Roboto", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  font-weight: 600;
  letter-spacing: 0.2px;
  line-height: 1.3;
  padding: 3px 5px;
}





/* Breitengriff am ausgewählten Text */
.text-width-handle {
  filter: drop-shadow(0 0 2px rgba(255, 255, 255, 0.8));
}
