*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg-base: #e8ecf4;
  --text-primary: rgba(20, 24, 32, 0.88);
  --text-secondary: rgba(20, 24, 32, 0.45);
  --glass-bg: rgba(255, 255, 255, 0.35);
  --glass-border: rgba(255, 255, 255, 0.55);
  --glass-highlight: rgba(255, 255, 255, 0.65);
  --shadow-soft: 0 8px 32px rgba(0, 0, 0, 0.06);
  --success-tint: rgba(72, 199, 142, 0.22);
  --failure-tint: rgba(220, 120, 110, 0.2);
  --radius-card: 24px;
  --radius-btn: 20px;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in: cubic-bezier(0.4, 0, 1, 1);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", system-ui, sans-serif;
  --font-num: "Outfit", var(--font);
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100dvh;
  font-family: var(--font);
  color: var(--text-primary);
  background: var(--bg-base);
  overflow-x: hidden;
}

.bg-mesh {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 80% 60% at 20% 10%, rgba(180, 210, 255, 0.45), transparent 60%),
    radial-gradient(ellipse 70% 50% at 85% 25%, rgba(200, 180, 255, 0.35), transparent 55%),
    radial-gradient(ellipse 90% 70% at 50% 90%, rgba(160, 230, 210, 0.3), transparent 60%),
    var(--bg-base);
  animation: meshDrift 24s ease-in-out infinite alternate;
}

@keyframes meshDrift {
  from { transform: scale(1) translate(0, 0); }
  to { transform: scale(1.04) translate(-1%, 1%); }
}

@media (prefers-reduced-motion: reduce) {
  .bg-mesh { animation: none; }
  .hero-count.bump { animation: none !important; }
  .hero-count.bump-success { animation: none !important; }
  .stat-value.stat-bump { animation: none !important; }
  .hero-sub strong.stat-bump { animation: none !important; }
  .hero.undo-flash { animation: none !important; }
  .action-btn { transition: none; }
  .undo-toast { transition: none; }
  .history-modal[open]::backdrop,
  .history-modal[open] .history-panel,
  .history-modal.is-closing::backdrop,
  .history-modal.is-closing .history-panel { animation: none !important; }
  .menu-overlay.is-open .menu-sheet-panel,
  .menu-overlay.is-closing .menu-sheet-panel,
  .menu-overlay.is-open .menu-item { animation: none !important; }
  .menu-trigger .menu-icon span { transition: none; }
  .confirm-overlay.is-open .confirm-backdrop,
  .confirm-overlay.is-open .confirm-panel,
  .confirm-overlay.is-closing .confirm-backdrop,
  .confirm-overlay.is-closing .confirm-panel { animation: none !important; }
}

.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--glass-border);
  box-shadow:
    var(--shadow-soft),
    inset 0 1px 0 var(--glass-highlight);
}

