:root{
  --hg-bg: rgba(255,255,255,.02);
  --hg-br: rgba(255,255,255,.08);
  --hg-br2: rgba(255,255,255,.14);

  --hg-island-bg: rgba(255,255,255,.06);
  --hg-island-br: rgba(255,255,255,.12);
  --hg-island-br2: rgba(255,255,255,.18);

  --hg-line: rgba(255,255,255,.82);
  --hg-line-soft: rgba(255,255,255,.22);

  --hg-done-bg: rgba(0,255,140,.10);
  --hg-done-br: rgba(0,255,140,.26);

  --hg-warn-bg: rgba(255,200,0,.08);
  --hg-warn-br: rgba(255,200,0,.22);

  --hg-bad-bg: rgba(255,60,60,.12);
  --hg-bad-br: rgba(255,60,60,.30);

  --hg-shadow: 0 10px 24px rgba(0,0,0,.22);

  /* driven by JS */
  --cell: 38px;
  --inset: 18px;
  --boardPx: 360px;
  --n: 7;
}

:root[data-theme="light"]{
  --hg-bg: rgba(11,15,20,.02);
  --hg-br: rgba(11,15,20,.10);
  --hg-br2: rgba(11,15,20,.16);

  --hg-island-bg: rgba(255,255,255,.88);
  --hg-island-br: rgba(11,15,20,.12);
  --hg-island-br2: rgba(11,15,20,.18);

  --hg-line: rgba(11,15,20,.86);
  --hg-line-soft: rgba(11,15,20,.16);

  --hg-done-bg: rgba(0,160,90,.10);
  --hg-done-br: rgba(0,160,90,.24);

  --hg-warn-bg: rgba(255,170,0,.10);
  --hg-warn-br: rgba(255,170,0,.22);

  --hg-bad-bg: rgba(255,60,60,.10);
  --hg-bad-br: rgba(255,60,60,.22);

  --hg-shadow: 0 10px 22px rgba(0,0,0,.10);
}

header.wrap { padding-bottom: 6px; }
main.wrap { padding-top: 6px; }

.card.hgCard { padding: 10px 10px 12px; }
@media (max-width:520px){
  .wrap { padding-left: 10px; padding-right: 10px; }
  .card.hgCard { padding: 8px 8px 10px; }
}

/* H1 tag */
.ngH1Tag{
  opacity: .72;
  font-weight: 800;
  letter-spacing: .01em;
  margin-left: .35rem;
  font-size: .92em;
}
@media (max-width:420px){
  .ngH1Tag{ display:none; }
}

/* Premium tagline pill */
.sub{
  display:flex;
  flex-wrap:wrap;
  justify-content:center;
  align-items:center;
  gap: .45rem;

  width:100%;
  margin: 8px 0 0;
  padding: .5rem .75rem;

  font-size: .92rem;
  line-height: 1.15;
  border-radius: 999px;
  letter-spacing: .01em;

  background: rgba(0,0,0,.04);
  border: 1px solid rgba(0,0,0,.06);
  text-wrap: normal;
}
:root[data-theme="dark"] .sub{
  background: rgba(255,255,255,.06);
  border-color: rgba(255,255,255,.10);
}
@media (max-width:520px){
  .sub{ font-size: .86rem; }
}

.hgTopRow{
  display:flex;
  align-items:flex-end;
  justify-content:space-between;
  gap:10px;
  margin-bottom: 10px;
}

.hgMeta{ display:flex; flex-direction:column; gap:6px; }
.hgModeLine{ font-size: 13px; opacity: .9; }
.hgRule{ font-size: 12px; opacity: .78; max-width: 60ch; }

.hgStats{
  display:flex;
  gap:10px;
  align-items:flex-end;
}
.hgStat{
  text-align:right;
  display:flex;
  flex-direction:column;
  gap:3px;
  min-width: 78px;
}
.hgStatVal{ font-size: 18px; line-height: 1; }

/* prevent right overflow on mobile */
.hgBoardWrap{
  display:flex;
  justify-content:center;
  padding-top: 2px;
  overflow-x: hidden;
}

