:root {
  color-scheme: dark;
  --ink: #f5f7fb;
  --muted: #93a4b8;
  --panel: rgba(12, 20, 32, 0.78);
  --panel-bright: rgba(245, 247, 251, 0.08);
  --case: #111927;
  --case-edge: #07111f;
  --display: #d9f7ee;
  --display-ink: #08261e;
  --accent: #5de4c7;
  --accent-dark: #1ca98d;
  --warm: #ffb86b;
  --warning: #ff5d73;
  --steel: #d9e3ee;
  --line: rgba(126, 234, 214, 0.16);
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.42);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background:
    linear-gradient(rgba(93, 228, 199, 0.09) 1px, transparent 1px),
    linear-gradient(90deg, rgba(93, 228, 199, 0.09) 1px, transparent 1px),
    linear-gradient(135deg, #080d17 0%, #111827 48%, #0d1524 100%);
  background-attachment: fixed;
  background-size:
    42px 42px,
    42px 42px,
    auto;
}

button,
input {
  font: inherit;
}

button,
a {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

.app-shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 28px 0 36px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

h1 {
  margin: 0;
  font-size: clamp(30px, 5vw, 58px);
  line-height: 1;
  letter-spacing: 0;
}

.home-view {
  min-height: calc(100vh - 64px);
  display: grid;
  align-content: center;
  gap: 28px;
}

.home-hero {
  max-width: 760px;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--accent);
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0;
}

.tool-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.tool-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px;
  min-height: 116px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.03)),
    rgba(8, 13, 23, 0.76);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    border-color 160ms ease,
    background-color 160ms ease;
}

.tool-card:hover {
  transform: translateY(-2px);
  border-color: rgba(93, 228, 199, 0.5);
  background:
    linear-gradient(135deg, rgba(93, 228, 199, 0.13), rgba(255, 184, 107, 0.05)),
    rgba(8, 13, 23, 0.86);
  box-shadow: 0 26px 80px rgba(0, 0, 0, 0.48);
}

.tool-index {
  display: grid;
  width: 50px;
  height: 50px;
  place-items: center;
  border-radius: 8px;
  color: #07111f;
  background: var(--accent);
  font-weight: 900;
}

.tool-card-body {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.tool-name {
  font-size: clamp(22px, 3vw, 30px);
  font-weight: 950;
  line-height: 1.05;
}

.tool-meta {
  color: var(--muted);
  font-size: 14px;
  font-weight: 750;
}

.tool-arrow {
  color: var(--accent);
  font-size: 30px;
  font-weight: 900;
}

.topbar p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 15px;
}

.topbar-actions,
.counter-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-button,
.text-button,
.mini-button {
  border: 0;
  border-radius: 8px;
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    background-color 160ms ease;
}

.icon-button {
  width: 48px;
  height: 48px;
  color: #06131f;
  background: var(--accent);
  box-shadow: 0 12px 32px rgba(93, 228, 199, 0.22);
  font-size: 32px;
  line-height: 1;
}

.text-button {
  display: inline-grid;
  place-items: center;
  min-height: 44px;
  padding: 0 16px;
  color: var(--ink);
  background: var(--panel-bright);
  box-shadow: inset 0 0 0 1px rgba(245, 247, 251, 0.13);
  font-weight: 700;
}

.link-button {
  text-decoration: none;
}

.text-button.dark {
  color: #07111f;
  background: var(--accent);
}

.icon-button:hover,
.text-button:hover,
.mini-button:hover {
  transform: translateY(-1px);
}

.icon-button:active,
.text-button:active,
.mini-button:active,
.count-face:active {
  transform: translateY(1px);
}

.control-strip {
  display: flex;
  align-items: end;
  gap: 12px;
  margin-bottom: 22px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(8, 13, 23, 0.56);
  backdrop-filter: blur(18px);
}

.field {
  display: grid;
  gap: 7px;
  min-width: 170px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.field input {
  width: 100%;
  height: 44px;
  border: 1px solid rgba(245, 247, 251, 0.14);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.08);
  font-size: 20px;
  font-weight: 800;
}

.counter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 18px;
  align-items: start;
}

.counter {
  position: relative;
  min-height: 310px;
  padding: 18px;
  border-radius: 8px;
  color: white;
  background:
    linear-gradient(145deg, rgba(93, 228, 199, 0.12), rgba(255, 255, 255, 0.03)),
    var(--case);
  box-shadow:
    var(--shadow),
    inset 0 0 0 1px rgba(93, 228, 199, 0.18),
    inset 0 -10px 0 rgba(0, 0, 0, 0.14);
}

.counter::before {
  position: absolute;
  inset: 9px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  pointer-events: none;
  content: "";
}

.counter-top {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr 34px;
  gap: 10px;
  margin-bottom: 10px;
}

