.counter-panel {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 8;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(420px, calc(100% - 24px));
  max-height: min(360px, calc(100% - 24px));
  overflow: hidden;
  border: 2px solid #afcb91;
  border-radius: 10px;
  background: #eef3df;
  color: #17231a;
  box-shadow: 0 0 0 3px #14261b, 0 8px 28px #0008;
  font: 13px/1.5 Manrope, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  pointer-events: auto;
}

.counter-panel[hidden],
.counter-panel [hidden] {
  display: none !important;
}

.counter-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  border-bottom: 1px solid #bccdab;
  background: #dce8c8;
}

.counter-header h3 {
  margin: 0;
  font-size: 16px;
  line-height: 1.3;
}

.counter-content {
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 10px 12px 12px;
  scrollbar-color: #78916a #e4ecd4;
}

.counter-note,
.counter-empty,
.counter-message p,
.counter-status {
  margin: 0;
  overflow-wrap: anywhere;
}

.counter-note,
.counter-empty {
  color: #526248;
  font-size: 12px;
}

.counter-panel button {
  min-height: 44px;
  min-width: 44px;
  padding: 8px 12px;
  border: 1px solid #9caf86;
  border-radius: 7px;
  background: #f8faed;
  color: #23351d;
  font: 700 13px/1.35 Manrope, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  cursor: pointer;
  touch-action: manipulation;
}

.counter-panel button:hover:not(:disabled) {
  border-color: #5c7d43;
  background: #e4edce;
}

.counter-panel button:focus-visible {
  outline: 3px solid #496a35;
  outline-offset: 2px;
}

.counter-panel button:active:not(:disabled) {
  background: #d4e6b5;
}

.counter-panel button:disabled {
  opacity: .5;
  cursor: not-allowed;
}

.counter-header button {
  flex-shrink: 0;
  background: transparent;
}

.counter-kind {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.counter-kind button[aria-pressed="true"],
.counter-panel .counter-primary {
  border-color: #5a753a;
  background: #c4e992;
  color: #213416;
}

.counter-friends {
  display: grid;
  gap: 7px;
  margin-top: 10px;
}

.counter-friends > button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-width: 0;
  text-align: left;
  overflow-wrap: anywhere;
}

.counter-friends > button small {
  flex-shrink: 0;
  color: #596b4c;
  font-size: 11px;
  font-weight: 500;
}

.counter-empty {
  padding: 10px 0 2px;
}

.counter-message {
  margin-top: 10px;
  padding: 10px;
  border: 1px solid #a4b78c;
  border-radius: 7px;
  background: #e2eccd;
}

.counter-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.counter-actions button {
  flex: 1 1 auto;
}

.counter-status:not(:empty) {
  margin-top: 10px;
  color: #495d36;
  font-size: 12px;
}

@media (max-width: 680px) {
  .counter-panel {
    right: 8px;
    bottom: 8px;
    left: 8px;
    width: auto;
    max-height: calc(100% - 16px);
  }

  .counter-header {
    gap: 8px;
    padding: 6px 9px;
  }

  .counter-header h3 {
    font-size: 15px;
  }

  .counter-content {
    padding: 8px 9px 10px;
  }

  .counter-kind,
  .counter-friends,
  .counter-message {
    margin-top: 8px;
  }
}

@media (orientation: landscape) and (max-height: 540px) {
  .counter-panel {
    max-height: min(320px, calc(100% - 16px));
  }
}
