.hh-game {
  --hh-ink: #f1f7ff;
  --hh-muted: #c1d1e7;
  --hh-gold: #ffda78;
  --hh-mint: #a5f0d4;
  --hh-pink: #ffacbd;
  position: relative;
  margin: 2.4rem 0;
  padding: clamp(.9rem, 3vw, 1.35rem);
  overflow: hidden;
  border: 1px solid #405774;
  border-radius: 12px;
  background: linear-gradient(145deg, #213650 0%, #13243c 60%, #1b2943 100%);
  color: var(--hh-ink);
  font-family: var(--sans, system-ui, sans-serif);
  font-size: 15px;
  line-height: 1.5;
  letter-spacing: 0;
  overflow-wrap: anywhere;
  box-shadow: 0 14px 30px rgb(22 38 54 / 16%);
}

.hh-game *, .hh-game *::before, .hh-game *::after,
.hh-source *, .hh-source *::before, .hh-source *::after { box-sizing: border-box; }

.hh-game::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 5px;
  background: linear-gradient(90deg, var(--hh-mint) 0 28%, var(--hh-gold) 28% 63%, var(--hh-pink) 63% 100%);
}

.hh-game h2, .hh-game h3, .hh-game p { margin: 0; }
.hh-game h2, .hh-game h3 {
  color: var(--hh-ink);
  font-family: var(--sans, system-ui, sans-serif);
  letter-spacing: -.025em;
  line-height: 1.2;
}
.hh-game h2 { font-size: clamp(1.4rem, 3.4vw, 1.85rem); }
.hh-game strong { color: inherit; }

.hh-game .hh-intro { margin-bottom: 1rem; }
.hh-game .hh-intro h2 { margin-bottom: .35rem; }
.hh-game .hh-intro p {
  max-width: 60ch;
  color: var(--hh-muted);
  font-size: .92rem;
  line-height: 1.5;
}

.hh-game .hh-hud {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .5rem;
  margin: 0 0 .75rem;
}

.hh-game .hh-hud-item {
  min-width: 0;
  padding: .45rem .7rem;
  border: 1px solid #4a6788;
  border-radius: 5px;
  background: #273c57;
}

.hh-game .hh-hud-label, .hh-game .hh-hud-value { display: block; }
.hh-game .hh-hud-label {
  color: var(--hh-muted);
  font-family: var(--mono, ui-monospace, monospace);
  font-size: .66rem;
  font-weight: 700;
  letter-spacing: .06em;
  line-height: 1.3;
  text-transform: uppercase;
}
.hh-game .hh-hud-value {
  margin-top: .1rem;
  color: var(--hh-gold);
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 1.1rem;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  line-height: 1.25;
}

.hh-game .hh-stage {
  position: relative;
  width: 100%;
  height: 420px;
  overflow: hidden;
  border: 2px solid #6985a2;
  border-radius: 9px;
  background: linear-gradient(#375f82 0%, #6f94a6 70%, #344d54 100%);
  box-shadow: inset 0 0 0 3px rgb(12 24 42 / 25%), 0 8px 0 #0d1b2c;
  isolation: isolate;
}

.hh-game .hh-canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  touch-action: pan-y;
}

.hh-game .hh-overlay {
  position: absolute;
  z-index: 2;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1rem;
  overflow-y: auto;
  background: rgb(9 19 37 / 76%);
  backdrop-filter: blur(2px);
}
.hh-game .hh-overlay[hidden] { display: none !important; }

.hh-game .hh-overlay-card {
  width: min(100%, 390px);
  padding: clamp(1rem, 3vw, 1.5rem);
  border: 2px solid var(--hh-gold);
  border-radius: 8px;
  background: #1f3450;
  color: var(--hh-ink);
  text-align: center;
  box-shadow: 0 9px 0 #101f35, 0 18px 32px rgb(4 12 24 / 35%);
}

.hh-game .hh-overlay-title {
  margin: 0 0 .55rem;
  color: var(--hh-gold);
  font-family: var(--sans, system-ui, sans-serif);
  font-size: clamp(1.35rem, 4vw, 1.9rem);
  font-weight: 700;
  line-height: 1.2;
}
.hh-game .hh-overlay-text {
  margin: 0 0 1rem;
  color: var(--hh-ink);
  font-size: .94rem;
  line-height: 1.5;
}

.hh-game button {
  min-width: 0;
  min-height: 48px;
  border-radius: 5px;
  font: 700 .86rem/1.25 var(--sans, system-ui, sans-serif);
  cursor: pointer;
  touch-action: manipulation;
}
.hh-game button:disabled { opacity: .58; cursor: default; }
.hh-game button:not(:disabled):hover { filter: brightness(1.08); }
.hh-game button:not(:disabled):active { transform: translateY(2px); }

.hh-game .hh-primary {
  padding: .7rem 1.2rem;
  border: 1px solid #fff0ba;
  background: var(--hh-gold);
  color: #17243b;
  box-shadow: 0 4px 0 #ad7e31;
}

.hh-game .hh-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .6rem 1rem;
  margin: 1rem 0 0;
}

.hh-game .hh-move-controls, .hh-game .hh-menu-controls {
  display: flex;
  flex-wrap: wrap;
  gap: .55rem;
}

