.hp-counter {
  --hp-bg: #20232d;
  --hp-text: #e8e9ef;
  --hp-border: #707487;
  --hp-teal: #79bab6;
  color-scheme: dark;
  box-sizing: border-box;
  width: 580px;
  max-width: calc(100vw - 40px);
  max-height: calc(100dvh - 40px);
  padding: 0;
  border: 1px solid #41485d;
  border-radius: 4px;
  margin: auto;
  background: var(--hp-bg);
  color: var(--hp-text);
  font: 16px/1.5 system-ui, sans-serif;
  overflow-y: auto;
}
.hp-counter::backdrop { background: #11131bd9; }
.hp-counter *, .hp-counter *::before, .hp-counter *::after { box-sizing: border-box; }
.hp-panel { position: relative; padding: 24px 18px 30px; }
.hp-counter .hp-key {
  appearance: none;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  padding: 0;
  margin: 0;
  border: 1px solid var(--hp-border);
  border-radius: 3px;
  background: transparent;
  color: var(--hp-text);
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.hp-counter .hp-key:hover { background: #ffffff08; border-color: #a1a6b8; }
.hp-counter .hp-key:active { background: #ffffff14; }
.hp-counter .hp-key:focus-visible, .hp-counter .hp-expression:focus-visible { outline: 2px solid var(--hp-teal); outline-offset: 3px; }
.hp-counter .hp-key:disabled { opacity: .4; cursor: wait; }
.hp-counter .hp-key[hidden], .hp-counter [hidden] { display: none; }
.hp-key svg { width: 42px; height: 42px; flex: none; }
.hp-counter .hp-close { width: 44px; height: 44px; margin-left: auto; border: 0; }
.hp-close svg { width: 32px; height: 32px; }
.hp-summary { min-height: 108px; display: flex; flex-direction: column; align-items: flex-end; justify-content: center; padding-bottom: 18px; }
.hp-form-label { color: #a2a9bc; font-size: 13px; min-height: 18px; }
.hp-totals { display: flex; align-items: center; gap: 22px; color: var(--hp-teal); }
.hp-totals svg { width: 44px; height: 44px; flex: none; }
.hp-readout { font-size: 52px; font-weight: 650; line-height: 1.35; font-variant-numeric: tabular-nums slashed-zero; }
.hp-readout[data-size="short"] { font-size: 34px; }
.hp-readout[data-size="medium"] { font-size: 20px; }
.hp-readout[data-size="long"] { font-size: 14px; }
.hp-temp { font-size: 13px; color: #a2a9bc; min-height: 18px; }
.hp-entry, .hp-keypad { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) 64px; gap: 18px; }
.hp-entry { margin: 14px 0 18px; }
.hp-counter .hp-expression {
  appearance: none;
  grid-column: span 3;
  width: 100%;
  height: 64px;
  min-width: 0;
  margin: 0;
  padding: 8px 14px;
  border: 1px solid var(--hp-border);
  border-radius: 3px;
  background: transparent;
  color: var(--hp-text);
  font: 32px/1.2 system-ui, sans-serif;
  text-align: right;
}
.hp-keypad { grid-auto-rows: 64px; }
.hp-counter .hp-digit { font-size: 40px; font-weight: 400; font-variant-numeric: slashed-zero; }
.hp-zero { position: relative; }
.hp-zero::after { content: ''; position: absolute; top: 50%; left: 50%; width: 23px; height: 1px; background: currentColor; transform: translate(-50%, -50%) rotate(-52deg); pointer-events: none; }
.hp-counter .hp-action { font-size: 12px; font-weight: 750; }
.hp-counter .hp-temp { color: #94a3c2; }
.hp-counter .hp-heal { color: #9bc8c6; }
.hp-counter .hp-damage { color: #f16a75; }
.hp-settings { color: #8591ae !important; }
.hp-roll { color: #a2a9bc; font-size: 13px; line-height: 1.5; margin: 14px 0 0; min-height: 20px; }
.hp-error { color: #ff939b; font-size: 14px; line-height: 1.5; margin: 8px 0; }
.hp-counter .hp-retry { padding: 12px 16px; font-size: 14px; margin-top: 12px; }
@media (max-width: 699px) {
  .hp-counter { width: 100%; max-width: 100%; height: 100dvh; max-height: 100dvh; border: 0; border-radius: 0; margin: 0; }
  .hp-panel { padding: max(12px, env(safe-area-inset-top)) 14px max(24px, env(safe-area-inset-bottom)); }
  .hp-summary { min-height: 76px; padding-bottom: 0; }
  .hp-form-label { position: absolute; top: 24px; left: 14px; }
  .hp-entry, .hp-keypad { grid-template-columns: repeat(3, minmax(0, 1fr)) 56px; gap: 14px; }
  .hp-entry { margin-top: 10px; margin-bottom: 18px; }
  .hp-counter .hp-expression { height: 56px; }
  .hp-keypad { grid-auto-rows: 56px; }
  .hp-counter .hp-digit { font-size: 36px; }
  .hp-readout { font-size: 46px; line-height: 1.2; }
  .hp-key svg { width: 38px; height: 38px; }
  .hp-totals svg { width: 38px; height: 38px; }
  .hp-counter .hp-action { font-size: 11px; }
}
@media (max-width: 359px) {
  .hp-entry, .hp-keypad { gap: 10px; grid-template-columns: repeat(3, minmax(0, 1fr)) 48px; }
  .hp-panel { padding-left: 12px; padding-right: 12px; }
  .hp-counter .hp-action { font-size: 10px; }
}
