:root {
  --hf-cell: 42px;
  --hf-gap: 0px;
  --hf-font: 15px;
}

body {
  margin: 0;
  font-family: Arial, sans-serif;
  background-color: #fff;
  text-align: center;
  margin-top: 15px;
  margin-bottom: 10px;
}


/* ===================== Container ===================== */

.hf-container {
  background: white;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 24px 20px;
  margin: 12px auto 10px;
  border-radius: 12px;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
  min-width: 320px;
  max-width: calc(100vw - 4px);
  position: relative;
}

/* ===================== Options-Zeile ===================== */

.hf-view-count {
  display: flex;
  align-items: center;
  gap: 4px;
}

.hf-jump-select {
  display: flex;
  align-items: center;
  gap: 18px;
}

.hf-jump-group {
  display: flex;
  align-items: center;
  gap: 2px;
}

/* ===================== Hauptbereich ===================== */

.hf-main {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 14px;
}

/* Navigation */

.hf-nav-btn {
  all: unset;
  font-size: 20px;
  color: #bbb;
  cursor: pointer;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s;
  user-select: none;
  flex-shrink: 0;
}

.hf-nav-btn:hover {
  color: #666;
}

/* +/− Zeilen */

.hf-adjust-row {
  display: flex;
  flex-direction: row;
  gap: 4px;
  align-items: center;
  justify-content: center;
  margin-top: 6px;
  margin-bottom: 8px;
}

.hf-adjust-btn {
  all: unset;
  font-size: 11px;
  color: #ccc;
  cursor: pointer;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, border-color 0.2s;
  user-select: none;
  line-height: 1;
  border-radius: 50%;
  border: 1px solid #ddd;
}

.hf-adjust-btn:hover {
  color: #888;
  border-color: #aaa;
}

.hf-adjust-label {
  font-size: 9px;
  color: #ccc;
  font-family: sans-serif;
  user-select: none;
  line-height: 1;
}

/* 123 halb invertiert */

#btnNumbers {
  background: linear-gradient(to bottom, #333 50%, #aaa 50%) !important;
  -webkit-background-clip: text !important;
  -webkit-text-fill-color: transparent !important;
  background-clip: text !important;
  opacity: 0.7 !important;
  filter: none !important;
}

#btnNumbers:hover {
  background: linear-gradient(to bottom, #b03a2e 50%, #e6a9a3 50%) !important;
  -webkit-background-clip: text !important;
  -webkit-text-fill-color: transparent !important;
  background-clip: text !important;
  opacity: 0.85 !important;
}

#btnNumbers.active {
  background: linear-gradient(to bottom, #aaa 50%, #333 50%) !important;
  -webkit-background-clip: text !important;
  -webkit-text-fill-color: transparent !important;
  background-clip: text !important;
  opacity: 0.7 !important;
  filter: none !important;
}

#btnNumbers.active:hover {
  background: linear-gradient(to bottom, #e6a9a3 50%, #b03a2e 50%) !important;
  -webkit-background-clip: text !important;
  -webkit-text-fill-color: transparent !important;
  background-clip: text !important;
  opacity: 0.85 !important;
}

/* ===================== Board ===================== */

.hf-board {
  position: relative;
  max-width: calc(100vw - 120px);
}

.hf-board.unfolded {
  flex: 1;
  min-width: 0;
}

/* ===================== Multi-Feld-Layout ===================== */

.hf-fields-wrap {
  max-width: calc(100vw - 120px);
  overflow-x: auto;
}

.hf-fields-inner {
  display: grid;
  gap: 10px;
  justify-content: center;
  position: relative;
}

.hf-field {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
}

.hf-field-label {
  font-size: 0.7em;
  color: #aaa;
  margin-bottom: 4px;
  font-family: sans-serif;
  user-select: none;
}

.hf-field-grid {
  display: flex;
  flex-direction: column;
  gap: var(--hf-gap);
  position: relative;
}

/* ===================== Zeilen ===================== */

.hf-row {
  display: flex;
  gap: 0;
  position: relative;
  z-index: 1;
}

