:root {
  --paper: #f6f3eb;
  --ink: #253d36;
  --muted: #737b6b;
  --line: #dedfd3;
  --green: #376653;
  --blue: #397d9a;
  --gold: #a27628;
  --card: #fffcf5;
  --serif: Georgia, 'Yu Mincho', 'Hiragino Mincho ProN', serif
}

* {
  box-sizing: border-box
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', sans-serif;
  font-size: 14px
}

button,
input,
select,
textarea {
  font: inherit
}

button {
  cursor: pointer;
  color: inherit;
  touch-action: manipulation
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 3px solid #68a58b;
  outline-offset: 3px
}

button {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 10px;
  min-height: 44px
}

button:hover {
  filter: brightness(.97)
}

button:active {
  transform: translateY(1px)
}

.wrap {
  max-width: 1080px;
  margin: auto;
  padding: 0 28px
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 25px 0;
  border-bottom: 1px solid var(--line);
  gap: 10px
}

.brand {
  display: flex;
  gap: 11px;
  align-items: center
}

.brand-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid #b7c5b2;
  border-radius: 50%;
  color: var(--green)
}

.brand small {
  font-size: 10px;
  letter-spacing: 2px;
  display: block;
  margin-bottom: 4px
}

.brand strong {
  font-family: var(--serif);
  font-size: 17px
}

.quiet {
  border: 0;
  background: transparent;
  padding: 0 12px;
  color: var(--muted)
}

.hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 40px 0 28px;
  gap: 24px
}

.eyebrow {
  letter-spacing: 2px;
  font-size: 10px;
  color: var(--green);
  font-weight: 700
}

.hero h1 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 38px;
  letter-spacing: 3px;
  margin: 12px 0
}

.hero p {
  color: var(--muted);
  line-height: 1.9;
  margin: 0
}

.stamp {
  width: 96px;
  height: 96px;
  flex: none;
  border: 1px solid #b6beab;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transform: rotate(7deg);
  color: #68816b;
  box-shadow: inset 0 0 0 5px var(--paper), inset 0 0 0 6px #c8cebd
}

.stamp span {
  font-size: 25px;
  font-family: var(--serif);
  letter-spacing: 5px;
  padding-left: 5px
}

.stamp small {
  font-size: 9px;
  letter-spacing: 2px;
  margin-top: 5px
}

.overview {
  display: grid;
  grid-template-columns: 1.4fr repeat(3, 1fr);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  margin-bottom: 26px
}

.stat {
  padding: 22px;
  border-right: 1px solid var(--line)
}

.stat:last-child {
  border: 0
}

.stat-title {
  font-size: 11px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  gap: 8px
}

.stat-number {
  font-family: var(--serif);
  font-size: 30px;
  margin: 10px 0
}

.stat-number small {
  font: 12px sans-serif;
  color: var(--muted);
  padding-left: 4px
}

.stat-sub {
  font-size: 10px;
  color: var(--muted)
}

.bar {
  height: 4px;
  background: #e8e8dc;
  border-radius: 5px;
  overflow: hidden;
  margin: 14px 0 9px
}

.bar>i {
  display: block;
  height: 100%;
  background: var(--green);
  transition: width .2s
}

.dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  background: currentColor;
  border-radius: 50%;
  margin-right: 6px
}

.blue {
  color: var(--blue)
}

.gold {
  color: var(--gold)
}

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

.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: #e9ebdf;
  border-radius: 12px
}

.tabs button {
  border: 0;
  background: none;
  padding: 0 25px;
  min-width: 102px;
  min-height: 42px;
  color: var(--muted)
}

.tabs button[aria-selected=true] {
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 1px 4px #233c3210
}

.search {
  position: relative;
  flex: 1;
  max-width: 330px
}

.search input {
  width: 100%;
  min-height: 46px;
  padding: 0 14px 0 40px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #ffffff70;
  color: var(--ink);
  font-size: 16px
}

.search svg {
  position: absolute;
  left: 13px;
  top: 15px;
  color: var(--muted)
}

.filters {
  display: flex;
  gap: 7px;
  align-items: center;
  flex-wrap: wrap
}

.chip {
  border-radius: 22px;
  min-height: 34px;
  padding: 0 13px;
  font-size: 12px;
  background: transparent
}

.chip[aria-pressed=true] {
  background: var(--green);
  border-color: var(--green);
  color: white
}

.list-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 23px 0 12px;
  font-size: 12px;
  color: var(--muted)
}

.list-heading strong {
  color: var(--ink);
  font-size: 14px;
  font-weight: 500
}

.legend {
  font-size: 11px;
  color: var(--muted);
  margin: 0 0 16px;
  line-height: 1.8
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px
}

.item {
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--card);
  padding: 17px 18px
}

.item-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 13px;
  gap: 8px
}

.item-name {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .4px
}

.item-count {
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap
}

.item.complete .item-count {
  color: var(--green)
}

.cells {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px
}

.cell {
  border: 1px dashed #d5d8cb;
  min-height: 57px;
  border-radius: 9px;
  background: transparent;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px
}

.cell span {
  font-size: 10px;
  opacity: .85
}

.cell b {
  font-size: 15px;
  font-weight: 500;
  line-height: 1
}

.cell.owned {
  border-style: solid;
  background: #edf1e7;
  border-color: #cbd8c1
}

.cell.blue.owned {
  background: #eaf2f4;
  border-color: #b9d4df
}

.cell.gold.owned {
  background: #f8f0dc;
  border-color: #e1cd9f
}

.cell.max b {
  font-weight: 700
}

.cell .star {
  font-size: 10px;
  margin-left: 3px
}

