:root {
  --paper: #f4f1ea;
  --card: #fbf9f4;
  --sumi: #1f2421;
  --soft: #454b46;
  --muted: #74776e;
  --line: #dad5c8;
  --pine: #2f4b3a;
  --pine-h: #1d3326;
  --uguisu: #8c8f4e;
  --kaki: #d9783b;
  --tint: #dfe6da;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--paper);
  color: var(--sumi);
  font-family: 'Geist', system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}

#stage,
#stage canvas {
  position: fixed;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  border: 0;
  background: none;
  padding: 0;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 2px solid var(--pine);
  outline-offset: 3px;
  border-radius: 6px;
}

[hidden] {
  display: none !important;
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

.klee {
  font-family: 'Klee One', cursive;
  color: var(--pine);
}

.top {
  position: fixed;
  top: max(20px, env(safe-area-inset-top));
  left: 0;
  right: 0;
  padding: 0 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
}

.top > * {
  pointer-events: auto;
}

.logo {
  color: var(--sumi);
  text-decoration: none;
  font-weight: 500;
  font-size: 17px;
}

.logo span {
  color: var(--muted);
  font-weight: 400;
}

.nav {
  display: flex;
  gap: 22px;
  font-size: 15px;
}

.nav button {
  padding: 8px 0;
  color: var(--muted);
  transition: color 0.15s;
}

.nav button:hover {
  color: var(--sumi);
}

.nav button.on {
  color: var(--sumi);
  box-shadow: inset 0 -1.5px var(--pine);
}

.slip {
  position: fixed;
  top: max(72px, calc(env(safe-area-inset-top) + 56px));
  left: 50%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px 10px 10px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 3px;
  box-shadow: 0 2px 0 var(--line);
  transform: translateX(-50%) rotate(-1.5deg);
  white-space: nowrap;
}

.slip::before {
  content: '';
  position: absolute;
  left: 50%;
  top: -9px;
  width: 64px;
  height: 18px;
  margin-left: -32px;
  background: rgba(140, 143, 78, 0.35);
  transform: rotate(3deg);
}

.slip > div {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.slip .klee {
  font-size: 14px;
}

.slip b {
  font-family: 'Zen Maru Gothic', system-ui, sans-serif;
  font-weight: 500;
  font-size: 19px;
}

.slip .count {
  align-self: flex-start;
  margin-left: 6px;
  font-size: 13px;
  color: var(--muted);
}

.swatch {
  display: inline-block;
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1.5px solid var(--sumi);
}

.swatch.big {
  width: 76px;
  height: 76px;
}

.dock {
  position: fixed;
  left: 50%;
  bottom: max(20px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px;
  background: var(--card);
  border: 1.5px solid var(--sumi);
  border-radius: 999px;
  box-shadow: 0 4px 0 var(--sumi);
}

.group {
  display: flex;
  align-items: center;
  gap: 4px;
}

.group + .group {
  padding-left: 8px;
  margin-left: 4px;
  border-left: 1px solid var(--line);
}

.well {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
}

.well i {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(31, 36, 33, 0.18);
  transition: transform 0.15s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.well:hover i {
  transform: scale(1.08);
}

.well.on i {
  transform: scale(1.12);
  box-shadow: 0 0 0 3px var(--card), 0 0 0 4.5px var(--sumi);
}

.tools button {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--soft);
  transition: background 0.15s, color 0.15s;
}

.tools button:hover {
  color: var(--sumi);
}

.tools button.on {
  background: var(--tint);
  color: var(--pine);
}

.tools svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.size {
  display: flex;
  align-items: center;
  padding: 0 8px;
}

input[type='range'] {
  -webkit-appearance: none;
  appearance: none;
  width: 92px;
  height: 28px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}

input[type='range']::-webkit-slider-runnable-track {
  height: 1.5px;
  background: var(--sumi);
}

input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  margin-top: -7.25px;
  border-radius: 50%;
  background: var(--card);
  border: 1.5px solid var(--sumi);
}

input[type='range']::-moz-range-track {
  height: 1.5px;
  background: var(--sumi);
}

input[type='range']::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--card);
  border: 1.5px solid var(--sumi);
}

.btn {
  height: 48px;
  padding: 0 26px;
  border-radius: 14px 18px 12px 20px / 16px 12px 18px 14px;
  background: var(--pine);
  color: var(--paper);
  font-weight: 600;
  white-space: nowrap;
  transition: transform 0.1s, background 0.15s;
}

.btn:hover {
  background: var(--pine-h);
}