/* ===================== Zellen ===================== */

.hf-cell {
  width: var(--hf-cell);
  height: var(--hf-cell);
  border: 0.5px solid #ccc;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Grundschrift', monospace;
  font-size: var(--hf-font);
  cursor: pointer;
  user-select: none;
  position: relative;
  background: white;
  box-sizing: border-box;
  transition: background-color 0.15s;
  color: #333;
}

.hf-cell.hf-range-preview {
  background: #e8e0f0;
}

.hf-cell:hover {
  background: #f8f4ec;
}

.hf-cell .num {
  pointer-events: none;
  transition: opacity 0.15s;
}

.hf-cell.hide-num .num {
  opacity: 0;
}

/* ===================== Plättchen ===================== */

.hf-cell.mark-blue::after {
  content: '';
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: rgba(59, 130, 246, 0.25);
  border: 1.5px solid rgba(59, 130, 246, 0.45);
  pointer-events: none;
}

.hf-cell.mark-red::after {
  content: '';
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: rgba(239, 68, 68, 0.25);
  border: 1.5px solid rgba(239, 68, 68, 0.45);
  pointer-events: none;
}

.hf-cell.mark-blue-minus::after {
  content: '';
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: rgba(59, 130, 246, 0.25);
  border: 1.5px solid rgba(59, 130, 246, 0.45);
  pointer-events: none;
}

.hf-cell.mark-red-minus::after {
  content: '';
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: rgba(239, 68, 68, 0.25);
  border: 1.5px solid rgba(239, 68, 68, 0.45);
  pointer-events: none;
}

.hf-cell.mark-blue-minus::before,
.hf-cell.mark-red-minus::before {
  content: '';
  position: absolute;
  top: 48%;
  left: -4%;
  right: -4%;
  height: 2.5px;
  background: linear-gradient(90deg, transparent 0%, #555 10%, #444 50%, #555 90%, transparent 100%);
  transform: rotate(-42deg);
  border-radius: 1px;
  pointer-events: none;
  z-index: 1;
}

/* ===================== Highlights ===================== */

.hf-cell.hl-main {
  background: #fef08a !important;
}

.hf-cell.hl-neighbor {
  background: #fef9c3 !important;
}

.hf-cell.hl-ten {
  background: #fed7aa !important;
}

.hf-cell.hl-jump-a {
  background: #ede9fe !important;
}

.hf-cell.hl-jump-b {
  background: #d1fae5 !important;
}

.hf-cell.hl-jump-both {
  background: linear-gradient(135deg, #ede9fe 50%, #d1fae5 50%) !important;
}

/* ===================== Verbindungslinien ===================== */

.hf-conn-svg {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: none;
  z-index: 0;
  overflow: visible;
}

/* ===================== Cursor ===================== */

.hf-board.marking .hf-cell {
  cursor: crosshair;
}

/* ===================== Aufklappen ===================== */

.hf-adjust-btn.disabled {
  color: transparent;
  cursor: default;
}

.hf-unfold-scroll {
  overflow-x: auto;
  padding-bottom: 8px;
  padding-right: 14px;
  scrollbar-width: thin;
  box-sizing: border-box;
}

.hf-strip {
  display: flex;
  border-top: 0.5px solid #ccc;
  border-bottom: 0.5px solid #ccc;
}

.hf-strip .hf-cell {
  flex: 0 0 var(--hf-cell);
  height: var(--hf-cell);
  border: none;
  box-shadow: inset -1px 0 0 0 #ccc;
}

.hf-strip .hf-cell:first-child {
  box-shadow: inset 1px 0 0 0 #ccc, inset -1px 0 0 0 #ccc;
}

.hf-strip .hf-cell.hf-strip-break {
  box-shadow: inset 1.5px 0 0 0 #999, inset -1px 0 0 0 #ccc;
}

.hf-strip .hf-cell.hf-before-break {
  box-shadow: none;
}

/* ===================== Positions-Punkte ===================== */

.hf-dots {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  justify-content: center;
}

.hf-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #e5e5e5;
  cursor: pointer;
  transition: background 0.2s;
}

.hf-dot:hover {
  background: #bbb;
}

.hf-dot.active {
  background: #888;
}

/* ===================== Toolbar: Plättchen-Dots ===================== */

.mark-dot {
  display: inline-block;
  width: 16px;
  height: 16px;
  border-radius: 50%;
}

.dot-flip {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.5) 50%, rgba(239, 68, 68, 0.5) 50%);
  border: 1.5px solid #888;
}

