:root {
  --ink: #20342a;
  --muted: #68776f;
  --green: #2f7a54;
  --green-dark: #225c40;
  --mint: #dff5e6;
  --mint-soft: #f3fbf5;
  --lavender: #eee6fb;
  --peach: #ffe9dc;
  --lemon: #fff3bd;
  --white: #ffffff;
  --line: rgba(32, 52, 42, .11);
  --shadow: 0 16px 45px rgba(36, 78, 55, .10);
  --radius-lg: 28px;
  --radius-md: 20px;
  --page: min(1240px, calc(100vw - 40px));
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  background: var(--mint-soft);
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 3%, rgba(238, 230, 251, .8), transparent 22rem),
    radial-gradient(circle at 92% 15%, rgba(255, 233, 220, .75), transparent 25rem),
    var(--mint-soft);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 1rem;
  line-height: 1.5;
}

button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
img { display: block; max-width: 100%; }

.skip-link {
  position: fixed;
  z-index: 100;
  top: 10px;
  left: 10px;
  transform: translateY(-160%);
  padding: 10px 15px;
  color: var(--white);
  background: var(--green-dark);
  border-radius: 10px;
}
.skip-link:focus { transform: none; }

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

.site-header {
  width: var(--page);
  min-height: 80px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  text-decoration: none;
  font-family: ui-rounded, "Arial Rounded MT Bold", "Trebuchet MS", sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
}

.brand-mark {
  width: 39px;
  height: 39px;
  display: grid;
  place-items: center;
  color: var(--white);
  background: var(--green);
  border: 3px solid rgba(255,255,255,.8);
  border-radius: 14px 18px 13px 18px;
  box-shadow: 0 6px 16px rgba(47, 122, 84, .18);
}

.primary-nav {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px;
  background: rgba(255,255,255,.62);
  border: 1px solid rgba(255,255,255,.82);
  border-radius: 15px;
  box-shadow: 0 7px 25px rgba(57, 83, 68, .06);
  backdrop-filter: blur(12px);
}

.primary-nav a {
  padding: 8px 14px;
  color: var(--muted);
  border-radius: 11px;
  font-weight: 600;
  text-decoration: none;
  transition: color .18s ease, background .18s ease, transform .18s ease;
}

.primary-nav a:hover { color: var(--green-dark); }
.primary-nav a[aria-current="page"] {
  color: var(--green-dark);
  background: var(--mint);
}

main {
  width: var(--page);
  margin: 0 auto;
  padding: 45px 0 80px;
}

.view[hidden] { display: none !important; }
.view { animation: view-in .28s ease both; }
@keyframes view-in { from { opacity: 0; transform: translateY(6px); } }

h1, h2, p { margin-top: 0; }
h1, h2 { font-family: ui-rounded, "Arial Rounded MT Bold", "Trebuchet MS", sans-serif; line-height: 1.08; }
h1 { margin-bottom: 0; font-size: clamp(2.1rem, 4.5vw, 4.2rem); letter-spacing: -.045em; }

.eyebrow {
  margin-bottom: 8px;
  color: var(--green);
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .13em;
  text-transform: uppercase;
}

.view-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 30px;
}

.collection-count, .vote-total {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: .95rem;
  font-weight: 600;
}

.gallery-toolbar {
  position: sticky;
  z-index: 5;
  top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
  padding: 10px;
  background: rgba(255,255,255,.83);
  border: 1px solid rgba(255,255,255,.92);
  border-radius: 19px;
  box-shadow: 0 10px 35px rgba(50, 80, 61, .08);
  backdrop-filter: blur(15px);
}

.search-field {
  width: min(450px, 100%);
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 13px;
}

.search-field svg {
  width: 20px;
  flex: 0 0 auto;
  fill: none;
  stroke: var(--green);
  stroke-linecap: round;
  stroke-width: 2;
}

