:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --surface-2: #f5f5f5;
  --text: #111111;
  --text-soft: #2a2a2a;
  --muted: #525252;
  --subtle: #737373;
  --hairline: #e5e5e5;
  --hairline-2: #d4d4d4;
  --warn: #b45309;
  --warn-bg: #fff7ed;
  --warn-border: #fed7aa;
  --info: #1d4ed8;
  --info-bg: #eff6ff;
  --kind-fish: #2563eb;
  --kind-bug: #16a34a;
  --kind-sea: #0891b2;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans",
               "Noto Sans JP", "Yu Gothic", "BIZ UDPGothic", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  letter-spacing: 0;
}

body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

button, select, input { font: inherit; color: inherit; }

.tnum {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

/* ============ Hero ============ */
.hero {
  padding: 56px 20px 32px;
  border-bottom: 1px solid var(--hairline);
}
.hero-inner {
  max-width: 1080px;
  margin: 0 auto;
}
.now-label {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}
.hero-title {
  margin: 0;
  font-size: clamp(34px, 8vw, 52px);
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: 0;
  color: var(--text);
}

/* ============ Sticky bar ============ */
.bar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(250,250,250,.85);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--hairline);
}
.bar-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.tabs {
  display: flex;
  gap: 4px;
}
.tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: color .15s ease, background .15s ease;
}
.tab:hover { color: var(--text); background: var(--hairline); }
.tab.active {
  color: var(--text);
  background: var(--surface);
  font-weight: 600;
  box-shadow: inset 0 0 0 1px var(--hairline);
}

.bar-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}
.check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 14px;
  cursor: pointer;
  user-select: none;
  color: var(--text-soft);
}
.check input { accent-color: var(--text); width: 15px; height: 15px; }
#sort {
  appearance: none;
  -webkit-appearance: none;
  padding: 7px 30px 7px 12px;
  border: 1px solid var(--hairline-2);
  border-radius: 999px;
  background: var(--surface);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path fill='%23525252' d='M5 6L0 0h10z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 11px center;
}
#sort:focus-visible { outline: 2px solid var(--text); outline-offset: 1px; }

/* ============ Container ============ */
.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 24px 20px 56px;
  width: 100%;
  flex: 1;
}

.status {
  margin: 0 0 16px;
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ============ Grid ============ */
.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
@media (min-width: 720px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
}

/* ============ Card ============ */
.card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-left: 4px solid var(--hairline);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color .15s ease, transform .12s ease;
}
.card:hover { border-color: var(--hairline-2); }
.card.unavailable { opacity: .42; }
.card[data-kind="fish"] { border-left-color: var(--kind-fish); }
.card[data-kind="bug"]  { border-left-color: var(--kind-bug); }
.card[data-kind="sea"]  { border-left-color: var(--kind-sea); }

.card.owned { opacity: .55; background: var(--surface-2); }
.card.owned .card-name { text-decoration: line-through; text-decoration-color: var(--subtle); }

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.owned-toggle {
  appearance: none;
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border: 1.5px solid var(--hairline-2);
  border-radius: 6px;
  background: var(--surface);
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  transition: background .12s ease, border-color .12s ease;
  margin: 0;
  align-self: flex-start;
  margin-top: 2px;
}
.owned-toggle:hover { border-color: var(--muted); }
.owned-toggle:checked {
  background: var(--text);
  border-color: var(--text);
}
.owned-toggle:checked::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 2px;
  width: 6px;
  height: 11px;
  border: solid var(--surface);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.owned-toggle:focus-visible { outline: 2px solid var(--info); outline-offset: 2px; }
.card-title-block {
  min-width: 0;
  flex: 1;
}
.card-name {
  display: block;
  font-size: 18px;
  font-weight: 650;
  line-height: 1.35;
  letter-spacing: 0;
  color: var(--text);
  word-break: keep-all;
}
.card-sub {
  display: block;
  margin-top: 3px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
}
.card-sub .dot-sep { margin: 0 6px; color: var(--hairline-2); }

.remaining {
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--info);
  background: var(--info-bg);
  border: 1px solid #c7dbff;
  border-radius: 999px;
  padding: 3px 10px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.remaining.urgent {
  color: var(--warn);
  background: var(--warn-bg);
  border-color: var(--warn-border);
}

.card-bottom {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  margin-top: 4px;
  padding-top: 10px;
  border-top: 1px solid var(--hairline);
  font-size: 13px;
  color: var(--muted);
}
.price {
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}
.price-suffix { font-weight: 500; color: var(--muted); margin-left: 1px; }
.time-text {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}
.month-tag {
  font-size: 12px;
  font-weight: 600;
  color: var(--warn);
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  border-radius: 999px;
  padding: 2px 9px;
  margin-left: auto;
}