.counter-name {
  width: 100%;
  height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 12px;
  color: var(--case-edge);
  background: var(--steel);
  box-shadow: inset 0 2px 5px rgba(25, 30, 35, 0.22);
  font-size: 16px;
  font-weight: 900;
}

.timestamp {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  margin-bottom: 14px;
  padding: 7px 10px;
  border: 1px solid rgba(93, 228, 199, 0.2);
  border-radius: 8px;
  color: rgba(244, 250, 255, 0.94);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(0, 0, 0, 0.08)),
    rgba(16, 24, 33, 0.52);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 8px 18px rgba(0, 0, 0, 0.12);
  font-variant-numeric: tabular-nums;
}

.timestamp-date {
  overflow: hidden;
  color: rgba(213, 230, 242, 0.86);
  font-size: 13px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.timestamp-time {
  color: #8ee8d5;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 17px;
  font-weight: 900;
  letter-spacing: 0;
  white-space: nowrap;
}

.count-face {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 8px;
  width: 100%;
  min-height: 150px;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 8px;
  color: var(--display-ink);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0)),
    var(--display);
  box-shadow:
    inset 0 0 0 5px rgba(24, 31, 38, 0.28),
    inset 0 10px 18px rgba(255, 255, 255, 0.38),
    inset 0 -10px 20px rgba(68, 84, 58, 0.12);
}

.digit-window {
  --digit-offset: 0;
  position: relative;
  width: clamp(52px, 21%, 72px);
  height: 88px;
  overflow: hidden;
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(28, 40, 31, 0.18), transparent 24%, transparent 76%, rgba(28, 40, 31, 0.16)),
    rgba(255, 255, 255, 0.24);
  box-shadow:
    inset 0 0 0 1px rgba(31, 45, 34, 0.14),
    inset 0 6px 10px rgba(255, 255, 255, 0.32),
    inset 0 -8px 12px rgba(32, 45, 35, 0.12);
}

.digit-window::before,
.digit-window::after {
  position: absolute;
  left: 0;
  z-index: 2;
  width: 100%;
  height: 28px;
  pointer-events: none;
  content: "";
}

.digit-window::before {
  top: 0;
  background: linear-gradient(180deg, rgba(232, 240, 214, 0.96), rgba(232, 240, 214, 0));
}

.digit-window::after {
  bottom: 0;
  background: linear-gradient(0deg, rgba(232, 240, 214, 0.96), rgba(232, 240, 214, 0));
}

.digit-reel {
  display: grid;
  transform: translateY(calc(var(--digit-offset) * -88px));
  transition: transform 360ms cubic-bezier(0.18, 0.8, 0.24, 1);
}

.digit-reel span {
  display: grid;
  height: 88px;
  place-items: center;
  font-family: "Arial Black", Impact, ui-monospace, monospace;
  font-size: clamp(54px, 9vw, 76px);
  line-height: 1;
  letter-spacing: 0;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.counter-actions {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 18px;
}

.mini-button {
  min-width: 0;
  min-height: 34px;
  padding: 0 8px;
  color: white;
  background: #596573;
  box-shadow:
    inset 0 -3px 0 rgba(0, 0, 0, 0.2),
    0 8px 14px rgba(0, 0, 0, 0.12);
  font-weight: 900;
}

.increment-ten {
  background: var(--accent-dark);
}

.clear-counter {
  background: var(--warning);
}

.delete-counter {
  padding: 0;
  background: var(--warning);
  font-size: 22px;
}

.empty-state {
  min-height: 260px;
  display: grid;
  place-items: center;
  border: 1px dashed rgba(93, 228, 199, 0.32);
  border-radius: 8px;
  background: rgba(8, 13, 23, 0.52);
  color: var(--muted);
  font-weight: 800;
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 20px, 480px);
    padding-top: 18px;
  }

  .topbar {
    align-items: start;
    flex-direction: column;
  }

  .topbar-actions,
  .control-strip {
    width: 100%;
  }

  .topbar-actions {
    display: grid;
    grid-template-columns: 1fr 48px 1fr;
  }

  .topbar-actions .text-button,
  .control-strip .text-button {
    flex: 1;
  }

  .control-strip {
    align-items: stretch;
    flex-direction: column;
  }

  .field {
    min-width: 0;
  }

  .counter-grid {
    grid-template-columns: 1fr;
  }

  .counter {
    min-height: 292px;
  }

  .home-view {
    min-height: calc(100vh - 36px);
    align-content: start;
    padding-top: 34px;
  }

  .tool-card {
    grid-template-columns: auto 1fr;
  }

  .tool-arrow {
    display: none;
  }

  .digit-window {
    width: clamp(56px, 24%, 74px);
    height: 82px;
  }

  .digit-reel {
    transform: translateY(calc(var(--digit-offset) * -82px));
  }

  .digit-reel span {
    height: 82px;
    font-size: clamp(48px, 17vw, 66px);
  }
}