.app {
  position: relative;
  z-index: 1;
  max-width: 420px;
  margin: 0 auto;
  padding:
    calc(24px + env(safe-area-inset-top, 0px))
    20px
    calc(88px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 28px;
  min-height: 100dvh;
}

.hero {
  border-radius: var(--radius-card);
  padding: 36px 28px 32px;
  text-align: center;
  position: relative;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

.hero.undo-flash {
  animation: undoFlash 0.45s var(--ease-out);
}

@keyframes undoFlash {
  0%, 100% { filter: brightness(1); }
  40% { filter: brightness(1.06); }
}

.hero-label {
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.hero-count {
  font-family: var(--font-num);
  font-size: 4.75rem;
  font-weight: 200;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.05em;
  font-feature-settings: "tnum" 1;
}

.hero-count.bump {
  animation: countBump 0.52s var(--ease-out);
}

.hero-count.bump-success {
  animation: countBumpSuccess 0.58s var(--ease-out);
}

@keyframes countBump {
  0% { transform: scale(1); opacity: 1; }
  22% { transform: scale(1.1); opacity: 0.88; }
  48% { transform: scale(0.96); opacity: 1; }
  72% { transform: scale(1.03); }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes countBumpSuccess {
  0% { transform: scale(1); color: inherit; }
  24% { transform: scale(1.12); color: rgba(40, 150, 105, 0.95); }
  52% { transform: scale(0.96); color: inherit; }
  100% { transform: scale(1); color: inherit; }
}

@keyframes statBump {
  0% { transform: translateY(0) scale(1); }
  35% { transform: translateY(-3px) scale(1.14); }
  100% { transform: translateY(0) scale(1); }
}

.stat-value.stat-bump,
.hero-sub strong.stat-bump {
  display: inline-block;
  animation: statBump 0.42s var(--ease-out);
}

.hero-sub {
  margin-top: 16px;
  font-size: 0.9375rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.hero-sub strong {
  font-family: var(--font-num);
  font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

.dot {
  opacity: 0.35;
}

.undo-toast {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%) translateY(6px);
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.55);
  font-size: 0.75rem;
  color: var(--text-secondary);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.undo-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.stat-pill {
  border-radius: var(--radius-btn);
  padding: 14px 10px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-label {
  font-size: 0.6875rem;
  color: var(--text-secondary);
  font-weight: 500;
  white-space: nowrap;
}

.stat-value {
  font-family: var(--font-num);
  font-size: 1.375rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  letter-spacing: -0.02em;
}

.actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  width: min(240px, 100%);
  margin: auto auto 0;
}

.action-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 88px;
  padding: 14px 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.28);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  box-shadow:
    0 10px 28px rgba(0, 0, 0, 0.05),
    inset 0 1px 0 rgba(255, 255, 255, 0.72);
  font-family: inherit;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
  transition:
    transform 0.4s var(--ease-out),
    box-shadow 0.35s ease,
    border-color 0.25s ease;
}

.action-btn::after {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0.55;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.action-btn.success {
  color: rgba(28, 110, 78, 0.92);
}

.action-btn.success::after {
  background: radial-gradient(circle at 50% 28%, rgba(72, 199, 142, 0.28), transparent 62%);
}

.action-btn.failure {
  color: rgba(130, 72, 68, 0.92);
}

.action-btn.failure::after {
  background: radial-gradient(circle at 50% 28%, rgba(220, 120, 110, 0.26), transparent 62%);
}

.action-mark {
  position: relative;
  z-index: 1;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.65);
  background: rgba(255, 255, 255, 0.42);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75);
}

.action-btn.success .action-mark {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.75),
    0 0 0 3px rgba(72, 199, 142, 0.12);
}

.action-btn.failure .action-mark {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.75),
    0 0 0 3px rgba(220, 120, 110, 0.12);
}

.action-mark::before {
  content: '';
  position: absolute;
  inset: 0;
  margin: auto;
}

.action-btn.success .action-mark::before {
  width: 7px;
  height: 11px;
  border-right: 2px solid rgba(52, 170, 120, 0.95);
  border-bottom: 2px solid rgba(52, 170, 120, 0.95);
  transform: rotate(45deg) translate(-1px, -1px);
  border-radius: 1px;
}

.action-btn.failure .action-mark::before {
  width: 11px;
  height: 2px;
  background: rgba(195, 95, 88, 0.95);
  border-radius: 999px;
  transform: rotate(45deg);
}

.action-btn.failure .action-mark::after {
  content: '';
  position: absolute;
  inset: 0;
  margin: auto;
  width: 11px;
  height: 2px;
  background: rgba(195, 95, 88, 0.95);
  border-radius: 999px;
  transform: rotate(-45deg);
}

.action-label {
  position: relative;
  z-index: 1;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.06em;
}

.action-btn:active {
  transform: scale(0.97) translateY(1px);
  transition-duration: 0.08s;
  border-color: rgba(255, 255, 255, 0.72);
  box-shadow:
    0 4px 14px rgba(0, 0, 0, 0.04),
    inset 0 2px 8px rgba(0, 0, 0, 0.03),
    inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

.action-btn:active::after {
  opacity: 0.75;
}

.bottom-bar {
  position: fixed;
  right: max(20px, calc((100% - 420px) / 2 + 20px));
  bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  z-index: 1001;
  display: flex;
  justify-content: flex-end;
  pointer-events: none;
}

.menu-trigger {
  pointer-events: auto;
  width: 52px;
  height: 52px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.55);
  background: rgba(255, 255, 255, 0.38);
  backdrop-filter: blur(18px) saturate(170%);
  -webkit-backdrop-filter: blur(18px) saturate(170%);
  box-shadow:
    0 8px 24px rgba(0, 0, 0, 0.07),
    inset 0 1px 0 rgba(255, 255, 255, 0.7);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition:
    transform 0.38s var(--ease-out),
    box-shadow 0.3s ease,
    background 0.25s ease;
}