.hgBoardShell{
  width: min(560px, 100%);
  max-width: 100%;
  padding: 10px;
  border-radius: 18px;
  background: var(--hg-bg);
  border: 1px solid var(--hg-br);
  box-shadow: var(--hg-shadow);
}

.hgBoardTitleRow{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:10px;
  margin-bottom: 8px;
}

.hgMiniMeta{
  font-size: 13px;
  opacity: .9;
}

.hgHint{
  display:flex;
  align-items:center;
  gap:8px;
  font-size: 12px;
}
.hgDot{
  width: 10px;
  height: 10px;
  border-radius: 99px;
  background: rgba(0,255,140,.25);
  border: 1px solid rgba(0,255,140,.35);
}
:root[data-theme="light"] .hgDot{
  background: rgba(0,160,90,.22);
  border-color: rgba(0,160,90,.28);
}

/* Board */
.hgBoard{
  width: var(--boardPx);
  height: var(--boardPx);
  max-width: 100%;
  margin: 0 auto;

  border-radius: 16px;
  background: rgba(255,255,255,.02);
  border: 1px solid var(--hg-br);

  position:relative;
  overflow:hidden;

  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;

  transition: box-shadow 160ms ease, border-color 160ms ease;
}
:root[data-theme="light"] .hgBoard{
  background: rgba(11,15,20,.02);
}
.hgBoard.badFlash{
  animation: hgBadFlash 260ms ease;
}
@keyframes hgBadFlash{
  0%{ box-shadow: 0 0 0 0 rgba(255,60,60,.0); }
  30%{ box-shadow: 0 0 0 4px rgba(255,60,60,.16); }
  100%{ box-shadow: 0 0 0 0 rgba(255,60,60,.0); }
}

.hgSvg{
  position:absolute;
  inset:0;
  width:100%;
  height:100%;
  display:block;
}

.hgGridDots circle{
  fill: var(--hg-line-soft);
  opacity: .55;
}

.hgLine{
  stroke: var(--hg-line);
  filter: drop-shadow(0 6px 10px rgba(0,0,0,.12));
  opacity: .92;
}

.hgIslands{
  position:absolute;
  inset:0;
}

.hgIsland{
  position:absolute;
  transform: translate(-50%, -50%);
  width: clamp(34px, calc(var(--cell) * 0.90), 48px);
  height: clamp(34px, calc(var(--cell) * 0.90), 48px);
  border-radius: 999px;

  background: var(--hg-island-bg);
  border: 1px solid var(--hg-island-br);
  box-shadow: 0 10px 22px rgba(0,0,0,.10);

  display:flex;
  flex-direction:column;
  justify-content:center;
  align-items:center;
  gap: 1px;

  cursor:pointer;
  padding:0;

  user-select:none;
  -webkit-tap-highlight-color: transparent;

  transition: transform 120ms ease, border-color 120ms ease, box-shadow 120ms ease, background 120ms ease;
}
.hgIsland:hover{ border-color: var(--hg-island-br2); }
.hgIsland:active{ transform: translate(-50%, -50%) scale(0.985); }

.hgNum{
  font-weight: 1000;
  font-size: clamp(14px, calc(var(--cell) * 0.42), 18px);
  line-height: 1;
}
.hgRem{
  font-weight: 900;
  font-size: 11px;
  line-height: 1;
  opacity: .72;
}

.hgIsland.sel{
  border-color: rgba(120,160,255,.55);
  box-shadow: 0 0 0 3px rgba(120,160,255,.18), 0 12px 26px rgba(0,0,0,.14);
}

.hgIsland.done{
  background: color-mix(in oklab, var(--hg-island-bg), rgba(0,255,140,.22) 40%);
  border-color: var(--hg-done-br);
  box-shadow: 0 0 0 3px rgba(0,255,140,.12), 0 12px 26px rgba(0,0,0,.14);
}
:root[data-theme="light"] .hgIsland.done{
  background: color-mix(in oklab, var(--hg-island-bg), rgba(0,160,90,.18) 35%);
}

.hgIsland.warn{
  border-color: var(--hg-warn-br);
  box-shadow: 0 0 0 3px rgba(255,190,0,.12), 0 12px 26px rgba(0,0,0,.14);
}