.btn:active,
.ghost:active {
  transform: translateY(1px);
}

.ghost {
  height: 44px;
  padding: 0 18px;
  border: 1.5px solid var(--sumi);
  border-radius: 999px;
  color: var(--sumi);
  font-weight: 500;
  white-space: nowrap;
}

.btn.sm,
.ghost.sm {
  height: 40px;
  padding: 0 16px;
  font-size: 15px;
}

.dock .btn.sm {
  border-radius: 18px 22px 16px 24px / 20px 16px 22px 18px;
}

#frame {
  position: fixed;
  border-radius: 50%;
  border: 1.5px dashed rgba(116, 119, 110, 0.45);
  pointer-events: none;
  display: grid;
  place-items: center;
}

#frame span {
  font-family: 'Klee One', cursive;
  font-size: 17px;
  line-height: 1.4;
  text-align: center;
  color: var(--pine);
  opacity: 0.75;
  transform: rotate(-3deg);
  transition: opacity 0.4s;
}

#frame.painted span {
  opacity: 0;
}

.card {
  width: min(400px, calc(100vw - 32px));
  padding: 22px;
  border: 1.5px solid var(--sumi);
  border-radius: 18px;
  background: var(--card);
  color: var(--sumi);
  box-shadow: 0 5px 0 var(--sumi);
  text-align: center;
}

.card[open] {
  animation: pop 0.28s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.card::backdrop {
  background: rgba(31, 36, 33, 0.35);
}

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

.ch {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.card h2 {
  margin: 4px 0 18px;
  font-family: 'Zen Maru Gothic', system-ui, sans-serif;
  font-size: 26px;
  font-weight: 500;
}

.compare {
  display: flex;
  justify-content: center;
  gap: 32px;
}

.compare figure {
  margin: 0;
  display: grid;
  justify-items: center;
  gap: 6px;
}

.compare figcaption {
  font-family: 'Klee One', cursive;
  font-size: 15px;
  color: var(--soft);
}

.score {
  margin: 18px 0 2px;
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: 12px;
}

.score strong {
  font-family: 'Zen Maru Gothic', system-ui, sans-serif;
  font-size: 40px;
  font-weight: 700;
  line-height: 1;
}

.stars {
  font-size: 20px;
  letter-spacing: 3px;
  color: var(--kaki);
}

.stars .off {
  color: var(--line);
}

.card p {
  margin: 8px 0 20px;
  font-size: 15px;
  color: var(--soft);
}

.card p.score {
  margin: 18px 0 2px;
}

#about {
  text-align: left;
}

#about p {
  margin: 0 0 14px;
}

.keys {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
}

kbd {
  display: inline-block;
  min-width: 22px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 1px 0 var(--line);
  font: 500 13px/22px 'Geist', system-ui, sans-serif;
  text-align: center;
  color: var(--sumi);
}

#about p.credit {
  font-size: 14px;
}

.credit a {
  color: var(--pine);
  text-decoration: underline wavy;
  text-decoration-color: var(--uguisu);
  text-decoration-thickness: 1.25px;
  text-underline-offset: 5px;
}

.credit a:hover {
  color: var(--pine-h);
}

.acts {
  display: flex;
  gap: 10px;
  justify-content: center;
}

#about .acts {
  justify-content: flex-end;
  margin-top: 20px;
}

.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  max-width: calc(100% - 32px);
  padding: 16px 20px;
  border: 1.5px solid var(--sumi);
  border-radius: 14px;
  background: var(--card);
}

@media (max-width: 640px) {
  .top {
    padding: 0 16px;
    top: max(12px, env(safe-area-inset-top));
  }

  .logo span {
    display: none;
  }

  .nav {
    gap: 14px;
    font-size: 14px;
  }

  .slip {
    top: max(72px, calc(env(safe-area-inset-top) + 60px));
  }

  .dock {
    width: calc(100% - 24px);
    flex-wrap: wrap;
    justify-content: space-between;
    border-radius: 24px;
    bottom: max(16px, env(safe-area-inset-bottom));
  }

  .group.actions {
    width: 100%;
    padding: 6px 0 0;
    margin: 4px 0 0;
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .size {
    flex: 1;
  }

  input[type='range'] {
    width: 100%;
  }

  .acts button {
    flex: 1;
    padding: 0 10px;
  }
}

@media (max-width: 360px) {
  .well {
    width: 34px;
  }

  .tools button {
    width: 36px;
  }
}

@media (pointer: coarse) {
  .keys {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .card[open] {
    animation: none;
  }
}
