:root {
  --bg: #101512;
  --surface: #18201c;
  --surface-2: #202a24;
  --ink: #eef6f1;
  --muted: #9fb0a8;
  --line: #2b3831;
  --green: #4fd0a8;
  --coral: #ff8a72;
  --gold: #e1ba4a;
  --shadow: 0 14px 34px rgba(0, 0, 0, 0.32);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.35;
}

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

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: rgba(16, 21, 18, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.brand {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.brand::after {
  content: "";
  width: 24px;
  height: 24px;
  display: inline-block;
  background: url("./assets/kashiwamochi.png") center / contain no-repeat;
  transform: translateY(1px);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-analysis-button {
  min-height: 34px;
  display: grid;
  place-items: center;
  padding: 0 10px;
  border: 1px solid rgba(79, 208, 168, 0.58);
  border-radius: 8px;
  background: rgba(79, 208, 168, 0.12);
  color: var(--green);
  font-size: 12px;
  font-weight: 900;
}

.menu-button,
.drawer-close {
  width: 42px;
  height: 42px;
  border: 0;
  background: transparent;
  color: var(--ink);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.menu-button {
  gap: 5px;
  align-content: center;
}

.menu-button span {
  display: block;
  width: 24px;
  height: 2px;
  background: var(--ink);
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(0, 0, 0, 0.52);
}

.drawer {
  position: fixed;
  inset: 0 0 0 auto;
  z-index: 40;
  width: min(78vw, 320px);
  background: #151c18;
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow);
  transform: translateX(100%);
  transition: transform 180ms ease;
  padding: 12px;
}

.drawer.open {
  transform: translateX(0);
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 48px;
  font-weight: 800;
}

.drawer-close {
  font-size: 28px;
}

.drawer a {
  display: flex;
  align-items: center;
  min-height: 46px;
  padding: 0 8px;
  border-bottom: 1px solid var(--line);
  font-weight: 700;
}

.page-shell {
  width: min(100%, 760px);
  margin: 0 auto;
  padding: 12px 12px 24px;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 8px;
}

.section-title h1,
.section-title h2 {
  margin: 0;
  font-size: 17px;
  line-height: 1.15;
  letter-spacing: 0;
}

.section-title.tight h2 {
  font-size: 15px;
}

.section-title a {
  flex: 0 0 auto;
  font-size: 12px;
  color: var(--green);
  font-weight: 800;
}

.hero-strip,
.compact-section {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.rare-scroll,
.tweet-scroll {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 58px;
  gap: 7px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  padding: 1px 1px 4px;
}

.rare-scroll::-webkit-scrollbar,
.tweet-scroll::-webkit-scrollbar {
  display: none;
}

.rare-card {
  display: block;
  min-width: 0;
}

.rare-thumb {
  aspect-ratio: 1 / 1;
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 7px;
  overflow: hidden;
}

.rare-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.rare-name {
  margin: 4px 1px 0;
  font-size: 10px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.official-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: start;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.official-card strong {
  font-size: 13px;
}

.official-card p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.official-card time {
  color: var(--gold);
  font-size: 11px;
  font-weight: 800;
}

.tweet-scroll {
  grid-auto-columns: 172px;
}

.tweet-card {
  min-height: 96px;
  padding: 9px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.tweet-card b {
  font-size: 12px;
}

.tweet-card p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tweet-card span {
  margin-top: auto;
  color: var(--coral);
  font-size: 11px;
  font-weight: 800;
}

.updates-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  border-bottom: 0;
}

.mini-list {
  display: grid;
  gap: 8px;
}

.mini-item {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 8px;
  align-items: center;
  min-width: 0;
  padding: 7px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.mini-item img {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 7px;
  border: 1px solid var(--line);
}

.mini-item b,
.mini-item span {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-item b {
  font-size: 12px;
}

.mini-item span {
  color: var(--muted);
  font-size: 11px;
}

.page-title-block h1 {
  margin: 0 0 4px;
  font-size: 20px;
}

.title-with-help {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  column-gap: 10px;
}

.title-with-help h1 {
  margin: 0;
}

.title-actions {
  display: contents;
}

.ct-button,
.help-button {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border: 1px solid rgba(79, 208, 168, 0.55);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--green);
  font-size: 18px;
  font-weight: 900;
  display: grid;
  place-items: center;
}

.ct-button {
  width: 44px;
  border-radius: 8px;
  font-size: 13px;
  letter-spacing: 0;
  justify-self: end;
  margin-right: 12px;
}

.help-button {
  justify-self: end;
}

.page-title-block p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 12px 0 24px;
}

.search-panel {
  display: grid;
  grid-template-columns: 1fr 58px 62px 68px;
  gap: 8px;
  padding: 12px 0 6px;
}

.search-panel.star-search {
  grid-template-columns: 1fr 62px 68px;
}

.search-input,
.search-select,
.search-button {
  min-width: 0;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-size: 16px;
}

.search-input {
  padding: 0 10px;
}

.search-select {
  padding: 0 8px;
}

.search-button {
  background: var(--green);
  color: #06100c;
  font-size: 14px;
  font-weight: 900;
}

.search-button.reset {
  background: #df4c4c;
  color: #fff;
}

.monster-list {
  display: grid;
  gap: 9px;
  padding: 8px 0 24px;
}

.data-card {
  display: grid;
  grid-template-columns: 74px 1fr;
  gap: 10px;
  min-width: 0;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.data-card img {
  width: 74px;
  height: 74px;
  border-radius: 8px;
  border: 1px solid var(--line);
  object-fit: cover;
  background: var(--surface-2);
}

.data-card div {
  min-width: 0;
}

.data-card b,
.data-card span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.data-card b {
  font-size: 13px;
}

.data-card span {
  margin-top: 2px;
  color: var(--gold);
  font-size: 11px;
  font-weight: 800;
}

.data-card p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.32;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.data-card .muted-line {
  color: #7fbba8;
}

.listing-card {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.listing-card img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  object-position: center center;
  background: var(--surface-2);
}

.listing-card div {
  padding: 8px;
}

.listing-card b,
.listing-card span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.listing-card b {
  font-size: 12px;
}

.listing-card span {
  margin-top: 2px;
  color: var(--gold);
  font-size: 11px;
  font-weight: 800;
}

.tool-panel {
  display: grid;
  gap: 12px;
  padding: 14px 0 24px;
}

.upload-box {
  position: relative;
  min-height: 220px;
  display: grid;
  place-items: center;
  background: var(--surface);
  border: 1px dashed #4d6258;
  border-radius: 8px;
  color: var(--green);
  font-weight: 800;
  overflow: hidden;
  padding: 12px;
}

.upload-box input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.upload-box img {
  width: 100%;
  max-height: 196px;
  object-fit: contain;
  display: block;
  background: #0b0f0d;
  border-radius: 6px;
}

.upload-box.locked {
  cursor: default;
}

.upload-box.locked input {
  pointer-events: none;
}

.analysis-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(16, 21, 18, 0.56);
}

.spinner {
  width: 72px;
  height: 72px;
  border-radius: 999px;
  border: 7px solid rgba(255, 255, 255, 0.28);
  border-top-color: var(--green);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.primary-button {
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  background: var(--green);
  color: #06100c;
  font-size: 16px;
  font-weight: 900;
  display: grid;
  place-items: center;
  position: relative;
}

.primary-button:disabled {
  opacity: 0.55;
}

.button-spinner {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  border: 3px solid rgba(6, 16, 12, 0.24);
  border-top-color: #06100c;
  animation: spin 0.8s linear infinite;
  display: none;
}

.primary-button.loading .button-label {
  display: none;
}

.primary-button.loading .button-spinner {
  display: block;
}

.status-text {
  min-height: 18px;
  color: var(--muted);
  font-size: 12px;
}

.analysis-result {
  display: grid;
  gap: 10px;
}

.analysis-result img {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.detected-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.detected-list span {
  padding: 5px 7px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 11px;
}

.formation-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.formation-card {
  position: relative;
  min-width: 0;
  min-height: 88px;
  padding: 11px 38px 11px 13px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  display: grid;
  gap: 7px;
  text-align: left;
  box-shadow:
    0 7px 0 rgba(0, 0, 0, 0.34),
    0 12px 22px rgba(0, 0, 0, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.2),
    inset 0 -1px 0 rgba(0, 0, 0, 0.3);
  transform: translateY(-2px);
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.formation-card::after {
  content: "›";
  position: absolute;
  top: 50%;
  right: 13px;
  transform: translateY(-52%);
  color: rgba(238, 246, 241, 0.72);
  font-size: 30px;
  font-weight: 800;
}

.formation-card::before {
  content: "";
  position: absolute;
  top: 10px;
  right: 34px;
  bottom: 10px;
  width: 1px;
  background: rgba(238, 246, 241, 0.22);
  box-shadow: 1px 0 0 rgba(0, 0, 0, 0.22);
}

.formation-card:active {
  transform: translateY(2px);
  box-shadow:
    0 2px 0 rgba(0, 0, 0, 0.22),
    0 5px 12px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.formation-1 {
  background: linear-gradient(180deg, rgba(255, 142, 142, 0.24), rgba(255, 118, 118, 0.13));
  border-color: rgba(255, 150, 150, 0.48);
}

.formation-2 {
  background: linear-gradient(180deg, rgba(130, 176, 255, 0.24), rgba(110, 158, 255, 0.13));
  border-color: rgba(142, 184, 255, 0.48);
}

.formation-3 {
  background: linear-gradient(180deg, rgba(100, 224, 174, 0.23), rgba(88, 216, 164, 0.12));
  border-color: rgba(109, 228, 181, 0.48);
}

.formation-card b {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.formation-card b {
  font-size: 14px;
}

.formation-card ul {
  margin: 0;
  padding-left: 17px;
  color: var(--muted);
  font-size: 12px;
}

.formation-card li {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.formation-card li + li {
  margin-top: 3px;
}

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 45;
  background: rgba(0, 0, 0, 0.48);
}

.bottom-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  max-height: 70vh;
  padding: 10px 14px 18px;
  border-radius: 14px 14px 0 0;
  border: 1px solid var(--line);
  border-bottom: 0;
  background: #151c18;
  box-shadow: var(--shadow);
  transform: translateY(105%);
  transition: transform 180ms ease;
  overflow: auto;
}

.bottom-sheet.open {
  transform: translateY(0);
}

.sheet-close {
  position: fixed;
  right: 14px;
  bottom: calc(70vh + 10px);
  width: 46px;
  height: 46px;
  border: 0;
  border-radius: 999px;
  background: rgba(21, 28, 24, 0.96);
  color: var(--ink);
  font-size: 28px;
  line-height: 1;
  display: grid;
  place-items: center;
  z-index: 60;
  box-shadow: var(--shadow);
}

.sheet-handle {
  width: 76px;
  height: 24px;
  margin: 0 auto 8px;
  border-radius: 999px;
  position: relative;
}

.sheet-handle::before {
  content: "";
  position: absolute;
  left: 15px;
  right: 15px;
  top: 9px;
  height: 5px;
  border-radius: 999px;
  background: #627269;
}

.bottom-sheet h2,
.sheet-block h3 {
  margin: 0;
}

.bottom-sheet h2 {
  font-size: 18px;
  margin-bottom: 12px;
}

.official-card-detail {
  display: grid;
  grid-template-columns: 86px 1fr;
  gap: 10px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.official-image-link {
  grid-column: 1;
  grid-row: 1;
  min-width: 0;
  min-height: 86px;
  display: grid;
  place-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.official-image-link img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.official-image-link span {
  color: var(--gold);
  font-weight: 800;
  font-size: 12px;
}

.official-card-detail h3 {
  color: var(--green);
  font-size: 13px;
  margin: 0 0 6px;
}

.official-skill-box {
  min-width: 0;
}

.official-active-box {
  grid-column: 2;
  grid-row: 1;
}

.official-passive-box {
  grid-column: 1 / -1;
  grid-row: 2;
}

.official-skill {
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.025);
}

.official-skill + .official-skill {
  margin-top: 6px;
}

.official-skill b {
  display: block;
  font-size: 12px;
}

.official-skill p,
.official-card-detail p {
  color: var(--muted);
  font-size: 12px;
  margin: 4px 0 0;
}

.help-modal {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.58);
}

.help-modal-card {
  width: min(92vw, 312px);
  max-height: 94vh;
  overflow: auto;
  position: relative;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #151c18;
  box-shadow: var(--shadow);
}

.help-modal-card h2 {
  margin: 0 44px 10px 0;
  font-size: 17px;
}

.help-modal-card img {
  width: 100%;
  display: block;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #e9f8f8;
}

.help-modal-card .arena-sample-image {
  width: 50%;
  margin: 0 auto;
}

.help-modal-card.ct-modal-card {
  width: min(94vw, 520px);
}

.help-modal-card .ct-table-image {
  width: 100%;
}

.help-modal-card p {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: clamp(14px, 3.6vw, 21px);
  line-height: 1.18;
  font-weight: 800;
}

.help-modal-card .help-warning,
.upload-error {
  color: #ff9d9d;
}

.upload-error {
  text-align: center;
  line-height: 1.45;
  font-size: 15px;
  padding: 0 8px;
}

.help-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font-size: 26px;
}

.address-input {
  width: 100%;
  min-height: 48px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-size: 16px;
}

.success-check {
  width: 96px;
  height: 96px;
  margin: 10px auto 0;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--green);
  color: #06100c;
  font-size: 62px;
  font-weight: 900;
}

.speed-panel {
  padding: 14px 0 24px;
}

.speed-table {
  display: grid;
  grid-template-columns: 30px repeat(5, minmax(0, 1fr)) 50px;
  gap: 4px;
}

.speed-cell {
  min-width: 0;
}

.speed-head {
  min-height: 28px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
}

.speed-index,
.speed-cell output {
  min-height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  font-size: 12px;
  font-weight: 900;
}

.speed-cell output {
  background: rgba(225, 186, 74, 0.12);
  color: var(--gold);
  user-select: none;
  pointer-events: none;
}

.speed-cell select {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
  padding: 0 2px;
  text-align: center;
  text-align-last: center;
}

.link-list {
  display: grid;
  gap: 10px;
  padding: 14px 0 24px;
}

.link-list a {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  font-size: 15px;
  font-weight: 900;
}

.link-list a::after {
  content: "›";
  color: var(--green);
  font-size: 26px;
  line-height: 1;
}

@media (min-width: 680px) {
  .page-shell {
    padding-top: 18px;
  }

  .rare-scroll {
    grid-auto-columns: 72px;
  }

  .tweet-scroll {
    grid-auto-columns: 210px;
  }

  .card-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}