.dot-minus {
  background: rgba(150, 150, 150, 0.2);
  border: 1.5px solid #999;
  position: relative;
  overflow: hidden;
}

.dot-minus::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1.5px;
  background: #666;
  transform: rotate(-45deg);
}

.dot-erase {
  background: rgba(150, 150, 150, 0.15);
  border: 1.5px solid #999;
  font-size: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #888;
}

.hf-mark-btn.active {
  opacity: 0.9 !important;
  filter: none !important;
}

#markErase.active .dot-erase {
  background: rgba(200, 50, 50, 0.15);
  border-color: #c0392b;
  color: #c0392b;
}

/* ===================== Info-Zeile ===================== */

.hf-info-row {
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: stretch;
  min-height: 20px;
  margin-top: 6px;
  margin-bottom: -4px;
  position: relative;
}

.hf-info {
  font-size: 0.95em;
  color: #555;
  font-family: sans-serif;
  text-align: center;
  background: #f5f0e8;
  padding: 2px 12px;
  border-radius: 10px;
}

.hf-info:empty {
  background: none;
  padding: 0;
}

.hf-info-row .circle-toggle {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
}

/* ===================== HZE-Suche ===================== */

.hf-bottom-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin-top: 8px;
}

.hf-search-row {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
}

.hf-hze {
  display: flex;
  gap: 2px;
}

.hf-hze-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}