.menu-trigger:active {
  transform: scale(0.94);
}

.menu-trigger[aria-expanded="true"] {
  background: rgba(255, 255, 255, 0.52);
  box-shadow:
    0 4px 16px rgba(0, 0, 0, 0.06),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.menu-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 100%;
  height: 100%;
}

.menu-icon span {
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 999px;
  background: rgba(20, 24, 32, 0.55);
  transition:
    transform 0.32s var(--ease-out),
    opacity 0.2s ease,
    width 0.25s ease;
}

.menu-trigger[aria-expanded="true"] .menu-icon span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
  width: 20px;
}

.menu-trigger[aria-expanded="true"] .menu-icon span:nth-child(2) {
  opacity: 0;
  transform: scaleX(0);
}

.menu-trigger[aria-expanded="true"] .menu-icon span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
  width: 20px;
}

.menu-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  pointer-events: none;
  visibility: hidden;
}

.menu-overlay.is-open,
.menu-overlay.is-closing {
  visibility: visible;
  pointer-events: auto;
}

.menu-backdrop {
  position: absolute;
  inset: 0;
  border: none;
  padding: 0;
  background: rgba(232, 236, 244, 0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  opacity: 0;
}

.menu-overlay.is-open .menu-backdrop {
  animation: fadeIn 0.32s var(--ease-out) forwards;
}

.menu-overlay.is-closing .menu-backdrop {
  animation: fadeOut 0.2s var(--ease-in) forwards;
}

.menu-sheet-panel {
  position: relative;
  z-index: 1;
  width: min(420px, calc(100% - 32px));
  margin-bottom: calc(68px + env(safe-area-inset-bottom, 0px));
  border-radius: 24px;
  padding: 8px 0 12px;
  transform-origin: bottom center;
  transform: translateY(100%);
  opacity: 0;
}

.menu-overlay.is-open .menu-sheet-panel {
  animation: menuSheetIn 0.38s var(--ease-out) forwards;
}

.menu-overlay.is-closing .menu-sheet-panel {
  animation: menuSheetOut 0.22s var(--ease-in) forwards;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes menuSheetIn {
  from { transform: translateY(100%); opacity: 0.6; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes menuSheetOut {
  from { transform: translateY(0); opacity: 1; }
  to { transform: translateY(100%); opacity: 0.5; }
}

.menu-sheet-handle {
  width: 36px;
  height: 4px;
  margin: 6px auto 10px;
  border-radius: 999px;
  background: rgba(20, 24, 32, 0.12);
}

.menu-list {
  list-style: none;
  margin: 0;
  padding: 4px 12px;
}

.menu-list li + li {
  margin-top: 4px;
}

.menu-item {
  width: 100%;
  padding: 14px 16px;
  border: none;
  border-radius: 14px;
  background: transparent;
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.2s ease, transform 0.25s var(--ease-out);
}

.menu-overlay.is-open .menu-item {
  animation: menuItemIn 0.36s var(--ease-out) backwards;
}

.menu-list li:nth-child(1) .menu-item { animation-delay: 0.05s; }
.menu-list li:nth-child(2) .menu-item { animation-delay: 0.08s; }
.menu-list li:nth-child(3) .menu-item { animation-delay: 0.11s; }
.menu-list li:nth-child(4) .menu-item { animation-delay: 0.14s; }
.menu-list li:nth-child(5) .menu-item { animation-delay: 0.17s; }

@keyframes menuItemIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.menu-item:active {
  background: rgba(255, 255, 255, 0.35);
  transform: scale(0.98);
}

.menu-item.danger {
  color: rgba(150, 70, 65, 0.95);
}

.install-hint {
  position: relative;
  padding: 14px 36px 14px 16px;
  border-radius: 16px;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--text-secondary);
}

.install-hint-close {
  position: absolute;
  top: 8px;
  right: 10px;
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  font-size: 1.25rem;
  line-height: 1;
  color: var(--text-secondary);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.confetti-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1000;
}

.history-modal {
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  margin: 0;
  padding: 14vh 28px 18vh;
  border: none;
  background: transparent;
  overflow: hidden;
}

.history-modal[open] {
  display: flex;
  align-items: center;
  justify-content: center;
}

.history-modal::backdrop {
  background: rgba(232, 236, 244, 0.5);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.history-modal[open]::backdrop {
  animation: modalBackdropIn 0.35s var(--ease-out) forwards;
}

.history-modal.is-closing::backdrop {
  animation: modalBackdropOut 0.18s var(--ease-in) forwards;
}

.history-modal[open] .history-panel {
  animation: modalPanelIn 0.38s var(--ease-out) forwards;
}

.history-modal.is-closing .history-panel {
  animation: modalPanelOut 0.18s var(--ease-in) forwards;
}

@keyframes modalBackdropIn {
  from {
    opacity: 0;
    backdrop-filter: blur(0);
    -webkit-backdrop-filter: blur(0);
  }
  to {
    opacity: 1;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
  }
}

@keyframes modalBackdropOut {
  from {
    opacity: 1;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
  }
  to {
    opacity: 0;
    backdrop-filter: blur(0);
    -webkit-backdrop-filter: blur(0);
  }
}

@keyframes modalPanelIn {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.94);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes modalPanelOut {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(12px) scale(0.96);
  }
}

.history-panel {
  display: flex;
  flex-direction: column;
  width: min(300px, 100%);
  max-height: min(54dvh, 380px);
  border-radius: 20px;
  overflow: hidden;
  transform-origin: center center;
  flex-shrink: 0;
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.35);
}

.history-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
}

.history-close {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.25);
  font-size: 1.25rem;
  line-height: 1;
  color: var(--text-secondary);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.history-list {
  list-style: none;
  margin: 0;
  padding: 8px 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
}

.history-item + .history-item {
  border-top: 1px solid rgba(255, 255, 255, 0.22);
}

.history-time {
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.history-badge {
  flex-shrink: 0;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
}

.history-badge.success {
  background: color-mix(in srgb, var(--success-tint) 80%, rgba(255, 255, 255, 0.5));
  color: rgba(30, 120, 80, 0.9);
}

.history-badge.failure {
  background: color-mix(in srgb, var(--failure-tint) 80%, rgba(255, 255, 255, 0.5));
  color: rgba(150, 70, 65, 0.95);
}

.history-empty {
  padding: 32px 20px 40px;
  text-align: center;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  pointer-events: none;
  visibility: hidden;
}

.confirm-overlay.is-open,
.confirm-overlay.is-closing {
  visibility: visible;
  pointer-events: auto;
}

.confirm-backdrop {
  position: absolute;
  inset: 0;
  border: none;
  padding: 0;
  background: rgba(232, 236, 244, 0.5);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  opacity: 0;
}

.confirm-overlay.is-open .confirm-backdrop {
  animation: fadeIn 0.28s var(--ease-out) forwards;
}

.confirm-overlay.is-closing .confirm-backdrop {
  animation: fadeOut 0.18s var(--ease-in) forwards;
}

.confirm-panel {
  position: relative;
  z-index: 1;
  width: min(320px, 100%);
  padding: 22px 20px 18px;
  border-radius: 22px;
  transform: scale(0.92);
  opacity: 0;
}

.confirm-overlay.is-open .confirm-panel {
  animation: confirmPanelIn 0.32s var(--ease-out) forwards;
}

.confirm-overlay.is-closing .confirm-panel {
  animation: confirmPanelOut 0.18s var(--ease-in) forwards;
}

@keyframes confirmPanelIn {
  from { opacity: 0; transform: scale(0.92) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes confirmPanelOut {
  from { opacity: 1; transform: scale(1) translateY(0); }
  to { opacity: 0; transform: scale(0.96) translateY(6px); }
}

.confirm-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.confirm-message {
  font-size: 0.875rem;
  line-height: 1.55;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

.confirm-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.confirm-btn {
  min-height: 44px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.2s var(--ease-out), background 0.2s ease;
}

.confirm-btn:active {
  transform: scale(0.97);
}

.confirm-btn.cancel {
  background: rgba(255, 255, 255, 0.22);
  color: var(--text-secondary);
}

.confirm-btn.ok {
  background: rgba(255, 255, 255, 0.42);
  color: var(--text-primary);
}

.confirm-btn.ok.danger {
  background: color-mix(in srgb, var(--failure-tint) 65%, rgba(255, 255, 255, 0.45));
  color: rgba(130, 58, 52, 0.95);
}