.hgIsland.bad{
  border-color: var(--hg-bad-br);
  background: var(--hg-bad-bg);
}

/* Controls */
.hgBar{
  margin-top: 12px;
  display:flex;
  gap:8px;
  justify-content:center;
  flex-wrap:wrap;
}

.hgMiniRow{
  margin-top:10px;
  display:flex;
  gap:10px;
  justify-content:space-between;
  align-items:center;
  flex-wrap:wrap;
}

.hgStatsPill{
  display:inline-flex;
  align-items:center;
  gap:.35rem;
  padding: 10px 12px;
  border-radius: 999px;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.10);
  font-size: 13px;
  box-shadow: 0 10px 22px rgba(0,0,0,.10);
}
:root[data-theme="light"] .hgStatsPill{
  background: rgba(255,255,255,.86);
  border-color: rgba(11,15,20,.14);
}

.hgMoreWrap{
  margin-top: 12px;
  display:flex;
  justify-content:center;
}
.hgMoreBtn{
  text-decoration:none;
  padding: 12px 16px;
  border-radius: 16px;
  box-shadow: 0 10px 22px rgba(0,0,0,.10);
  animation: hgMorePulse 2.8s ease-in-out infinite;
}
@keyframes hgMorePulse{
  0%,100%{ transform: translateY(0); }
  50%{ transform: translateY(-1px); }
}

.msg{
  display:none;
  margin: 8px auto 0;
  text-align:center;
  font-weight: 900;
  letter-spacing:.01em;
}

/* dialogs */
.hgHelpDlg,
.hgWinDlg,
.hgShareDlg{
  padding: 0;
  border: 0;
  background: transparent;
  width: fit-content;
  max-width: calc(100vw - 24px);
  margin: auto;
}
.hgHelpDlg::backdrop,
.hgWinDlg::backdrop,
.hgShareDlg::backdrop{ background: rgba(0,0,0,.55); }
:root[data-theme="light"] .hgHelpDlg::backdrop,
:root[data-theme="light"] .hgWinDlg::backdrop,
:root[data-theme="light"] .hgShareDlg::backdrop{ background: rgba(0,0,0,.35); }

.hgHelp{
  padding: 10px 10px 12px;
  max-width: 560px;
}
.hgHelpScroll{
  max-height: 70vh;
  overflow: auto;
  padding-right: 2px;
}
.hgHelpBox{
  border: 1px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.02);
  border-radius: 12px;
  padding: 9px 10px;
  margin: 8px 0;
}
:root[data-theme="light"] .hgHelpBox{
  border-color: rgba(11,15,20,.12);
  background: rgba(11,15,20,.02);
}
.hgHelpKicker{
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
  opacity: .78;
  margin-bottom: 6px;
}
.hgHelpList{ margin:0; padding-left: 18px; }
.hgHelpList li{ margin:5px 0; }
.hgHelpActions{
  display:flex;
  gap:10px;
  justify-content:flex-end;
  flex-wrap:wrap;
  margin-top: 8px;
}

.hgWinActions{
  display:flex;
  gap:10px;
  justify-content:flex-end;
  flex-wrap:wrap;
  margin-top: 12px;
}
.hgPbLine{
  margin-top: 8px;
  font-weight: 900;
  letter-spacing: .01em;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--hg-done-bg);
  border: 1px solid var(--hg-done-br);
}

/* Light mode: make selected seg more obvious */
:root[data-theme="light"] .seg.on{
  box-shadow: 0 0 0 3px rgba(0,120,255,.18) inset;
}

@media (prefers-reduced-motion: reduce){
  .hgIsland{ transition:none !important; }
  .hgMoreBtn{ animation:none !important; }
}

/* Mode pills always 1 row */
.hgCard .modeSeg{
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  width: 100%;
}
.hgCard .modeSeg .seg{
  width:100%;
  min-width:0;
  white-space:nowrap;
  padding: 10px 10px;
  font-size: 13px;
}
@media (max-width: 360px){
  .hgCard .modeSeg{ gap:5px; }
  .hgCard .modeSeg .seg{ padding: 9px 8px; font-size: 12.5px; }
}