.hf-hze-label {
  font-size: 0.6em;
  color: #bbb;
  user-select: none;
  font-family: sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.hf-hze-btn {
  all: unset;
  font-size: 8px;
  color: #bbb;
  cursor: pointer;
  width: 24px;
  height: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s;
  user-select: none;
}

.hf-hze-btn:hover {
  color: #666;
}

.hf-hze-digit {
  font-size: 1.1em;
  font-family: 'Grundschrift', monospace;
  color: #333;
  width: 24px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #ddd;
  border-radius: 3px;
  background: #fafafa;
  user-select: none;
}

.hf-search-btn {
  filter: grayscale(0) !important;
  opacity: 0.5 !important;
}

.hf-search-btn:hover {
  opacity: 0.8 !important;
}

/* ===================== Reihen-Steuerung (entfernt) ===================== */

.hf-kgv-wrap {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 4px;
}

.hf-kgv-input {
  width: 42px;
  height: 24px;
  font-size: 0.8em;
  text-align: center;
  border: 1px solid #ddd;
  border-radius: 4px;
  outline: none;
  font-family: 'Grundschrift', monospace;
  -moz-appearance: textfield;
}

.hf-kgv-input::-webkit-inner-spin-button,
.hf-kgv-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.hf-kgv-input:focus {
  border-color: #aaa;
}

.hf-kgv-feedback {
  font-size: 1em;
  font-weight: 700;
  min-width: 16px;
  user-select: none;
}

.hf-kgv-feedback.correct {
  color: #16a34a;
}

.hf-kgv-feedback.wrong {
  color: #dc2626;
}

/* ===================== Feldanzahl-Buttons ===================== */

.hf-view-count {
  margin-top: 8px;
}

.hf-vc-btn {
  all: unset;
  font-size: 0.65em;
  color: #bbb;
  cursor: pointer;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #e0e0e0;
  border-radius: 50%;
  user-select: none;
  font-family: sans-serif;
  transition: all 0.15s;
}

.hf-vc-btn:hover {
  border-color: #aaa;
  color: #888;
}

.hf-vc-btn.active {
  color: #999;
  border-color: #bbb;
  font-weight: 600;
}

/* ===================== Känguru ===================== */

.hf-animal {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 80%;
  height: 80%;
  z-index: 2;
  pointer-events: auto;
  object-fit: contain;
  cursor: grab;
}

.hf-cell.has-animal .num {
  position: relative;
  z-index: 3;
  opacity: 0;
  transition: opacity 0.2s;
}

.hf-cell.has-animal.show-num .num {
  opacity: 1;
  color: white;
  text-shadow: 0 0 3px rgba(0,0,0,0.6);
  font-weight: 700;
}

.hf-kanga-btn {
  cursor: grab !important;
  filter: grayscale(1) !important;
  opacity: 0.5 !important;
}

.hf-kanga-btn:hover {
  filter: grayscale(0) !important;
  opacity: 0.8 !important;
}

.hf-kanga-btn.placed {
  filter: grayscale(0) !important;
  opacity: 0.5 !important;
  position: relative;
}

.hf-kanga-btn.placed::after {
  content: '✕';
  position: absolute;
  top: -2px;
  right: -4px;
  font-size: 8px;
  color: #c00;
  font-weight: bold;
  line-height: 1;
}

.hf-kanga-preview {
  width: 18px;
  height: 18px;
  object-fit: contain;
  pointer-events: none;
}

.hf-drag-ghost {
  position: fixed;
  width: 36px;
  height: 36px;
  object-fit: contain;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.85;
  transform: translate(-50%, -50%);
}

/* ===================== D-Pad ===================== */

.hf-dpad-wrap {
  display: grid;
  grid-template-columns: repeat(3, 30px);
  grid-template-rows: repeat(3, 30px);
  gap: 2px;
  justify-content: center;
}

.hf-dpad-btn {
  all: unset;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: #bbb;
  cursor: pointer;
  border: 1px solid #e0e0e0;
  border-radius: 5px;
  user-select: none;
  transition: color 0.15s, border-color 0.15s, background 0.1s;
}

.hf-dpad-btn:hover {
  color: #666;
  border-color: #aaa;
}

.hf-dpad-btn:active {
  background: #f0f0f0;
}

.hf-dpad-up    { grid-column: 2; grid-row: 1; }
.hf-dpad-left  { grid-column: 1; grid-row: 2; }
.hf-dpad-right { grid-column: 3; grid-row: 2; }
.hf-dpad-down  { grid-column: 2; grid-row: 3; }

/* ===================== Responsive ===================== */

.hf-container .top-toolbar {
  flex-wrap: wrap;
  gap: 4px;
  align-self: stretch;
  justify-content: space-between;
}

.hf-container .toolbar-left {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 0 1 auto;
  justify-content: flex-start;
}

.hf-container .toolbar-right {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  flex-shrink: 0;
  align-items: center;
}

.hf-container .toolbar-right .tool-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.hf-kanga-preview {
  display: block !important;
}

@media (max-width: 1024px) {
  .hf-container {
    display: flex;
  }
}

@media (max-width: 500px) {
  .hf-container {
    padding: 10px 8px 14px;
  }

  .hf-nav-btn {
    display: none;
  }

  .hf-board {
    max-width: calc(100vw - 28px);
  }

  .hf-fields-wrap {
    max-width: calc(100vw - 28px);
  }

  .hf-fields-inner {
    grid-template-columns: 1fr !important;
  }

  .hf-bottom-controls {
    margin-top: 6px;
  }

  .hf-dots {
    margin-top: 6px;
  }
}

@media (max-height: 700px) {
  body {
    margin-top: 6px;
    margin-bottom: 4px;
  }

  .hf-container {
    padding-top: 10px;
    padding-bottom: 10px;
    margin-top: 4px;
  }

  .hf-main {
    margin-top: 8px;
  }

  .hf-info-row {
    margin-top: 2px;
    margin-bottom: -6px;
  }

  .hf-dots {
    margin-top: 4px;
  }

  .hf-adjust-row {
    margin-top: 3px;
    margin-bottom: 4px;
  }

  .hf-bottom-controls {
    margin-top: 4px;
  }
}