.search-field input {
  width: 100%;
  padding: 10px 0;
  color: var(--ink);
  background: transparent;
  border: 0;
  outline: 0;
  font-size: 1rem;
}
.search-field input::placeholder { color: #8b9991; }

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

.sort-field {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 7px 5px 11px;
  color: var(--muted);
  font-size: .88rem;
  font-weight: 600;
  white-space: nowrap;
}
.sort-field select {
  min-height: 36px;
  padding: 0 29px 0 11px;
  color: var(--ink);
  background: var(--mint-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  font-weight: 700;
}
.sort-field select:focus-visible { outline: 3px solid rgba(47,122,84,.22); outline-offset: 2px; }

.motion-toggle {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  color: var(--muted);
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.motion-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-track {
  width: 39px;
  height: 23px;
  padding: 3px;
  background: #c9d3cd;
  border-radius: 30px;
  transition: background .2s ease;
}
.toggle-track span {
  width: 17px;
  height: 17px;
  display: block;
  background: var(--white);
  border-radius: 50%;
  box-shadow: 0 2px 5px rgba(0,0,0,.15);
  transition: transform .2s ease;
}
.motion-toggle input:checked + .toggle-track { background: var(--green); }
.motion-toggle input:checked + .toggle-track span { transform: translateX(16px); }
.motion-toggle input:focus-visible + .toggle-track { outline: 3px solid rgba(47,122,84,.25); outline-offset: 2px; }

.results-summary {
  min-height: 24px;
  margin: 0 4px 18px;
  color: var(--muted);
  font-size: .88rem;
}

.emote-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
  gap: 15px;
}

.emote-card {
  min-width: 0;
  padding: 10px 10px 12px;
  color: var(--ink);
  background: rgba(255,255,255,.72);
  border: 1px solid rgba(255,255,255,.92);
  border-radius: var(--radius-md);
  box-shadow: 0 5px 18px rgba(43, 75, 55, .045);
  cursor: pointer;
  text-align: left;
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
  content-visibility: auto;
  contain-intrinsic-size: 190px 225px;
}
.emote-card:hover, .emote-card:focus-visible {
  transform: translateY(-4px);
  border-color: rgba(47,122,84,.22);
  box-shadow: 0 16px 30px rgba(43, 75, 55, .11);
  outline: none;
}

.emote-art {
  position: relative;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: linear-gradient(145deg, #f7fcf8, #edf8f0);
  border-radius: 14px;
}
.emote-card:nth-child(3n+2) .emote-art { background: linear-gradient(145deg, #fbf8ff, var(--lavender)); }
.emote-card:nth-child(3n) .emote-art { background: linear-gradient(145deg, #fffaf6, var(--peach)); }
.emote-art img { width: 88%; height: 88%; object-fit: contain; }
.emote-name {
  display: block;
  padding: 11px 4px 0;
  overflow: hidden;
  font-size: .88rem;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.load-sentinel { height: 20px; }
.empty-state { padding: 70px 20px; text-align: center; color: var(--muted); }
.empty-state span { display: block; margin-bottom: 10px; color: var(--green); font-size: 2rem; }
.empty-state h2 { margin-bottom: 8px; color: var(--ink); }

.battle-view { min-height: calc(100vh - 205px); }
.battle-heading { margin: 0 auto 18px; text-align: center; }
.battle-heading h1 { margin-bottom: 10px; }
.battle-heading > p:last-child { margin: 0; color: var(--muted); }

.battle-progress {
  width: min(560px, 100%);
  margin: 0 auto 26px;
  padding: 12px 15px 10px;
  background: rgba(255,255,255,.68);
  border: 1px solid rgba(255,255,255,.9);
  border-radius: 16px;
  box-shadow: 0 7px 24px rgba(43, 75, 55, .055);
}
.progress-copy {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: .82rem;
  font-weight: 600;
}
.progress-copy span:first-child { color: var(--ink); font-weight: 700; }
.progress-track {
  height: 7px;
  overflow: hidden;
  background: rgba(47,122,84,.12);
  border-radius: 20px;
}
.progress-track span {
  width: 0;
  height: 100%;
  display: block;
  background: linear-gradient(90deg, var(--green), #78b98f);
  border-radius: inherit;
  transition: width .3s ease;
}
.battle-progress small {
  display: block;
  margin-top: 6px;
  color: #829088;
  font-size: .72rem;
  text-align: right;
}

.battle-stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 72px minmax(0, 1fr);
  align-items: center;
  max-width: 960px;
  margin: 0 auto;
}

.fighter {
  min-width: 0;
  padding: 16px 16px 18px;
  color: var(--ink);
  background: rgba(255,255,255,.82);
  border: 2px solid rgba(255,255,255,.95);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease;
}
.fighter:first-child { transform: rotate(-1deg); }
.fighter:last-child { transform: rotate(1deg); }
.fighter:hover:not(:disabled), .fighter:focus-visible:not(:disabled) {
  transform: translateY(-7px) rotate(0);
  border-color: rgba(47,122,84,.38);
  box-shadow: 0 24px 60px rgba(36, 78, 55, .16);
  outline: none;
}
.fighter:disabled { cursor: wait; opacity: .76; }
.fighter-art {
  position: relative;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: linear-gradient(145deg, var(--mint-soft), var(--mint));
  border-radius: 20px;
}
.fighter:last-child .fighter-art { background: linear-gradient(145deg, #fbf8ff, var(--lavender)); }
.fighter-art img { position: relative; z-index: 1; width: 92%; height: 92%; object-fit: contain; }
.fighter-name {
  display: block;
  min-height: 2.8em;
  margin: 15px 5px 6px;
  font-family: ui-rounded, "Arial Rounded MT Bold", "Trebuchet MS", sans-serif;
  font-size: clamp(1.05rem, 2vw, 1.35rem);
  line-height: 1.2;
}
.vote-label { display: block; color: var(--green); font-size: .88rem; font-weight: 700; }
kbd { padding: 1px 5px; color: var(--muted); background: var(--white); border: 1px solid var(--line); border-radius: 5px; font: inherit; font-size: .75rem; box-shadow: 0 1px 0 var(--line); }

.fighter-loader {
  position: absolute;
  width: 34px;
  height: 34px;
  border: 3px solid rgba(47,122,84,.15);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
.fighter-art:has(img[src]) .fighter-loader { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.versus {
  position: relative;
  z-index: 2;
  display: grid;
  place-items: center;
}
.versus span {
  width: 62px;
  height: 62px;
  display: grid;
  place-items: center;
  color: var(--green-dark);
  background: var(--lemon);
  border: 5px solid var(--mint-soft);
  border-radius: 50%;
  font-family: ui-rounded, "Arial Rounded MT Bold", "Trebuchet MS", sans-serif;
  font-weight: 700;
  transform: rotate(-5deg);
}
.battle-status { min-height: 24px; margin: 18px 0 0; color: var(--green); font-weight: 600; text-align: center; }
.battle-edit-note {
  margin: 5px 0 0;
  color: #7d8b83;
  font-size: .78rem;
  text-align: center;
}
.text-button {
  display: block;
  margin: 2px auto 0;
  padding: 7px 11px;
  color: var(--muted);
  background: transparent;
  border: 0;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 4px;
}
.text-button:hover { color: var(--green-dark); text-decoration-color: currentColor; }

.top-view { max-width: 930px; margin: 0 auto; }
.ranking-list { display: grid; gap: 10px; }
.ranking-row {
  width: 100%;
  display: grid;
  grid-template-columns: 54px 74px minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 10px 18px 10px 10px;
  color: var(--ink);
  background: rgba(255,255,255,.73);
  border: 1px solid rgba(255,255,255,.92);
  border-radius: 19px;
  box-shadow: 0 5px 18px rgba(43, 75, 55, .04);
  cursor: pointer;
  text-align: left;
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.ranking-row:hover, .ranking-row:focus-visible {
  transform: translateY(-2px);
  border-color: rgba(47,122,84,.25);
  box-shadow: 0 11px 26px rgba(43, 75, 55, .09);
  outline: none;
}
.ranking-row:nth-child(1) { background: linear-gradient(100deg, rgba(255,243,189,.88), rgba(255,255,255,.78)); }
.ranking-row:nth-child(2) { background: linear-gradient(100deg, rgba(238,230,251,.86), rgba(255,255,255,.78)); }
.ranking-row:nth-child(3) { background: linear-gradient(100deg, rgba(255,233,220,.9), rgba(255,255,255,.78)); }
.rank-number { color: var(--green); font-family: ui-rounded, "Arial Rounded MT Bold", "Trebuchet MS", sans-serif; font-size: 1.25rem; font-weight: 700; text-align: center; }
.rank-art { width: 74px; height: 74px; padding: 5px; object-fit: contain; background: rgba(243,251,245,.8); border-radius: 14px; }
.rank-info { min-width: 0; }
.rank-name { display: block; overflow: hidden; font-family: ui-rounded, "Arial Rounded MT Bold", "Trebuchet MS", sans-serif; font-size: 1.08rem; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.rank-record { color: var(--muted); font-size: .82rem; }
.rank-score { color: var(--green-dark); font-weight: 700; text-align: right; }
.rank-score small { display: block; color: var(--muted); font-size: .7rem; font-weight: 600; text-transform: uppercase; }

.emote-dialog {
  width: min(940px, calc(100vw - 28px));
  max-height: calc(100dvh - 28px);
  padding: 0;
  overflow: auto;
  color: var(--ink);
  background: var(--mint-soft);
  border: 0;
  border-radius: var(--radius-lg);
  box-shadow: 0 35px 90px rgba(28, 57, 40, .25);
}
.emote-dialog::backdrop { background: rgba(22, 43, 31, .48); backdrop-filter: blur(5px); }
.dialog-close {
  position: absolute;
  z-index: 2;
  top: 12px;
  right: 12px;
  width: 38px;
  height: 38px;
  color: var(--ink);
  background: rgba(255,255,255,.86);
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.45rem;
}
.dialog-layout { display: grid; grid-template-columns: minmax(0, .95fr) minmax(320px, 1.05fr); }
.dialog-preview { min-width: 0; padding: 16px; }
.dialog-art { aspect-ratio: 1.15; display: grid; place-items: center; background: linear-gradient(145deg, var(--mint), var(--lavender)); border-radius: 18px; }
.dialog-art img { width: 88%; height: 88%; object-fit: contain; }
.dialog-details { padding: 20px 6px 5px; }
.dialog-details h2 { margin-bottom: 18px; font-size: clamp(1.35rem, 4vw, 2rem); }
.download-button {
  display: inline-flex;
  padding: 10px 16px;
  color: var(--white);
  background: var(--green);
  border-radius: 12px;
  font-weight: 700;
  text-decoration: none;
}

.notes-panel {
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 24px 22px 18px;
  background: rgba(255,255,255,.72);
  border-left: 1px solid var(--line);
}
.notes-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 0 38px 13px 2px;
  border-bottom: 1px solid var(--line);
}
.notes-heading h3 { margin: 0; font-size: 1.05rem; }
.notes-heading span { color: var(--muted); font-size: .78rem; }
.notes-list {
  min-height: 168px;
  max-height: 310px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.community-note { padding: 14px 2px; border-bottom: 1px solid var(--line); }
.community-note header { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.community-note strong { font-size: .88rem; }
.community-note time { color: var(--muted); font-size: .72rem; }
.community-note p { margin: 0; font-size: .88rem; line-height: 1.45; overflow-wrap: anywhere; }
.notes-placeholder { margin: 0; padding: 25px 2px; color: var(--muted); font-size: .86rem; text-align: center; }
.note-form { margin-top: auto; padding-top: 15px; }
.note-form label { display: block; }
.note-form input,
.note-form textarea {
  width: 100%;
  color: var(--ink);
  background: var(--mint-soft);
  border: 1px solid var(--line);
  border-radius: 11px;
  outline: 0;
}
.note-form input { min-height: 40px; padding: 0 11px; }
.note-form textarea { min-height: 78px; margin-top: 8px; padding: 10px 11px; resize: vertical; }
.note-form input:focus,
.note-form textarea:focus { border-color: rgba(47,122,84,.5); box-shadow: 0 0 0 3px rgba(47,122,84,.12); }
.note-form-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 8px; }
.note-form-footer span { color: var(--muted); font-size: .78rem; }
.note-form-footer button {
  min-height: 39px;
  padding: 0 14px;
  color: var(--white);
  background: var(--green);
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 700;
}
.note-form-footer button:disabled { cursor: wait; opacity: .65; }
.note-form > p { margin: 7px 2px 0; color: var(--muted); font-size: .72rem; }

.toast {
  position: fixed;
  z-index: 50;
  right: 20px;
  bottom: 20px;
  max-width: min(360px, calc(100vw - 40px));
  padding: 12px 16px;
  color: var(--white);
  background: var(--green-dark);
  border-radius: 13px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity .2s ease, transform .2s ease;
}
.toast.visible { opacity: 1; transform: none; }

noscript { display: block; padding: 30px; text-align: center; }

@media (max-width: 720px) {
  :root { --page: min(100% - 24px, 1240px); }
  .site-header { min-height: 70px; align-items: center; }
  .brand span:last-child { display: none; }
  .primary-nav a { padding: 8px 10px; font-size: .9rem; }
  main { padding-top: 28px; }
  .view-heading { align-items: start; }
  .gallery-toolbar { align-items: stretch; flex-direction: column; gap: 2px; }
  .search-field { width: 100%; }
  .toolbar-actions { justify-content: flex-start; }
  .motion-toggle { display: none; }
  .emote-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .emote-card { padding: 7px 7px 9px; border-radius: 15px; }
  .emote-name { padding-top: 8px; font-size: .77rem; }
  .battle-stage { grid-template-columns: 1fr 1fr; gap: 10px; }
  .fighter { padding: 8px 8px 13px; border-radius: 20px; }
  .fighter-art { border-radius: 15px; }
  .versus { position: absolute; left: 50%; transform: translateX(-50%); }
  .versus span { width: 48px; height: 48px; border-width: 4px; font-size: .88rem; }
  .fighter-name { margin-top: 12px; font-size: .95rem; }
  .vote-label kbd { display: none; }
  .top-heading { align-items: end; }
  .ranking-row { grid-template-columns: 35px 58px minmax(0, 1fr) auto; gap: 9px; padding: 8px 10px 8px 5px; }
  .rank-art { width: 58px; height: 58px; }
  .rank-name { font-size: .92rem; }
  .rank-score { font-size: .88rem; }
  .dialog-layout { grid-template-columns: 1fr; }
  .dialog-preview { padding: 12px; }
  .dialog-art { aspect-ratio: 1.35; }
  .notes-panel { padding: 19px 16px 15px; border-top: 1px solid var(--line); border-left: 0; }
  .notes-list { max-height: none; }
}

@media (max-width: 430px) {
  .emote-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .collection-count { display: none; }
  .view-heading { margin-bottom: 22px; }
  .battle-heading { margin-bottom: 22px; }
  .battle-heading > p:last-child { font-size: .9rem; }
}

@media (hover: none) {
  .motion-toggle { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