/* shadow size dot */
.shadow-mark {
  display: inline-block;
  background: currentColor;
  opacity: .55;
  border-radius: 50%;
  vertical-align: middle;
  margin-right: 4px;
}
.shadow-mark.size-1 { width: 5px;  height: 5px; }
.shadow-mark.size-2 { width: 7px;  height: 7px; }
.shadow-mark.size-3 { width: 9px;  height: 9px; }
.shadow-mark.size-4 { width: 11px; height: 11px; }
.shadow-mark.size-5 { width: 13px; height: 13px; }
.shadow-mark.size-6 { width: 15px; height: 15px; }
.shadow-mark.fin    { width: 14px; height: 5px; border-radius: 50%; transform: skewX(-18deg); }
.shadow-mark.thin   { width: 16px; height: 3px; border-radius: 4px; }

/* states */
.empty, .error {
  text-align: center;
  padding: 56px 20px;
  color: var(--muted);
  font-size: 15px;
  background: var(--surface);
  border: 1px dashed var(--hairline-2);
  border-radius: 10px;
  grid-column: 1 / -1;
}
.error { color: var(--warn); }

footer {
  text-align: center;
  padding: 24px 16px 32px;
  font-size: 12px;
  color: var(--subtle);
  border-top: 1px solid var(--hairline);
  margin-top: 32px;
  font-variant-numeric: tabular-nums;
}

/* toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1a1a1a;
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 100;
  box-shadow: 0 6px 20px rgba(0,0,0,.2);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* tablet */
@media (max-width: 768px) {
  .hero { padding: 36px 18px 22px; }
  .hero-title { font-size: clamp(28px, 8vw, 38px); line-height: 1.18; }
  .now-label { margin-bottom: 8px; font-size: 12px; }
  .bar-inner { padding: 10px 16px; flex-wrap: wrap; gap: 8px; }
  .tabs { width: 100%; gap: 2px; }
  .tab { flex: 1; padding: 10px 6px; min-height: 40px; font-size: 14px; }
  .bar-controls { width: 100%; justify-content: space-between; gap: 8px; }
  .check { font-size: 13px; }
  .check input { width: 18px; height: 18px; }
  #sort { padding: 8px 28px 8px 12px; min-height: 36px; font-size: 13px; }
  .container { padding: 16px 14px calc(40px + env(safe-area-inset-bottom)); }
  .grid { gap: 10px; }
  .card { padding: 14px 14px 12px; gap: 8px; }
  .card-name { font-size: 16px; line-height: 1.32; }
  .card-sub { font-size: 12.5px; line-height: 1.45; }
  .card-bottom { font-size: 13px; gap: 4px 10px; padding-top: 9px; margin-top: 2px; }
  .price { font-size: 14px; }
  .remaining { font-size: 12px; padding: 3px 9px; }
  .month-tag { font-size: 11px; padding: 2px 8px; }
  .owned-toggle { width: 26px; height: 26px; border-radius: 7px; margin-top: 0; }
  .owned-toggle:checked::after { left: 7px; top: 3px; width: 7px; height: 13px; border-width: 0 2.5px 2.5px 0; }
  .toast { bottom: calc(20px + env(safe-area-inset-bottom)); font-size: 12.5px; padding: 9px 16px; }
}

/* small phones */
@media (max-width: 380px) {
  .hero-title { font-size: 24px; }
  .card { padding: 12px; }
  .card-name { font-size: 15.5px; }
  .card-bottom { gap: 4px 8px; }
  .remaining { font-size: 11px; padding: 2px 7px; }
}

/* iOS safe areas (notch) for sticky bar and footer */
@supports (padding: env(safe-area-inset-top)) {
  .bar { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
  footer { padding-bottom: calc(32px + env(safe-area-inset-bottom)); }
}

/* dark */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0a0a;
    --surface: #141414;
    --surface-2: #1a1a1a;
    --text: #f5f5f5;
    --text-soft: #e0e0e0;
    --muted: #c7c7c7;
    --subtle: #a3a3a3;
    --hairline: #2a2a2a;
    --hairline-2: #3d3d3d;
    --warn: #fbbf24;
    --warn-bg: rgba(251,191,36,.12);
    --warn-border: rgba(251,191,36,.3);
    --info: #93c5fd;
    --info-bg: rgba(147,197,253,.12);
    --kind-fish: #60a5fa;
    --kind-bug: #4ade80;
    --kind-sea: #22d3ee;
  }
  .bar { background: rgba(10,10,10,.85); }
  .remaining { border-color: rgba(147,197,253,.25); }
  .month-tag { border-color: rgba(251,191,36,.3); }
}