.hh-game .hh-move-controls { flex: 1 1 17rem; }
.hh-game .hh-menu-controls { flex: 0 1 auto; }

.hh-game .hh-control, .hh-game .hh-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: .6rem .65rem;
  text-align: center;
}
.hh-game .hh-control {
  min-width: 64px;
  border: 1px solid #c8ffea;
  background: var(--hh-mint);
  color: #133d38;
  box-shadow: 0 3px 0 #4c9d88;
  touch-action: none;
}
.hh-game .hh-control--jump {
  min-width: 108px;
  border-color: #ffe2e9;
  background: var(--hh-pink);
  color: #49253b;
  box-shadow: 0 3px 0 #bd6682;
}
.hh-game .hh-secondary {
  min-width: 88px;
  border: 1px solid #91abc7;
  background: #304969;
  color: var(--hh-ink);
}
.hh-game .hh-secondary:not(:disabled):hover { background: #416082; }

.hh-game .hh-howto {
  margin: 1rem 0 0;
  padding: .65rem .8rem;
  border-left: 3px solid var(--hh-mint);
  border-radius: 0 5px 5px 0;
  background: #273e5b;
  color: var(--hh-ink);
  font-size: .84rem;
  line-height: 1.5;
}
.hh-game .hh-howto p, .hh-game .hh-howto ul, .hh-game .hh-howto ol { margin: 0; }
.hh-game .hh-howto ul, .hh-game .hh-howto ol { padding-left: 1.25rem; }
.hh-game .hh-howto kbd {
  display: inline-block;
  min-width: 1.35rem;
  padding: .04rem .25rem;
  border: 1px solid #8ea6bd;
  border-radius: 3px;
  background: #1b2d46;
  color: var(--hh-gold);
  font-family: var(--mono, ui-monospace, monospace);
  font-size: .86em;
  text-align: center;
}

.hh-game .hh-message {
  min-height: 1.5em;
  margin: .8rem 0 0;
  color: var(--hh-muted);
  font-family: var(--mono, ui-monospace, monospace);
  font-size: .8rem;
  line-height: 1.45;
}

.hh-game :focus-visible {
  outline: 3px solid #ffeb96;
  outline-offset: 4px;
}

.hh-source {
  margin: 2.2rem 0;
  padding: 1rem 1.2rem;
  border: 1px solid var(--line, #d9dbd3);
  border-left: 4px solid var(--accent, #a53724);
  border-radius: 2px;
  background: var(--surface, #f0f1ed);
  color: var(--ink, #252722);
  font-family: var(--sans, system-ui, sans-serif);
  font-size: .91rem;
  line-height: 1.55;
}
.hh-source h2, .hh-source h3 {
  margin: 0 0 .45rem;
  font-family: var(--sans, system-ui, sans-serif);
  font-size: 1.12rem;
  font-weight: 700;
  line-height: 1.3;
}
.hh-source p { margin: 0 0 .75rem; }
.hh-source .hh-source-links {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin: .75rem 0 0;
}
.hh-source .hh-source-link {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  gap: .3rem;
  padding: .55rem .75rem;
  border: 1px solid #a5aaa1;
  border-radius: 4px;
  background: #fff;
  color: var(--accent-dark, #772819);
  font: 700 .82rem/1.3 var(--sans, system-ui, sans-serif);
  text-decoration: none;
}
.hh-source .hh-source-link:hover { border-color: var(--accent, #a53724); background: #f8e9e2; }
.hh-source :focus-visible { outline: 3px solid var(--accent, #a53724); outline-offset: 3px; }

@media (max-width: 620px) {
  .hh-game .hh-hud { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hh-game .hh-stage { height: 340px; }
  .hh-game .hh-controls { display: block; }
  .hh-game .hh-move-controls {
    display: grid;
    grid-template-columns: 1fr 1fr 1.5fr;
    gap: .5rem;
  }
  .hh-game .hh-menu-controls {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .5rem;
    margin-top: .5rem;
  }
  .hh-game .hh-control, .hh-game .hh-secondary { width: 100%; min-width: 0; min-height: 56px; }
}

@media (max-width: 420px) {
  .hh-game { padding: .85rem; }
  .hh-game .hh-intro { margin-bottom: .7rem; }
  .hh-game .hh-intro p { font-size: .86rem; }
  .hh-game .hh-hud { gap: .4rem; margin-bottom: .65rem; }
  .hh-game .hh-hud-item { padding: .35rem .5rem; }
  .hh-game .hh-hud-value { font-size: .97rem; }
  .hh-game .hh-overlay { padding: .65rem; }
  .hh-game .hh-overlay-card { padding: .8rem; }
  .hh-game .hh-controls { gap: .4rem; margin-top: .7rem; }
  .hh-game .hh-control, .hh-game .hh-secondary { padding: .55rem .3rem; }
  .hh-source { padding: .85rem; }
  .hh-source .hh-source-link { flex: 1 1 8rem; justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  .hh-game *, .hh-game *::before, .hh-game *::after { transition: none !important; animation: none !important; }
  .hh-game button:not(:disabled):active { transform: none; }
}