.empty {
  padding: 45px;
  text-align: center;
  grid-column: 1/-1;
  color: var(--muted);
  line-height: 1.9
}

.bottom {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 27px 0
}

.bottom button {
  padding: 0 15px;
  font-size: 12px
}

.footer {
  border-top: 1px solid var(--line);
  padding: 21px 0 36px;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.9
}

.footer a {
  color: inherit
}

.save-state {
  color: var(--green)
}

dialog {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--card);
  color: var(--ink);
  padding: 27px;
  width: min(500px, calc(100% - 26px));
  max-height: 90dvh;
  overflow: auto;
  box-shadow: 0 20px 90px #162b3230
}

dialog::backdrop {
  background: #192b285c;
  backdrop-filter: blur(3px)
}

.dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 12px
}

.dialog-head h2 {
  font-family: var(--serif);
  font-size: 22px;
  margin: 0;
  font-weight: 500
}

.close {
  border: 0;
  background: transparent;
  min-width: 44px;
  font-size: 24px;
  margin: -12px -12px 0 0
}

.dialog-sub {
  font-size: 12px;
  line-height: 1.8;
  color: var(--muted);
  margin: 0 0 19px
}

.number-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
  margin: 20px 0
}

.number-grid button {
  min-height: 55px;
  font-size: 18px
}

.number-grid button.selected {
  background: var(--green);
  color: white;
  border-color: var(--green)
}

.number-grid button.lower {
  color: var(--muted)
}

.row {
  display: flex;
  gap: 9px;
  margin-top: 12px;
  align-items: center
}

.row>* {
  flex: 1
}

.row button,
.wide {
  padding: 0 14px
}

.wide {
  width: 100%;
  margin-top: 10px
}

.primary {
  background: var(--green);
  color: white;
  border-color: var(--green)
}

.danger {
  color: #9d4d38
}

.helper {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.9;
  margin-top: 14px
}

textarea {
  display: block;
  width: 100%;
  height: 145px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  background: #fff;
  font-size: 14px;
  color: var(--ink)
}

.settings-section {
  padding: 18px 0;
  border-top: 1px solid var(--line)
}

.settings-section h3 {
  font-size: 13px;
  margin: 0 0 8px
}

.settings-section p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.9;
  margin: 7px 0
}

.settings-section button {
  font-size: 12px
}

.error {
  color: #a34d35;
  line-height: 1.8;
  font-size: 12px;
  white-space: pre-line
}

.import-preview {
  font-size: 12px;
  line-height: 1.8;
  background: #edf1e7;
  padding: 12px;
  border-radius: 10px;
  margin-top: 12px
}

#toast {
  position: fixed;
  bottom: max(20px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  max-width: calc(100% - 24px);
  width: max-content;
  background: var(--ink);
  color: white;
  padding: 13px 18px;
  border-radius: 12px;
  font-size: 12px;
  box-shadow: 0 5px 20px #0002;
  display: none
}

#toast button {
  margin-left: 15px;
  min-height: 30px;
  border: 0;
  background: transparent;
  color: #d4e8ba;
  padding: 0 3px
}

#storage-warning {
  display: none;
  padding: 12px;
  background: #fff0df;
  border-radius: 10px;
  line-height: 1.8;
  margin-top: 16px;
  color: #9b5634;
  font-size: 12px
}

svg {
  vertical-align: middle
}

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

@media(min-width:800px) {
  .grid {
    gap: 12px 18px
  }

  .item {
    padding: 18px 20px
  }
}

@media(max-width:600px) {
  .wrap {
    padding: 0 18px
  }

  .topbar {
    padding: 17px 0
  }

  .brand strong {
    font-size: 16px
  }

  .hero {
    padding: 27px 0 22px;
    gap: 10px
  }

  .hero h1 {
    font-size: 30px;
    letter-spacing: 2px
  }

  .hero p {
    font-size: 12px
  }

  .stamp {
    width: 69px;
    height: 69px
  }

  .stamp span {
    font-size: 20px
  }

  .stamp small {
    font-size: 7px
  }

  .overview {
    grid-template-columns: repeat(3, 1fr);
    margin-bottom: 22px
  }

  .stat {
    padding: 15px 12px
  }

  .stat:first-child {
    grid-column: 1/-1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: center;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    column-gap: 10px
  }

  .stat:first-child .stat-number {
    grid-row: 1/3;
    grid-column: 2;
    text-align: right;
    font-size: 33px;
    margin: 0
  }

  .stat:first-child .bar {
    margin: 9px 0 0
  }

  .stat:first-child .stat-sub {
    display: none
  }

  .stat-number {
    font-size: 25px;
    margin: 9px 0
  }

  .stat-title {
    font-size: 10px
  }

  .stat-sub {
    font-size: 9px
  }

  .tools {
    flex-wrap: wrap;
    gap: 13px
  }

  .tabs {
    flex: 1
  }

  .tabs button {
    width: 50%;
    min-width: 0;
    padding: 0 14px
  }

  .search {
    max-width: none;
    flex: 1;
    min-width: 155px
  }

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

  .item {
    padding: 14px 15px
  }

  .item-head {
    margin-bottom: 11px
  }

  .cell {
    min-height: 56px
  }

  .legend {
    font-size: 10px
  }

  .footer {
    flex-direction: column;
    gap: 7px
  }

  .list-heading {
    margin-top: 20px
  }

  dialog {
    padding: 23px;
    max-height: 88dvh
  }

  .filters {
    gap: 6px
  }

  .chip {
    padding: 0 11px;
    font-size: 11px
  }
}

@media(prefers-reduced-motion:reduce) {
  * {
    transition: none !important
  }
}
