.hh-app,
.hh-app * {
  box-sizing: border-box;
}

.hh-app {
  --ink: #1f2421;
  --muted: #66706a;
  --paper: #f6f3ea;
  --panel: rgba(255, 255, 255, .88);
  --line: #d8d2c3;
  --accent: #215946;
  max-width: 1180px;
  margin: 24px auto;
  padding: clamp(16px, 3vw, 30px);
  color: var(--ink);
  font-family: "Noto Sans JP", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(255,255,255,.98), rgba(246,243,234,.94) 58%),
    var(--paper);
  border: 1px solid #e0dacd;
  border-radius: 28px;
  box-shadow: 0 20px 50px rgba(34, 41, 37, .12);
}

.hh-header {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.hh-kicker {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .16em;
}

.hh-title {
  margin: 0;
  font-size: clamp(1.7rem, 4vw, 2.8rem);
  line-height: 1.18;
  letter-spacing: -.04em;
}

.hh-lead {
  max-width: 700px;
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.75;
}

.hh-header-status {
  display: grid;
  grid-template-columns: repeat(2, minmax(94px, 1fr));
  gap: 8px;
  flex: 0 0 auto;
}

.hh-mini-card {
  padding: 10px 14px;
  background: rgba(255,255,255,.75);
  border: 1px solid var(--line);
  border-radius: 14px;
  text-align: center;
}

.hh-mini-card span {
  display: block;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: .72rem;
}

.hh-mini-card strong {
  font-size: .98rem;
}

.hh-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 290px;
  gap: 18px;
  align-items: start;
}

.hh-board-panel,
.hh-side-panel {
  background: var(--panel);
  border: 1px solid rgba(216, 210, 195, .9);
  border-radius: 22px;
  box-shadow: 0 12px 32px rgba(37, 45, 40, .08);
}

.hh-board-panel {
  padding: clamp(10px, 2vw, 18px);
}

.hh-board-wrap {
  position: relative;
  overflow: hidden;
  border-radius: 18px;
}

#hh-board {
  display: block;
  width: 100%;
  height: auto;
  touch-action: manipulation;
}

.hh-board-surface {
  fill: #315f4d;
  stroke: rgba(255,255,255,.22);
  stroke-width: 2;
}

.hh-edges line {
  stroke: rgba(245, 234, 198, .82);
  stroke-width: 8;
  stroke-linecap: round;
}

.hh-point {
  fill: #d7c896;
  stroke: rgba(255,255,255,.7);
  stroke-width: 3;
  transition: transform .16s ease, fill .16s ease, stroke .16s ease;
  transform-origin: center;
}

.hh-node {
  cursor: default;
  outline: none;
}

.hh-node.is-selectable,
.hh-node.is-legal {
  cursor: pointer;
}

.hh-node.is-selectable:hover .hh-point,
.hh-node.is-selectable:focus-visible .hh-point {
  fill: #f4e7b8;
  stroke: #fff;
  stroke-width: 5;
}

.hh-node.is-selected .hh-point {
  stroke: #ffdd66;
  stroke-width: 8;
}

.hh-node-label {
  fill: rgba(31,36,33,.58);
  font-size: 15px;
  font-weight: 900;
  pointer-events: none;
}

.hh-eval-marker {
  stroke-width: 4;
  filter: url(#hh-shadow);
}

.hh-eval-marker.hounds-win {
  fill: #f8edc7;
  stroke: #111;
}

.hh-eval-marker.hare-win {
  fill: #303633;
  stroke: #fff;
}

.hh-eval-number {
  font-size: 24px;
  font-weight: 950;
  pointer-events: none;
}

.hh-eval-number.hounds-win {
  fill: #000;
}

.hh-eval-number.hare-win {
  fill: #fff;
  paint-order: stroke;
  stroke: rgba(0,0,0,.65);
  stroke-width: 2px;
}

.hh-piece.is-selected circle {
  stroke: #ffdd66;
  stroke-width: 5;
}

.hh-piece-kanji {
  fill: #fff;
  font-size: 19px;
  font-weight: 900;
}

.hh-hare-ear {
  fill: #f6f4ed;
  stroke: #97938a;
  stroke-width: 2;
}

.hh-hare-kanji {
  fill: #171917;
  font-size: 19px;
  font-weight: 900;
}

.hh-board-footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-top: 12px;
  padding: 0 4px;
}

.hh-status {
  margin: 0;
  color: #37413b;
  font-size: .92rem;
  line-height: 1.55;
}

.hh-actions {
  display: flex;
  gap: 8px;
  flex: 0 0 auto;
}

.hh-button {
  appearance: none;
  border: 1px solid #cfc8b8;
  border-radius: 11px;
  padding: 9px 13px;
  color: #27312b;
  background: #fff;
  font: inherit;
  font-size: .85rem;
  font-weight: 800;
  cursor: pointer;
}

.hh-button:hover {
  background: #f4f0e6;
}

.hh-button:focus-visible {
  outline: 3px solid rgba(33,89,70,.28);
  outline-offset: 2px;
}

.hh-button:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.hh-side-panel {
  padding: 16px;
}

.hh-side-section + .hh-side-section {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.hh-side-title {
  margin: 0 0 10px;
  font-size: .84rem;
  letter-spacing: .06em;
}

.hh-result-chip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 12px 13px;
  border-radius: 14px;
}

.hh-result-chip.hounds-win {
  color: #fff;
  background: #171917;
}

.hh-result-chip.hare-win {
  color: #171917;
  background: #fff;
  border: 2px solid #262a27;
}

.hh-result-chip span {
  font-weight: 800;
}

.hh-result-chip strong {
  font-size: 1.05rem;
}

.hh-legend {
  display: grid;
  gap: 9px;
  margin: 0;
}

.hh-legend-row {
  display: grid;
  grid-template-columns: 30px 1fr;
  gap: 10px;
  align-items: center;
  color: #48514c;
  font-size: .82rem;
  line-height: 1.45;
}

.hh-legend-number {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: .9rem;
  font-weight: 950;
}

.hh-legend-number.hounds-win {
  color: #000;
  background: #f8edc7;
  border: 2px solid #111;
}

.hh-legend-number.hare-win {
  color: #fff;
  background: #303633;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px #222;
}

.hh-history {
  max-height: 190px;
  overflow: auto;
  margin: 0;
  padding: 0;
  list-style: none;
}

.hh-history li {
  display: grid;
  grid-template-columns: 25px 1fr;
  gap: 7px;
  padding: 7px 0;
  border-bottom: 1px dashed #ddd6c8;
  font-size: .8rem;
}

.hh-history li span {
  color: #8a918d;
  font-variant-numeric: tabular-nums;
}

.hh-history li strong {
  font-weight: 700;
}

.hh-history-empty {
  display: block !important;
  color: #8a918d;
}

.hh-solver-stats {
  margin: 0;
  color: #64706a;
  font-size: .76rem;
  line-height: 1.55;
}

.hh-rules {
  margin: 0;
  padding-left: 1.2em;
  color: #59635d;
  font-size: .78rem;
  line-height: 1.65;
}

.hh-sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

@media (max-width: 880px) {
  .hh-header {
    display: block;
  }

  .hh-header-status {
    margin-top: 14px;
    max-width: 320px;
  }

  .hh-layout {
    grid-template-columns: 1fr;
  }

  .hh-side-panel {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
  }

  .hh-side-section + .hh-side-section {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
  }
}

@media (max-width: 580px) {
  .hh-app {
    margin: 8px auto;
    border-radius: 18px;
  }

  .hh-board-footer {
    display: block;
  }

  .hh-actions {
    margin-top: 10px;
  }

  .hh-side-panel {
    display: block;
  }

  .hh-side-section + .hh-side-section {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
  }

  .hh-node-label {
    font-size: 18px;
  }
}
