* {
  box-sizing: border-box;
}

html,
body,
#app {
  width: 100%;
  height: 100%;
  margin: 0;
}

html {
  color-scheme: light;
  background: var(--wm-color-canvas);
}

body {
  overflow: hidden;
  background:
    linear-gradient(var(--wm-color-border-soft) 1px, transparent 1px),
    linear-gradient(90deg, var(--wm-color-border-soft) 1px, transparent 1px),
    var(--wm-color-canvas);
  background-size: 44px 44px;
  color: var(--wm-color-text);
  font-family: var(--wm-font-family-sans);
  font-size: var(--wm-font-size-md);
  line-height: var(--wm-font-line-normal);
  letter-spacing: 0;
  text-rendering: geometricPrecision;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: var(--wm-space-2);
  left: var(--wm-space-2);
  padding: var(--wm-space-2) var(--wm-space-3);
  border: 1px solid var(--wm-color-border);
  background: var(--wm-color-surface);
  color: var(--wm-color-text);
  transform: translateY(calc(-100% - var(--wm-space-4)));
}

.skip-link:focus {
  transform: translateY(0);
  box-shadow: var(--wm-shadow-focus);
}

button,
input,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button {
  color: inherit;
}

button:not(:disabled) {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

button,
textarea,
input {
  border-radius: var(--wm-radius-xs);
}

button:focus-visible,
textarea:focus-visible,
input:focus-visible {
  outline: none;
  box-shadow: var(--wm-shadow-focus);
}

::selection {
  background: var(--wm-color-accent);
  color: var(--wm-color-text-inverse);
}

.ui-icon {
  width: 18px;
  height: 18px;
  display: inline-block;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.file-input-hidden {
  position: fixed;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  pointer-events: none;
  opacity: 0;
  transform: translate(-200vw, -200vh);
}

.app-shell {
  width: 100vw;
  height: 100dvh;
  display: grid;
  grid-template-columns: var(--wm-size-sidebar-expanded) minmax(0, 1fr);
  background: color-mix(in srgb, var(--wm-color-canvas) 92%, white);
  overflow: hidden;
}

.app-shell.sidebar-collapsed {
  grid-template-columns: var(--wm-size-sidebar-collapsed) minmax(0, 1fr);
}

.sidebar {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  border-right: 1px solid var(--wm-color-border);
  background: var(--wm-color-surface);
  overflow: hidden;
}

.sidebar-header {
  min-width: 0;
  /* Match the main column's .topbar height so the left/right header borders align.
     Horizontal-only padding (like .topbar) so the 40px toggle fits the 58px row. */
  height: var(--wm-size-topbar);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--wm-space-3);
  /* Left inset = space-6 (24px) so the brand mark lands on the nav-icon rail
     (nav padding 12 + button padding 12); right inset = space-3 so the toggle
     aligns with the nav buttons' right edge. */
  padding: 0 var(--wm-space-3) 0 var(--wm-space-6);
  border-bottom: 1px solid var(--wm-color-border);
}

.brand {
  min-width: 0;
  width: 100%;
  display: grid;
  /* Wordmark column is max-content (not 1fr) so the caret hugs the brand instead of
     being pushed to the far right by a stretched column. */
  grid-template-columns: auto minmax(0, max-content);
  grid-template-areas: "mark text";
  align-items: center;
  /* start (not the default stretch) so the auto mark/caret columns don't absorb
     leftover width — keeps the mark→wordmark gap exactly column-gap (10px). */
  justify-content: start;
  column-gap: 10px;
  background: none;
  border: none;
  margin: 0;
  padding: 0;
  font: inherit;
  text-align: left;
  color: inherit;
  cursor: pointer;
  text-decoration: none;
}

.model-badge,
.generation-state-icon {
  display: inline-grid;
  place-items: center;
  border: 1px solid currentColor;
  font-family: var(--wm-font-family-mono);
  font-weight: var(--wm-font-weight-semibold);
}

/* Brand mark: solid accent square, matching the static content pages' .topbar lockup. */
.mark {
  grid-area: mark;
  width: 22px;
  height: 22px;
  background: var(--wm-color-accent);
}

.brand-text {
  grid-area: text;
  overflow: hidden;
  color: var(--wm-color-text);
  font-size: 15px;
  font-weight: var(--wm-font-weight-bold);
  letter-spacing: 3px;
  /* Nudge the all-caps wordmark down 1px: caps ride high in the line box because the
     empty descender space inflates it below the glyphs, so geometric-center reads high. */
  transform: translateY(1px);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-button,
.control-button {
  width: var(--wm-size-control);
  height: var(--wm-size-control);
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--wm-color-border);
  background: transparent;
  color: var(--wm-color-text);
  transition:
    background var(--wm-motion-duration-fast) var(--wm-motion-easing-standard),
    color var(--wm-motion-duration-fast) var(--wm-motion-easing-standard);
}

.icon-button:hover,
.control-button:hover {
  background: var(--wm-color-surface-sunken);
  color: var(--wm-color-text-inverse);
}

/* The sidebar expand/collapse toggle reads as a borderless glyph next to the
   brand; the hover background still gives the affordance. */
.icon-button[data-action="toggle-sidebar"] {
  border-color: transparent;
}

.nav {
  display: grid;
  gap: var(--wm-space-1);
  padding: var(--wm-space-3);
  border-bottom: 1px solid var(--wm-color-border);
}

.nav-button,
.recent-button {
  width: 100%;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: var(--wm-space-3);
  border: 1px solid transparent;
  background: transparent;
  color: var(--wm-color-text);
  text-align: left;
}

.nav-button {
  min-height: 44px;
  padding: var(--wm-space-2) var(--wm-space-3);
  font-weight: var(--wm-font-weight-medium);
}

.nav-button:hover,
.recent-button:hover,
.recent-button.is-loading,
.nav-button.is-active {
  border-color: var(--wm-color-border);
  background: var(--wm-color-surface-pressed);
}

.nav-button.is-active {
  color: var(--wm-color-accent);
}

.nav-icon {
  width: 20px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
}

.nav-label,
.recent-button span:last-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-main {
  min-height: 0;
  overflow-y: auto;
  padding: var(--wm-space-4) var(--wm-space-3);
}

.sidebar-section-title {
  /* left margin = space-3 so the label sits on the same icon rail as the items below */
  margin: var(--wm-space-2) var(--wm-space-2) var(--wm-space-3) var(--wm-space-3);
  color: var(--wm-color-text-muted);
  font-family: var(--wm-font-family-mono);
  font-size: var(--wm-font-size-xs);
  font-weight: var(--wm-font-weight-semibold);
}

.recent-list {
  display: grid;
  gap: var(--wm-space-1);
}

.recent-button {
  min-height: 38px;
  /* Horizontal padding matches .nav-button (space-3) so the history icons sit on the
     same left rail as the New Battle / Leaderboard / Search icons above. */
  padding: var(--wm-space-2) var(--wm-space-3);
  color: var(--wm-color-text-muted);
}

.sidebar-bottom {
  display: grid;
  gap: var(--wm-space-3);
  padding: var(--wm-space-3);
  border-top: 1px solid var(--wm-color-border);
}

.footer-links {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--wm-space-2);
}

.footer-link,
.consent-link {
  border: 0;
  background: transparent;
  color: var(--wm-color-text-muted);
  font-size: var(--wm-font-size-xs);
  text-align: left;
}

.footer-link:hover,
.consent-link:hover {
  color: var(--wm-color-text);
  text-decoration: underline;
}

.login-button,
.account-logout,
.topbar-auth {
  min-height: 40px;
  border: 1px solid var(--wm-color-border);
  background: var(--wm-color-surface-sunken);
  color: var(--wm-color-text-inverse);
  font-weight: var(--wm-font-weight-semibold);
}

.login-button {
  width: 100%;
}

.app-shell:not(.sidebar-collapsed) .topbar-auth {
  display: none;
}

.account-control {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: var(--wm-space-2);
  align-items: center;
}

.account-avatar {
  width: 34px;
  height: 34px;
  border: 1px solid var(--wm-color-border);
  object-fit: cover;
}

.account-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
  font-size: var(--wm-font-size-sm);
}

.account-copy strong,
.account-copy span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-copy span {
  color: var(--wm-color-text-muted);
  font-family: var(--wm-font-family-mono);
  font-size: var(--wm-font-size-xs);
}

.account-logout {
  grid-column: 1 / -1;
  width: 100%;
}

.sidebar-collapsed .brand,
.sidebar-collapsed .brand-text,
.sidebar-collapsed .nav-label,
.sidebar-collapsed .sidebar-main,
.sidebar-collapsed .sidebar-bottom {
  display: none;
}

.sidebar-collapsed .sidebar-header {
  grid-template-columns: 1fr;
  justify-items: center;
  padding-inline: var(--wm-space-2);
}

.sidebar-collapsed .nav {
  padding: var(--wm-space-2);
}

.sidebar-collapsed .nav-button {
  justify-content: center;
  padding: 0;
}

.main {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: var(--wm-size-topbar) minmax(0, 1fr);
}

.main.has-round-progress {
  grid-template-rows: var(--wm-size-topbar) 8px minmax(0, 1fr);
}

.topbar {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--wm-space-3);
  padding: 0 var(--wm-space-5);
  border-bottom: 1px solid var(--wm-color-border);
  background: var(--wm-color-surface);
}

.topbar-left {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: var(--wm-space-1);
}

.topbar-title {
  min-width: 0;
  height: 38px;
  display: inline-flex;
  align-items: center;
  gap: var(--wm-space-2);
  padding: 0 8px;
  color: var(--wm-color-text);
  font-weight: var(--wm-font-weight-semibold);
}

.topbar-title-icon {
  display: inline-grid;
  place-items: center;
  color: var(--wm-color-accent);
}

.topbar-right {
  display: inline-flex;
  align-items: center;
  gap: var(--wm-space-2);
}

.language-switch {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: 112px;
  height: 34px;
  padding: 2px;
  border: 1px solid var(--wm-color-border);
  border-radius: var(--wm-radius-xs);
  background: var(--wm-color-canvas-muted);
}

.language-option {
  min-width: 0;
  border: 0;
  border-radius: calc(var(--wm-radius-xs) - 2px);
  background: transparent;
  color: var(--wm-color-text-muted);
  font-family: inherit;
  font-size: var(--wm-font-size-xs);
  font-weight: var(--wm-font-weight-semibold);
}

.language-option.is-active {
  background: var(--wm-color-surface);
  color: var(--wm-color-text);
  box-shadow: 0 0 0 1px var(--wm-color-border-soft);
}

.topbar-auth {
  padding: 0 var(--wm-space-4);
}

.round-progress {
  min-width: 0;
  height: 8px;
  overflow: hidden;
  border-bottom: 1px solid var(--wm-color-border);
  background: var(--wm-color-canvas-muted);
}

.round-progress-fill {
  display: block;
  height: 100%;
  background: var(--wm-color-accent);
  transition: width 220ms ease-out;
}

.content {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  padding: var(--wm-space-6);
}

.compose-shell,
.battle-shell,
.leaderboard-shell {
  width: min(100%, 1240px);
  min-height: 100%;
  margin: 0 auto;
}

.mobile-bottom-safe-zone {
  display: none;
}

.compose-shell {
  display: grid;
  align-content: center;
  gap: var(--wm-space-4);
}

.composer {
  --compose-image-height: min(46dvh, 420px);
  width: min(100%, 980px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(260px, 420px) minmax(0, 1fr);
  align-items: start;
  gap: 0;
  border: 1px solid var(--wm-color-border);
  background: transparent;
  box-shadow: 8px 8px 0 var(--wm-color-border-soft);
}

.compose-shell.is-selected .composer {
  width: min(100%, 1120px);
  grid-template-columns:
    minmax(180px, min(var(--media-width, 1280px), calc(var(--compose-image-height) * var(--media-ratio, 1.77778)), 52vw))
    minmax(400px, 1fr);
}

.image-slot {
  position: relative;
  width: 100%;
  min-width: 0;
  min-height: 0;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-right: 1px solid var(--wm-color-border);
  background: var(--wm-color-surface-sunken);
}

.compose-shell.is-selected .image-slot {
  aspect-ratio: var(--media-aspect, 16 / 9);
  align-self: start;
  background: transparent;
}

.image-slot.is-dragging {
  outline: 2px solid var(--wm-color-accent);
  outline-offset: -4px;
}

.battle-image-bg,
.gallery-thumb {
  background-color: var(--wm-color-surface-sunken);
  background-image: var(--scene-image);
  background-position: center;
  background-size: cover;
}

.image-preview {
  width: 100%;
  height: 100%;
  background-color: transparent;
  background-image: var(--scene-image);
  background-position: center;
  background-repeat: no-repeat;
  background-size: var(--media-fit, contain);
}

.filled-toolbar {
  position: absolute;
  right: var(--wm-space-3);
  bottom: var(--wm-space-3);
  display: inline-flex;
  gap: var(--wm-space-2);
}

.image-reviewing {
  position: absolute;
  inset: 0;
  /* flex column (not grid place-items) so the spinner + label stay one centered
     group; a bare grid stretches the two rows and pushes the spinner off-center. */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--wm-space-3);
  background: color-mix(in srgb, var(--wm-color-surface-sunken) 55%, transparent);
  color: var(--wm-color-text-inverse);
  font-weight: var(--wm-font-weight-semibold);
}

.image-reviewing .spinner {
  width: 34px;
  height: 34px;
}

.tiny-button,
.gallery-button,
.ghost-button,
.primary-button,
.secondary-button,
.vote-button {
  min-height: var(--wm-size-control);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--wm-space-2);
  border: 1px solid var(--wm-color-border);
  background: var(--wm-color-surface);
  color: var(--wm-color-text);
  font-weight: var(--wm-font-weight-semibold);
}

.tiny-button {
  min-height: 34px;
  padding: 0 var(--wm-space-3);
  background: var(--wm-color-surface-translucent);
}

.empty-slot {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  gap: var(--wm-space-4);
  padding: var(--wm-space-6);
  color: var(--wm-color-text-inverse);
  text-align: center;
}

.empty-icon {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border: 1px solid currentColor;
}

.empty-title {
  max-width: 220px;
  font-size: var(--wm-font-size-xl);
  font-weight: var(--wm-font-weight-semibold);
  line-height: var(--wm-font-line-compact);
}

.empty-subtitle {
  max-width: 280px;
  color: var(--wm-color-text-muted);
  font-size: var(--wm-font-size-sm);
  line-height: var(--wm-font-line-normal);
}

.leaderboard-modality {
  display: inline-flex;
  gap: var(--wm-space-1);
  margin-bottom: var(--wm-space-3);
  padding: 4px;
  border: 1px solid var(--wm-color-border);
  border-radius: var(--wm-radius-sm);
  background: var(--wm-color-surface);
}

.lb-tab {
  padding: var(--wm-space-2) var(--wm-space-3);
  border: 0;
  border-radius: var(--wm-radius-xs);
  background: transparent;
  color: var(--wm-color-text-muted);
  font-weight: var(--wm-font-weight-medium);
}

.lb-tab.is-active {
  background: var(--wm-color-surface-sunken);
  color: var(--wm-color-text-inverse);
}

.empty-actions {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--wm-space-2);
}

.empty-slot .gallery-button {
  background: transparent;
  color: var(--wm-color-text-inverse);
  border-color: currentColor;
}

.drop-overlay {
  position: absolute;
  inset: var(--wm-space-3);
  display: grid;
  place-items: center;
  gap: var(--wm-space-2);
  background: color-mix(in srgb, var(--wm-color-accent) 86%, transparent);
  color: var(--wm-color-text-inverse);
  font-weight: var(--wm-font-weight-semibold);
}

.action-stack {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(180px, 1fr) auto auto auto;
  background: var(--wm-color-surface);
}

.compose-shell.is-selected .action-stack {
  min-height: min-content;
  /* Stretch the white panel to the image's height; the textarea (1fr) absorbs the
     extra height so the right column reads as one solid card, while the footer stays
     a single slim row at the bottom (no empty filler below the Start button). */
  align-self: stretch;
  grid-template-rows: 1fr auto;
}

.action-field {
  width: 100%;
  min-width: 0;
  min-height: 260px;
  padding: var(--wm-space-5);
  resize: none;
  border: 0;
  border-bottom: 1px solid var(--wm-color-border);
  background: transparent;
  color: var(--wm-color-text);
  font-size: var(--wm-font-size-2xl);
  font-weight: var(--wm-font-weight-medium);
  line-height: var(--wm-font-line-normal);
}

.compose-shell.is-selected .action-field {
  min-height: clamp(180px, 28dvh, 220px);
}

.action-field::placeholder {
  color: var(--wm-color-text-faint);
}

.chip-row {
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  gap: var(--wm-space-2);
  padding: var(--wm-space-3) var(--wm-space-4);
  border-bottom: 1px solid var(--wm-color-border-soft);
}

.chip {
  max-width: 100%;
  min-height: 32px;
  padding: var(--wm-space-1) var(--wm-space-3);
  border: 1px solid var(--wm-color-border-soft);
  background: transparent;
  color: var(--wm-color-text-muted);
  text-align: left;
  white-space: normal;
}

.chip:hover {
  border-color: var(--wm-color-border);
  color: var(--wm-color-text);
}

.composer-footer {
  min-width: 0;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding: var(--wm-space-3) var(--wm-space-4);
}

.composer-tools {
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--wm-space-2);
}

.ghost-button,
.gallery-button {
  padding: 0 var(--wm-space-3);
  background: transparent;
}

.ghost-button:hover,
.gallery-button:hover,
.secondary-button:hover,
.tiny-button:hover {
  background: var(--wm-color-surface-sunken);
  color: var(--wm-color-text-inverse);
}

.primary-button {
  padding: 0 var(--wm-space-4);
  background: var(--wm-color-surface-sunken);
  color: var(--wm-color-text-inverse);
}

.primary-button:not(:disabled):hover {
  background: var(--wm-color-accent);
  border-color: var(--wm-color-accent);
}

.secondary-button {
  padding: 0 var(--wm-space-4);
  background: transparent;
}

.char-count {
  color: var(--wm-color-text-muted);
  font-family: var(--wm-font-family-mono);
  font-size: var(--wm-font-size-xs);
  white-space: nowrap;
}

.system-alert {
  margin: 0 var(--wm-space-4) var(--wm-space-4);
  padding: var(--wm-space-3);
  border: 1px solid var(--wm-color-border);
  background: var(--wm-color-canvas-muted);
}

.disclosure {
  width: min(100%, 980px);
  margin: 0 auto;
  color: var(--wm-color-text-faint);
  font-family: var(--wm-font-family-mono);
  font-size: var(--wm-font-size-xs);
  text-align: center;
}

.battle-shell {
  --battle-grid-gap: var(--wm-space-4);
  --battle-media-max-height: min(58dvh, 720px);
  --battle-card-column-max: calc((100% - var(--battle-grid-gap)) / 2);
  --battle-card-target-width: min(
    var(--battle-card-column-max),
    var(--media-width, 1280px),
    calc(var(--battle-media-max-height) * var(--media-ratio, 1.77778))
  );
  display: grid;
  position: relative;
  align-content: center;
  gap: var(--wm-space-4);
  width: min(100%, 1500px);
  padding: var(--wm-space-4) 0;
}

.battle-primary-action {
  width: 100%;
  height: 48px;
  display: grid;
  place-items: center;
  transition: opacity 180ms ease;
}

.battle-primary-action > .battle-action-control,
.battle-playback-countdown {
  grid-area: 1 / 1;
}

.battle-playback-countdown {
  box-sizing: border-box;
  width: 64px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 2px solid var(--wm-color-border);
  background: var(--wm-color-surface);
  box-shadow: 4px 4px 0 color-mix(in srgb, var(--wm-color-border) 35%, transparent);
  color: var(--wm-color-accent);
  font-size: 32px;
  font-weight: var(--wm-font-weight-medium);
  line-height: 1;
  pointer-events: none;
}

.battle-action-control {
  box-sizing: border-box;
  width: min(100%, 430px);
  height: 48px;
  min-height: 48px;
}

.battle-vote-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--wm-space-3);
}

.battle-question-anchor {
  display: contents;
}

.battle-vote-panel {
  display: none;
}

.battle-question {
  margin: 0;
  display: grid;
  place-items: center;
  color: var(--wm-color-accent);
  font-size: 32px;
  font-weight: var(--wm-font-weight-medium);
  line-height: var(--wm-font-line-compact);
  letter-spacing: 0;
  text-align: center;
}

.battle-both-bad-button {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 0 var(--wm-space-4);
  border: 1px solid color-mix(in srgb, var(--wm-color-danger) 45%, var(--wm-color-border));
  border-radius: var(--wm-radius-xs);
  background: var(--wm-color-surface);
  color: var(--wm-color-danger);
  font: inherit;
  font-weight: var(--wm-font-weight-medium);
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
}

.battle-both-bad-button:hover {
  border-color: var(--wm-color-danger);
  background: color-mix(in srgb, var(--wm-color-danger) 8%, var(--wm-color-surface));
}

.battle-both-bad-button:focus-visible {
  outline: none;
  box-shadow: var(--wm-shadow-focus);
}

.battle-next-action {
  display: grid;
  place-items: center;
}

.battle-next-button {
  width: min(100%, 240px);
  height: 48px;
  min-height: 48px;
  margin: 0;
}

.battle-entry-loading {
  width: 100%;
  min-height: calc(100dvh - 76px);
  display: grid;
  place-items: center;
}

.battle-entry-brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.battle-entry-mark {
  width: 32px;
  height: 32px;
  display: inline-grid;
  place-items: center;
  color: var(--wm-color-accent);
}

.battle-entry-mark svg {
  width: 32px;
  height: 32px;
}

.battle-entry-wordmark {
  color: var(--wm-color-text);
  font-size: 20px;
  font-weight: var(--wm-font-weight-bold);
  letter-spacing: 4px;
  line-height: 1;
}

.battle-stage {
  min-width: 0;
  display: grid;
  position: relative;
}

.battle-stage::before {
  content: "";
  grid-area: 1 / 1;
  z-index: 1;
  pointer-events: none;
  background: var(--wm-color-surface);
  opacity: 0;
  will-change: opacity;
}

.battle-stage > .battle-source-preview,
.battle-stage > .battle-grid {
  grid-area: 1 / 1;
}

.battle-source-preview {
  z-index: 2;
  width: min(100%, var(--battle-card-target-width));
  align-self: start;
  justify-self: center;
  margin-top: 54px;
  overflow: hidden;
  position: relative;
  display: block;
  aspect-ratio: var(--media-aspect, 16 / 9);
  border: 1px solid var(--wm-color-border);
  background: var(--wm-color-surface-sunken);
  transform: translateZ(0);
  transition: border-color 180ms ease, background-color 180ms ease;
  will-change: opacity, transform;
}

.battle-source-image {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  background: var(--wm-color-surface-sunken);
}

.battle-source-split {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
}

.battle-source-pane {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 50%;
  overflow: hidden;
  background: var(--wm-color-surface-sunken);
  will-change: opacity, transform;
}

.battle-source-pane.is-left {
  left: 0;
}

.battle-source-pane.is-right {
  right: 0;
}

.battle-source-pane img {
  position: absolute;
  top: 0;
  width: 200%;
  height: 100%;
  max-width: none;
  object-fit: fill;
  background: var(--wm-color-surface-sunken);
}

.battle-source-pane.is-left img {
  left: 0;
}

.battle-source-pane.is-right img {
  right: 0;
}

.battle-shell.is-media-ready .battle-source-preview {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.battle-shell:is(.is-media-image, .is-media-prompt, .is-media-transitioning) .vote-wrap {
  display: none;
}

.battle-shell:is(.is-media-image, .is-media-prompt, .is-media-transitioning) .battle-primary-action {
  visibility: hidden;
  opacity: 0;
}

.battle-shell.is-interaction-locked .battle-vote-actions {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.battle-shell.is-interaction-unlocked .battle-playback-countdown {
  display: none;
}

.battle-shell.is-interaction-locked .battle-card,
.battle-shell.is-interaction-locked .battle-card:hover,
.battle-shell.is-interaction-locked .battle-card:active,
.battle-shell.is-interaction-locked .battle-card:focus-within {
  cursor: default;
  border-color: var(--wm-color-border);
  box-shadow: none;
}

.battle-shell.is-interaction-locked .battle-card-vote-target {
  pointer-events: none;
}

.battle-shell.is-media-image .prompt-row {
  display: none;
}

.battle-shell.is-media-image.has-floating-prompt .prompt-row {
  display: flex;
}

.battle-shell.is-media-prompt .prompt-image-thumb {
  display: none;
}

.battle-shell.is-media-prompt .prompt-context {
  border: 0;
}

.battle-shell.is-media-prompt .prompt-pill {
  border: 1px solid var(--wm-color-border);
}

.battle-shell:is(.is-media-image, .is-media-prompt) .battle-grid {
  pointer-events: none;
}

.battle-shell:is(.is-media-image, .is-media-prompt) .battle-stage::before {
  opacity: 1;
}

.battle-shell:is(.is-media-prompt, .is-media-transitioning) .prompt-row {
  animation: wm-prompt-in 180ms ease-out both;
}

.battle-shell.is-media-transitioning .battle-grid {
  pointer-events: none;
}

.battle-shell.is-media-transitioning .battle-stage::before {
  opacity: 0;
  transition: opacity 520ms ease 80ms;
}

.battle-shell.is-media-transitioning .battle-source-base {
  opacity: 0;
}

.battle-shell.is-media-transitioning .battle-source-preview {
  border-color: transparent;
  background: transparent;
}

.battle-shell.is-media-transitioning .prompt-image-thumb {
  animation: wm-prompt-thumb-in 650ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.battle-shell.is-media-transitioning .battle-source-split {
  opacity: 1;
}

.battle-shell.is-media-transitioning .battle-source-pane.is-left {
  animation: wm-source-split-left 650ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.battle-shell.is-media-transitioning .battle-source-pane.is-right {
  animation: wm-source-split-right 650ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes wm-prompt-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes wm-prompt-thumb-in {
  from {
    width: 0;
    opacity: 0;
  }
  to {
    width: var(--prompt-thumb-width, 64px);
    opacity: 1;
  }
}

@keyframes wm-source-split-left {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(calc(-100% - var(--battle-grid-gap) / 2));
  }
}

@keyframes wm-source-split-right {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(calc(100% + var(--battle-grid-gap) / 2));
  }
}

.prompt-row {
  display: flex;
  justify-content: center;
  min-width: 0;
}

.prompt-context {
  max-width: min(860px, 100%);
  min-width: 0;
  display: flex;
  align-items: stretch;
  overflow: hidden;
  border: 1px solid var(--wm-color-border);
  background: var(--wm-color-surface);
}

.prompt-image-thumb {
  --prompt-thumb-width: 64px;
  width: var(--prompt-thumb-width);
  min-height: 42px;
  flex: 0 0 auto;
  border-right: 1px solid var(--wm-color-border);
  background-color: var(--wm-color-surface-sunken);
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
}

.prompt-pill {
  max-width: min(760px, 100%);
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  padding: var(--wm-space-2) var(--wm-space-4);
  border: 1px solid var(--wm-color-border);
  background: var(--wm-color-surface);
  color: var(--wm-color-text);
  font-weight: var(--wm-font-weight-medium);
}

.prompt-context .prompt-pill {
  min-width: 0;
  border: 0;
}

.battle-grid {
  min-width: 0;
  position: relative;
  z-index: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, var(--battle-card-target-width)));
  align-items: start;
  justify-items: center;
  justify-content: center;
  gap: var(--battle-grid-gap);
}

.battle-card {
  position: relative;
  width: 100%;
  max-width: min(100%, var(--media-width, 1280px), calc(var(--battle-media-max-height) * var(--media-ratio, 1.77778)));
  min-width: 0;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto auto;
  border: 1px solid var(--wm-color-border);
  background: var(--wm-color-surface);
}

.battle-card[data-vote-side] {
  cursor: pointer;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.battle-card[data-vote-side]:hover,
.battle-card[data-vote-side]:has(.battle-card-vote-target:focus-visible) {
  border-color: var(--wm-color-accent);
  box-shadow: var(--wm-shadow-winner);
}

.battle-card-vote-target {
  position: absolute;
  z-index: 3;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: transparent;
  cursor: pointer;
}

.battle-card-vote-target:focus-visible {
  outline: 3px solid var(--wm-color-accent);
  outline-offset: -4px;
}

.battle-card-vote-target:disabled {
  cursor: wait;
}

.battle-card.is-winner {
  border-color: var(--wm-color-accent);
  box-shadow: var(--wm-shadow-winner);
}

.battle-card.is-bad {
  border-color: var(--wm-color-danger);
  box-shadow: var(--wm-shadow-danger);
}

.card-header {
  min-width: 0;
  height: 72px;
  min-height: 72px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--wm-space-3);
  padding: var(--wm-space-2) var(--wm-space-3);
  border-bottom: 1px solid var(--wm-color-border);
  background: var(--wm-color-surface);
}

.model-title {
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: var(--wm-space-3);
}

.model-badge {
  width: 34px;
  height: 34px;
  color: var(--wm-color-accent);
  font-size: var(--wm-font-size-md);
}

.model-copy {
  min-width: 0;
  display: grid;
  grid-template-rows: 22px 16px 16px;
  gap: 1px;
}

.model-name {
  overflow: hidden;
  color: var(--wm-color-text);
  font-family: var(--wm-font-family-mono);
  font-size: var(--wm-font-size-lg);
  font-weight: var(--wm-font-weight-semibold);
  line-height: 22px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-org,
.model-params {
  overflow: hidden;
  color: var(--wm-color-text-muted);
  font-size: var(--wm-font-size-xs);
  line-height: 16px;
  min-height: 16px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-params {
  font-family: var(--wm-font-family-mono);
}

.card-controls {
  position: relative;
  z-index: 4;
  display: inline-flex;
  gap: var(--wm-space-2);
}

.control-button {
  width: 34px;
  height: 34px;
}

.blind-playback-control[aria-pressed="true"] {
  background: var(--wm-color-surface-pressed);
}

.card-body {
  position: relative;
  min-width: 0;
  overflow: hidden;
  aspect-ratio: var(--media-aspect, 16 / 9);
  background: var(--wm-color-surface-sunken);
}

.battle-image-bg {
  position: absolute;
  inset: 0;
  opacity: 0.45;
  filter: grayscale(1) contrast(1.08);
  background-repeat: no-repeat;
  background-size: var(--media-fit, contain);
}

.generating-state,
.generation-state,
.expired-clip {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: var(--wm-space-5);
  color: var(--wm-color-text-inverse);
}

.generating-inner,
.generation-inner,
.expired-clip-inner {
  width: min(100%, 380px);
  display: grid;
  justify-items: center;
  gap: var(--wm-space-3);
  text-align: center;
}

.generation-state.is-terminal {
  background: color-mix(in oklab, var(--wm-color-surface-sunken) 18%, transparent);
}

.generation-inner.is-terminal {
  gap: var(--wm-space-2);
}

.generation-state-icon {
  width: 48px;
  height: 48px;
  color: var(--wm-color-text-inverse);
}

.generation-state-icon.is-ready {
  color: var(--wm-color-accent);
}

.generation-state-icon.is-error {
  color: var(--wm-color-danger);
}

.generation-substatus,
.generation-elapsed {
  color: color-mix(in srgb, var(--wm-color-text-inverse) 72%, transparent);
  font-size: var(--wm-font-size-sm);
}

.generation-elapsed {
  font-family: var(--wm-font-family-mono);
}

.generation-progress {
  width: min(100%, 390px);
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--wm-space-2);
  margin-top: var(--wm-space-1);
}

.generation-progress span {
  min-width: 0;
  padding: 5px var(--wm-space-2);
  border: 1px solid color-mix(in srgb, var(--wm-color-text-inverse) 28%, transparent);
  color: color-mix(in srgb, var(--wm-color-text-inverse) 70%, transparent);
  font-family: var(--wm-font-family-mono);
  font-size: var(--wm-font-size-xs);
  line-height: var(--wm-font-line-tight);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.generation-progress span.is-done,
.generation-progress span.is-active {
  border-color: var(--wm-color-accent);
  color: var(--wm-color-text-inverse);
}

.spinner {
  width: 48px;
  height: 48px;
  border: 2px solid color-mix(in srgb, var(--wm-color-text-inverse) 28%, transparent);
  border-top-color: var(--wm-color-accent);
  border-radius: 50%;
  animation: wm-spin 900ms linear infinite;
}

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

.video-stage {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--wm-color-surface-sunken);
}

.video-stage.is-loading {
  display: grid;
  place-items: center;
}

.real-video {
  width: 100%;
  height: 100%;
  display: block;
  background: var(--wm-color-surface-sunken);
  object-fit: contain;
  opacity: 1;
}

.wechat-video-image {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  background: var(--wm-color-surface-sunken);
  pointer-events: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
}

.real-video:not([controls])::-webkit-media-controls-start-playback-button,
.real-video:not([controls])::-webkit-media-controls-overlay-play-button {
  display: none !important;
  -webkit-appearance: none;
}

.simulated-clip {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--wm-color-surface-sunken);
}

.simulated-badge {
  position: absolute;
  z-index: 2;
  top: var(--wm-space-3);
  left: var(--wm-space-3);
  max-width: min(320px, calc(100% - var(--wm-space-6)));
  padding: var(--wm-space-1) var(--wm-space-2);
  border: var(--wm-border-width) solid var(--wm-color-border-strong);
  background: var(--wm-color-ink);
  color: var(--wm-color-canvas);
  font-family: var(--wm-font-mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1.25;
  text-transform: uppercase;
}

.simulated-frame {
  position: absolute;
  inset: 0;
  background-image: var(--scene-image);
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  transform: scale(1.03);
  animation: wm-sim-drift 5s linear infinite;
  will-change: transform, filter;
}

.simulated-motion-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, transparent 0 44%, color-mix(in srgb, var(--accent, #0057ff) 18%, transparent) 50%, transparent 57%),
    radial-gradient(circle at 64% 38%, color-mix(in srgb, var(--accent, #0057ff) 26%, transparent), transparent 30%);
  mix-blend-mode: screen;
  opacity: 0.34;
  animation: wm-sim-light 5s linear infinite;
}

.simulated-clip.variant-crisp .simulated-frame {
  filter: saturate(1.08) contrast(1.04);
}

.simulated-clip.variant-cinematic .simulated-frame {
  filter: saturate(1.16) contrast(1.02) brightness(0.96);
}

.simulated-clip.motion-advance .simulated-frame {
  animation-name: wm-sim-advance;
}

.simulated-clip.motion-pan .simulated-frame {
  animation-name: wm-sim-pan;
}

.simulated-clip.motion-rise .simulated-frame {
  animation-name: wm-sim-rise;
}

.simulated-clip.motion-orbit .simulated-frame {
  animation-name: wm-sim-orbit;
}

@keyframes wm-sim-drift {
  0% {
    transform: scale(1.04) translate3d(-1.5%, 0, 0);
  }
  50% {
    transform: scale(1.07) translate3d(1.5%, -0.5%, 0);
  }
  100% {
    transform: scale(1.04) translate3d(-1.5%, 0, 0);
  }
}

@keyframes wm-sim-advance {
  0% {
    transform: scale(1.02);
  }
  100% {
    transform: scale(1.12);
  }
}

@keyframes wm-sim-pan {
  0% {
    transform: scale(1.08) translate3d(-3%, 0, 0);
  }
  100% {
    transform: scale(1.08) translate3d(3%, 0, 0);
  }
}

@keyframes wm-sim-rise {
  0% {
    transform: scale(1.07) translate3d(0, 2.5%, 0);
  }
  100% {
    transform: scale(1.07) translate3d(0, -2.5%, 0);
  }
}

@keyframes wm-sim-orbit {
  0% {
    transform: scale(1.08) rotate(-0.6deg);
  }
  50% {
    transform: scale(1.1) rotate(0.6deg);
  }
  100% {
    transform: scale(1.08) rotate(-0.6deg);
  }
}

@keyframes wm-sim-light {
  0% {
    transform: translateX(-12%);
    opacity: 0.22;
  }
  50% {
    transform: translateX(10%);
    opacity: 0.38;
  }
  100% {
    transform: translateX(-12%);
    opacity: 0.22;
  }
}

.expired-icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border: 1px solid currentColor;
}

.vote-wrap {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.vote-bar {
  width: min(100%, 780px);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border: 1px solid var(--wm-color-border);
  background: var(--wm-color-surface);
}

.status-bar {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.vote-button {
  min-width: 0;
  min-height: 54px;
  border: 0;
  border-right: 1px solid var(--wm-color-border);
  background: transparent;
}

.vote-button:last-child {
  border-right: 0;
}

.vote-button:hover:not(:disabled),
.vote-button.is-selected {
  background: var(--wm-color-surface-sunken);
  color: var(--wm-color-text-inverse);
}

.vote-button.is-selected.good,
.vote-button.is-selected {
  background: var(--wm-color-accent);
  color: var(--wm-color-text-inverse);
}

.vote-button.is-selected.bad {
  background: var(--wm-color-danger);
  color: var(--wm-color-text-inverse);
}

.vote-button.is-selected:disabled {
  cursor: default;
  opacity: 1;
}

.leaderboard-shell {
  display: grid;
  align-content: start;
  gap: var(--wm-space-5);
  padding-block: var(--wm-space-6);
}

.page-title {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: var(--wm-space-4);
  border-bottom: 1px solid var(--wm-color-border);
  padding-bottom: var(--wm-space-4);
}

.page-title h1 {
  margin: 0;
  font-size: var(--wm-font-size-3xl);
  font-weight: var(--wm-font-weight-semibold);
  line-height: var(--wm-font-line-tight);
}

.page-title p {
  margin: var(--wm-space-2) 0 0;
  color: var(--wm-color-text-muted);
}

.table-wrap {
  min-width: 0;
  overflow: auto;
  border: 1px solid var(--wm-color-border);
  background: var(--wm-color-surface);
}

.leaderboard-table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  /* Fixed layout + explicit column widths so the "Image + Prompt" (i2v) and
     "Prompt only" (t2v) tabs render identical columns. Auto layout sized each
     column to its content, and the two tabs (different model ids, vote counts,
     CI ranges) never lined up. */
  table-layout: fixed;
}

.leaderboard-table th:nth-child(1) { width: 7%; }   /* # */
.leaderboard-table th:nth-child(2) { width: 26%; }  /* Model */
.leaderboard-table th:nth-child(3) { width: 16%; }  /* Org */
.leaderboard-table th:nth-child(4) { width: 15%; }  /* Price */
.leaderboard-table th:nth-child(5) { width: 11%; }  /* Elo */
.leaderboard-table th:nth-child(6) { width: 16%; }  /* 95% CI */
.leaderboard-table th:nth-child(7) { width: 9%; }   /* Votes */

.leaderboard-table th,
.leaderboard-table td {
  padding: var(--wm-space-3);
  border-bottom: 1px solid var(--wm-color-border-soft);
  text-align: left;
  vertical-align: middle;
}

.leaderboard-table th {
  color: var(--wm-color-text-muted);
  font-family: var(--wm-font-family-mono);
  font-size: var(--wm-font-size-xs);
  font-weight: var(--wm-font-weight-semibold);
}

.leaderboard-price-header {
  position: relative;
}

.leaderboard-price-heading {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.leaderboard-price-hint {
  position: relative;
  display: inline-flex;
  z-index: 4;
}

.leaderboard-price-hint-trigger {
  display: inline-grid;
  width: 18px;
  height: 18px;
  padding: 0;
  place-items: center;
  border: 1px solid currentColor;
  border-radius: 50%;
  background: transparent;
  color: var(--wm-color-text-muted);
  font: inherit;
  line-height: 1;
  cursor: help;
}

.leaderboard-price-hint-trigger:hover,
.leaderboard-price-hint-trigger:focus-visible {
  color: var(--wm-color-text);
  outline: none;
}

.leaderboard-price-hint-panel {
  position: absolute;
  top: calc(100% + var(--wm-space-2));
  right: 0;
  display: grid;
  width: min(320px, calc(100vw - 40px));
  padding: var(--wm-space-3);
  gap: var(--wm-space-2);
  border: 1px solid var(--wm-color-border);
  background: var(--wm-color-text);
  color: var(--wm-color-surface);
  box-shadow: var(--wm-shadow-panel);
  font-family: var(--wm-font-family-sans);
  font-size: var(--wm-font-size-xs);
  font-weight: var(--wm-font-weight-regular);
  line-height: 1.45;
  text-align: left;
  white-space: normal;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity 120ms ease, transform 120ms ease, visibility 120ms ease;
  pointer-events: none;
}

.leaderboard-price-hint-panel strong {
  color: inherit;
  font-weight: var(--wm-font-weight-semibold);
}

.leaderboard-price-hint:hover .leaderboard-price-hint-panel,
.leaderboard-price-hint:focus-within .leaderboard-price-hint-panel {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.leaderboard-table tr:last-child td {
  border-bottom: 0;
}

.empty-row td,
.empty-state {
  color: var(--wm-color-text-muted);
  font-family: var(--wm-font-family-mono);
  font-size: var(--wm-font-size-sm);
}

.empty-row td {
  padding: var(--wm-space-5);
  text-align: center;
}

.rank,
.number {
  font-family: var(--wm-font-family-mono);
  white-space: nowrap;
}

.number {
  text-align: right;
}

.ci {
  color: var(--wm-color-text-muted);
}

.model-cell {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.model-cell span {
  color: var(--wm-color-text-muted);
  font-family: var(--wm-font-family-mono);
  font-size: var(--wm-font-size-xs);
}

.empty-state {
  padding: var(--wm-space-5);
  border-bottom: 1px solid var(--wm-color-border-soft);
  background: var(--wm-color-surface);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: var(--wm-space-5);
  background: rgba(246, 244, 238, 0.82);
  backdrop-filter: blur(8px);
}

.round-completion-backdrop {
  background: rgba(246, 244, 238, 0.88);
}

.round-completion-modal {
  width: min(560px, calc(100vw - 40px));
}

.round-completion-popup {
  width: 100%;
  min-height: 132px;
  display: grid;
  place-items: center;
  padding: var(--wm-space-5);
  border: 1px solid var(--wm-color-border);
  border-radius: 0;
  background: var(--wm-color-surface);
  color: var(--wm-color-text);
  font: inherit;
  font-size: var(--wm-font-size-2xl);
  font-weight: var(--wm-font-weight-semibold);
  line-height: var(--wm-font-line-normal);
  letter-spacing: 0;
  text-align: center;
  cursor: pointer;
  box-shadow: 8px 8px 0 var(--wm-color-border);
}

.round-completion-popup:hover {
  color: var(--wm-color-accent);
}

.round-completion-popup:active {
  transform: translate(4px, 4px);
  box-shadow: 4px 4px 0 var(--wm-color-border);
}

.round-completion-popup:focus-visible {
  outline: 3px solid var(--wm-color-accent);
  outline-offset: 4px;
}

.modal {
  width: min(980px, calc(100vw - 40px));
  max-height: min(760px, calc(100dvh - 40px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  border: 1px solid var(--wm-color-border);
  background: var(--wm-color-surface);
  box-shadow: 10px 10px 0 var(--wm-color-border-soft);
}

.modal-header,
.modal-footer {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--wm-space-3);
  padding: var(--wm-space-4);
  border-bottom: 1px solid var(--wm-color-border);
}

.modal-header h2 {
  margin: 0;
  min-width: 0;
  overflow: hidden;
  font-size: var(--wm-font-size-2xl);
  font-weight: var(--wm-font-weight-semibold);
  line-height: var(--wm-font-line-tight);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modal-footer {
  border-top: 1px solid var(--wm-color-border);
  border-bottom: 0;
}

.modal-body {
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  padding: var(--wm-space-4);
}

.modal-body p {
  margin: 0 0 var(--wm-space-3);
  color: var(--wm-color-text-muted);
}

.consent-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--wm-space-3);
  margin-top: var(--wm-space-4);
}

.gallery-loading {
  min-height: 220px;
  display: grid;
  place-items: center;
  gap: var(--wm-space-3);
  color: var(--wm-color-text-muted);
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--wm-space-3);
}

.gallery-card {
  min-width: 0;
  display: grid;
  gap: var(--wm-space-2);
  padding: var(--wm-space-2);
  border: 1px solid var(--wm-color-border);
  background: var(--wm-color-surface);
  color: var(--wm-color-text);
  text-align: left;
}

.gallery-card:hover {
  background: var(--wm-color-surface-pressed);
}

.gallery-card.is-selected {
  border-color: var(--wm-color-accent);
  background: var(--wm-color-canvas-muted);
}

.gallery-thumb {
  aspect-ratio: 4 / 3;
  border: 1px solid var(--wm-color-border);
}

.gallery-meta {
  display: grid;
  gap: 2px;
  color: var(--wm-color-text-muted);
  font-size: var(--wm-font-size-xs);
}

.gallery-meta strong {
  color: var(--wm-color-text);
  font-size: var(--wm-font-size-sm);
}

.toast {
  position: fixed;
  right: var(--wm-space-5);
  bottom: var(--wm-space-5);
  z-index: 40;
  max-width: min(360px, calc(100vw - 32px));
  padding: var(--wm-space-3) var(--wm-space-4);
  border: 1px solid var(--wm-color-border);
  background: var(--wm-color-surface-sunken);
  color: var(--wm-color-text-inverse);
  box-shadow: 6px 6px 0 var(--wm-color-border-soft);
}

@media (max-width: 1120px) {
  .battle-grid {
    grid-template-columns: minmax(0, min(100%, var(--media-width, 1280px), calc(var(--battle-media-max-height) * var(--media-ratio, 1.77778))));
  }
}

@media (max-width: 820px) {
  .app-shell,
  .app-shell.sidebar-collapsed {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr);
  }

  .sidebar {
    display: none;
  }

  .main {
    min-height: 0;
    height: 100%;
    grid-template-rows: 52px minmax(0, 1fr);
  }

  .main.has-round-progress {
    grid-template-rows: 52px 7px minmax(0, 1fr);
  }

  .round-progress {
    height: 7px;
  }

  .topbar {
    padding: 0 var(--wm-space-3);
  }

  .language-switch {
    width: 102px;
    height: 32px;
  }

  .topbar-auth {
    display: none;
  }

  .content {
    padding: var(--wm-space-3);
  }

  .compose-shell {
    align-content: start;
    gap: var(--wm-space-2);
  }

  .composer {
    width: 100%;
    grid-template-columns: 1fr;
    box-shadow: none;
  }

  .compose-shell.is-selected .composer {
    width: 100%;
    grid-template-columns: 1fr;
  }

  .image-slot {
    border-right: 0;
    border-bottom: 1px solid var(--wm-color-border);
    aspect-ratio: 16 / 9;
  }

  .compose-shell.is-selected .image-slot {
    width: min(100%, var(--media-width, 100%), calc(42dvh * var(--media-ratio, 1.77778)));
    margin: 0 auto;
    aspect-ratio: var(--media-aspect, 16 / 9);
  }

  .empty-slot {
    padding: var(--wm-space-4);
    gap: var(--wm-space-3);
  }

  .empty-icon {
    width: 42px;
    height: 42px;
  }

  .empty-title {
    max-width: 260px;
    font-size: var(--wm-font-size-lg);
  }

  .action-stack {
    grid-template-rows: auto auto auto auto;
  }

  .action-field {
    min-height: 110px;
    padding: var(--wm-space-3);
    font-size: var(--wm-font-size-lg);
  }

  .compose-shell.is-selected .action-field {
    min-height: 120px;
  }

  .chip-row {
    padding: var(--wm-space-2) var(--wm-space-3);
    gap: var(--wm-space-1);
  }

  .chip {
    min-height: 30px;
    padding-inline: var(--wm-space-2);
    font-size: var(--wm-font-size-sm);
    white-space: normal;
  }

  .composer-footer {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: var(--wm-space-2);
    padding: var(--wm-space-2) var(--wm-space-3);
  }

  .ghost-button,
  .gallery-button,
  .primary-button,
  .secondary-button {
    min-height: 38px;
    padding-inline: var(--wm-space-3);
  }

  .disclosure {
    width: 100%;
    font-size: 10px;
    line-height: var(--wm-font-line-compact);
  }

  .battle-shell {
    --battle-grid-gap: var(--wm-space-2);
    --battle-media-max-height: min(48dvh, 620px);
    width: 100%;
    min-height: 100%;
    align-content: start;
    gap: var(--wm-space-2);
    padding: 0;
  }

  .battle-primary-action {
    height: 40px;
  }

  .battle-question {
    font-size: 24px;
  }

  .battle-action-control {
    height: 40px;
    min-height: 40px;
  }

  .battle-vote-actions {
    gap: var(--wm-space-2);
  }

  .battle-both-bad-button {
    min-height: 36px;
    padding-inline: var(--wm-space-3);
    font-size: 13px;
  }

  .battle-next-button {
    height: 40px;
    min-height: 40px;
  }

  .prompt-row {
    justify-content: stretch;
  }

  .prompt-context {
    width: 100%;
  }

  .prompt-image-thumb {
    --prompt-thumb-width: 50px;
    min-height: 36px;
  }

  .prompt-pill {
    width: 100%;
    min-height: 36px;
    justify-content: flex-start;
    padding: var(--wm-space-2) var(--wm-space-3);
    line-height: var(--wm-font-line-normal);
    overflow-wrap: anywhere;
    white-space: normal;
  }

  .battle-source-preview {
    margin-top: 42px;
  }

  .battle-grid {
    gap: var(--wm-space-2);
  }

  .card-header {
    height: 44px;
    min-height: 44px;
    padding: var(--wm-space-1) var(--wm-space-2);
  }

  .model-copy {
    grid-template-rows: 20px 12px;
  }

  .model-badge {
    width: 30px;
    height: 30px;
  }

  .model-name {
    font-size: var(--wm-font-size-md);
    line-height: 20px;
  }

  .model-org,
  .model-params {
    font-size: 10px;
    line-height: 12px;
    min-height: 12px;
  }

  .model-params {
    display: none;
  }

  .control-button {
    width: 30px;
    height: 30px;
  }

  .generation-progress {
    gap: var(--wm-space-1);
  }

  .generation-progress span {
    padding: 4px;
    font-size: 10px;
  }

  .vote-bar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .vote-button {
    min-height: 44px;
    border-right: 1px solid var(--wm-color-border);
    border-bottom: 1px solid var(--wm-color-border);
    font-size: var(--wm-font-size-sm);
  }

  .vote-button:nth-child(2n) {
    border-right: 0;
  }

  .vote-button:nth-last-child(-n + 2) {
    border-bottom: 0;
  }

  .status-bar {
    grid-template-columns: 1fr;
  }

  .status-bar .vote-button,
  .status-bar .vote-button:nth-child(2n) {
    border-right: 0;
    border-bottom: 1px solid var(--wm-color-border);
  }

  .status-bar .vote-button:last-child {
    border-bottom: 0;
  }

  .leaderboard-shell {
    gap: var(--wm-space-3);
    padding-block: 0;
  }

  .leaderboard-table {
    min-width: 0;
    table-layout: fixed;
  }

  .leaderboard-table th,
  .leaderboard-table td {
    padding: var(--wm-space-2);
  }

  .leaderboard-table th:nth-child(3),
  .leaderboard-table td:nth-child(3),
  .leaderboard-table th:nth-child(6),
  .leaderboard-table td:nth-child(6) {
    display: none;
  }

  .leaderboard-table th:nth-child(1) { width: 9%; }
  .leaderboard-table th:nth-child(2) { width: 43%; }
  .leaderboard-table th:nth-child(4) { width: 16%; }
  .leaderboard-table th:nth-child(5) { width: 16%; }
  .leaderboard-table th:nth-child(7) { width: 16%; }

  .leaderboard-table .model-cell strong,
  .leaderboard-table .model-cell span {
    overflow-wrap: anywhere;
  }

  .page-title {
    flex-direction: column;
    align-items: stretch;
    padding-bottom: var(--wm-space-3);
  }

  .page-title h1 {
    font-size: var(--wm-font-size-2xl);
  }

  .modal-backdrop {
    padding: var(--wm-space-3);
  }

  .modal {
    width: calc(100vw - 24px);
    max-height: calc(100dvh - 24px);
    box-shadow: none;
  }

  .round-completion-modal {
    width: calc(100vw - 24px);
  }

  .round-completion-popup {
    min-height: 112px;
    padding: var(--wm-space-4);
    font-size: var(--wm-font-size-xl);
    box-shadow: 5px 5px 0 var(--wm-color-border);
  }

  .modal-header,
  .modal-footer,
  .modal-body {
    padding: var(--wm-space-3);
  }

  .gallery-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .toast {
    right: var(--wm-space-3);
    bottom: var(--wm-space-3);
  }
}

@media (max-width: 420px) {
  .footer-links {
    grid-template-columns: 1fr;
  }

  .composer-tools {
    gap: var(--wm-space-1);
  }

  .ghost-button span,
  .gallery-button span {
    display: none;
  }

  .char-count {
    font-size: 10px;
  }

  .gallery-grid {
    grid-template-columns: 1fr;
  }
}

/* Ultra-narrow extras keep the content tight without dropping core controls. */
@media (max-width: 340px) {
  .main {
    grid-template-rows: 48px minmax(0, 1fr);
  }

  .main.has-round-progress {
    grid-template-rows: 48px 7px minmax(0, 1fr);
  }

  .content {
    padding: var(--wm-space-2);
  }

  .image-slot {
    aspect-ratio: 16 / 8.6;
  }

  .compose-shell.is-selected .image-slot {
    aspect-ratio: var(--media-aspect, 16 / 9);
  }

  .empty-icon,
  .empty-title {
    display: none;
  }

  .empty-actions {
    width: 100%;
  }

  .action-field {
    min-height: 92px;
    font-size: var(--wm-font-size-md);
  }

  .chip:nth-child(n + 3) {
    display: none;
  }

  .composer-footer {
    grid-template-columns: 1fr auto;
  }

  .primary-button {
    min-width: 72px;
  }

  .prompt-pill {
    font-size: var(--wm-font-size-sm);
  }

  .card-header {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .model-title {
    gap: var(--wm-space-2);
  }

  .model-name {
    font-size: var(--wm-font-size-sm);
  }

  .model-copy {
    grid-template-rows: 20px;
  }

  .model-org,
  .model-params {
    display: block;
    height: 0;
    overflow: hidden;
    visibility: hidden;
  }

  .card-body {
    aspect-ratio: var(--media-aspect, 16 / 8.5);
  }

  .vote-button {
    min-height: 42px;
    gap: 4px;
    padding-inline: 4px;
  }
}

@media (max-width: 820px) {
  .app-shell .main.has-round-progress {
    grid-template-rows: 7px minmax(0, 1fr);
  }

  .app-shell .main.has-round-progress .topbar {
    display: none;
  }

  .app-shell .main.has-round-progress .content:has(> .battle-entry-loading) {
    overflow: hidden;
    padding: 0;
  }

  .app-shell .main.has-round-progress .battle-entry-loading {
    height: 100%;
    min-height: 0;
  }

  .app-shell.view-battle.battle-viewport .content {
    --mobile-bottom-safe-zone-height: clamp(56px, 9vh, 84px);
    --mobile-bottom-safe-zone-height: max(clamp(56px, 9dvh, 84px), env(safe-area-inset-bottom, 0px));
    position: relative;
    display: grid;
    grid-template-rows: minmax(0, 1fr) var(--mobile-bottom-safe-zone-height);
    overflow: hidden;
    padding: 0;
    background: #000;
    overscroll-behavior: none;
    touch-action: none;
  }

  .app-shell.view-battle.battle-viewport .battle-shell,
  .app-shell.view-battle.battle-viewport .mobile-battle-swipe-preview {
    transform: translate3d(0, var(--mobile-battle-swipe-y, 0px), 0);
    transition: var(--mobile-battle-swipe-transition, none);
  }

  .app-shell.view-battle.battle-viewport .content:is(.is-mobile-battle-dragging, .is-mobile-battle-settling) .battle-shell,
  .app-shell.view-battle.battle-viewport .content:is(.is-mobile-battle-dragging, .is-mobile-battle-settling) .mobile-battle-swipe-preview {
    will-change: transform;
  }

  .app-shell.view-battle.battle-viewport .content.is-mobile-battle-dragging .battle-shell {
    pointer-events: none;
    user-select: none;
  }

  .app-shell.view-battle.battle-viewport .battle-shell {
    --battle-grid-gap: 8px;
    grid-row: 1;
    width: 100%;
    height: 100%;
    min-height: 0;
    margin: 0;
    padding: 0;
    grid-template-rows: minmax(0, 1fr);
    align-content: stretch;
    gap: 0;
    overflow: hidden;
  }

  .app-shell.view-battle.battle-viewport .mobile-bottom-safe-zone {
    position: relative;
    z-index: 3;
    grid-row: 2;
    display: block;
    width: 100%;
    height: 100%;
    min-height: 0;
    box-sizing: border-box;
    background: #000;
    color: #fff;
    pointer-events: none;
  }

  .app-shell.view-battle.battle-viewport .mobile-bottom-prompt {
    position: absolute;
    right: 12px;
    bottom: calc(var(--mobile-bottom-safe-zone-height) / 3);
    bottom: max(calc(var(--mobile-bottom-safe-zone-height) / 3), env(safe-area-inset-bottom, 0px));
    left: 12px;
    display: none;
    overflow: hidden;
    color: #fff;
    font-family: var(--wm-font-family-mono);
    font-size: clamp(12px, 3.4vw, 14px);
    font-weight: var(--wm-font-weight-medium);
    line-height: 1.25;
    text-align: left;
    text-overflow: ellipsis;
    overflow-wrap: anywhere;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
  }

  .app-shell.view-battle.battle-viewport .battle-shell.has-floating-prompt + .mobile-bottom-safe-zone .mobile-bottom-prompt {
    display: -webkit-box;
  }

  .app-shell.view-battle.battle-viewport .mobile-bottom-next-cue {
    position: absolute;
    bottom: max(8px, env(safe-area-inset-bottom, 0px));
    left: 50%;
    display: none;
    color: #fff;
    font-family: var(--wm-font-family-sans);
    font-size: 34px;
    font-weight: var(--wm-font-weight-regular);
    line-height: 1;
    transform: translateX(-50%) rotate(90deg);
    transform-origin: center;
  }

  .app-shell.view-battle.battle-viewport .mobile-bottom-safe-zone.is-vote-complete .mobile-bottom-next-cue {
    display: block;
    animation: wm-mobile-next-cue 1.2s ease-in-out infinite;
  }

  .app-shell.view-battle.battle-viewport .content:is(.is-mobile-battle-dragging, .is-mobile-battle-settling) :is(.mobile-bottom-prompt, .mobile-bottom-next-cue) {
    opacity: 0;
  }

  .app-shell.view-battle.battle-viewport .mobile-battle-swipe-preview {
    position: absolute;
    top: 100%;
    right: 0;
    left: 0;
    z-index: 2;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 32px;
    overflow: hidden;
    border-top: 1px solid var(--wm-color-border);
    background: #000;
    color: #fff;
    pointer-events: none;
  }

  .app-shell.view-battle.battle-viewport .mobile-battle-swipe-next {
    font-family: var(--wm-font-family-mono);
    font-size: clamp(18px, 5vw, 24px);
    font-weight: var(--wm-font-weight-semibold);
    letter-spacing: 0.04em;
  }

  .app-shell.view-battle.battle-viewport .prompt-row {
    display: none;
  }

  .app-shell.view-battle.battle-viewport .battle-stage {
    grid-row: 1;
    grid-column: 1;
    width: 100%;
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }

  .app-shell.view-battle.battle-viewport .battle-source-preview {
    width: 100%;
    height: 100%;
    max-height: none;
    margin: 0;
    align-self: center;
    aspect-ratio: auto;
  }

  .app-shell.view-battle.battle-viewport .battle-grid {
    box-sizing: border-box;
    width: 100%;
    height: 100%;
    min-height: 0;
    margin-top: 0;
    padding: 0;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: repeat(2, minmax(0, 1fr));
    align-items: stretch;
    justify-items: stretch;
    gap: var(--battle-grid-gap);
  }

  .app-shell.view-battle.battle-viewport .battle-card {
    width: 100%;
    height: 100%;
    min-height: 0;
    max-width: none;
    grid-template-rows: 44px minmax(0, 1fr);
  }

  .app-shell.view-battle.battle-viewport .card-body {
    min-height: 0;
    aspect-ratio: auto;
  }

  .app-shell.view-battle.battle-viewport .battle-primary-action {
    position: absolute;
    z-index: 6;
    top: 50%;
    left: 50%;
    width: min(calc(100vw - 32px), 304px);
    height: 44px;
    pointer-events: none;
    transform: translate(-50%, -100%);
  }

  .app-shell.view-battle.battle-viewport .battle-primary-action.is-vote-action {
    transform: translate(-50%, -55%);
  }

  .app-shell.view-battle.battle-viewport .battle-primary-action.is-next-action {
    transform: translate(-50%, -55%);
  }

  .app-shell.view-battle.battle-viewport .battle-action-control {
    width: 100%;
    height: 44px;
    min-height: 44px;
    pointer-events: auto;
  }

  .app-shell.view-battle.battle-viewport .battle-vote-actions {
    position: relative;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    pointer-events: none;
  }

  .app-shell.view-battle.battle-viewport .battle-question-anchor {
    --mobile-both-bad-width: 56px;
    position: absolute;
    top: 2px;
    left: 50%;
    width: max-content;
    height: 40px;
    display: block;
    transform: translateX(-50%);
  }

  .app-shell.view-battle.battle-viewport .battle-vote-panel {
    position: absolute;
    z-index: 0;
    top: 0;
    right: -64px;
    bottom: 0;
    left: 0;
    display: block;
    border: 2px solid var(--wm-color-border);
    background: var(--wm-color-surface);
    box-shadow: 4px 4px 0 color-mix(in srgb, var(--wm-color-border) 35%, transparent);
    pointer-events: none;
  }

  .app-shell.view-battle.battle-viewport .battle-question {
    position: relative;
    z-index: 1;
    box-sizing: border-box;
    height: 40px;
    padding: 0 4px;
    border: 0;
    background: transparent;
    box-shadow: none;
    font-size: clamp(18px, 5.6vw, 24px);
    white-space: nowrap;
  }

  .app-shell.view-battle.battle-viewport .battle-both-bad-button {
    position: absolute;
    z-index: 1;
    top: 50%;
    left: calc(100% + 4px);
    width: var(--mobile-both-bad-width);
    height: 24px;
    min-height: 24px;
    padding-inline: 3px;
    font-size: 11px;
    white-space: nowrap;
    transform: translateY(-50%);
    pointer-events: auto;
  }

  .app-shell.view-battle.battle-viewport .battle-next-action {
    width: max-content;
    height: 32px;
    min-height: 32px;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    transform: translateY(-6px);
  }

  .app-shell.view-battle.battle-viewport .battle-next-button {
    width: auto;
    height: 32px;
    min-height: 32px;
    padding-inline: 10px;
    font-size: 13px;
  }
}

@keyframes wm-mobile-next-cue {
  0%,
  100% {
    transform: translate(-50%, -2px) rotate(90deg);
  }

  50% {
    transform: translate(-50%, 4px) rotate(90deg);
  }
}

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

/* Login modal (Google + email-code) */
.login-modal {
  width: 100%;
  max-width: 420px;
}
.login-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.login-input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: 10px;
  font: inherit;
  box-sizing: border-box;
}
.login-input:focus {
  outline: 2px solid rgba(0, 0, 0, 0.5);
  outline-offset: 1px;
}
.login-code {
  letter-spacing: 6px;
  text-align: center;
  font-size: 18px;
}
.login-submit {
  width: 100%;
  justify-content: center;
}
.login-text-button {
  background: none;
  border: none;
  color: rgba(0, 0, 0, 0.6);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  text-decoration: underline;
  padding: 4px;
}
.login-info {
  margin: 0;
  font-size: 14px;
  color: rgba(0, 0, 0, 0.7);
}
.login-error {
  margin: 0;
  font-size: 14px;
  color: #b3261e;
}
.login-footer {
  justify-content: center;
}
.login-terms {
  font-size: 12px;
  color: rgba(0, 0, 0, 0.55);
  text-align: center;
}
.login-terms .consent-link {
  font-size: 12px;
}

/* ============================================================================
   Video Arena gallery homepage — masonry of (image + prompt) task cards.
   ============================================================================ */
.gallery-page {
  height: 100%;
  overflow-y: auto;
  padding: var(--wm-space-4) var(--wm-space-6) var(--wm-space-8);
}
/* Shortest-column masonry: JS distributes tiles into these flex columns, so they
   pack tight, stay balanced, and never reflow as images load. */
.gallery-grid {
  display: flex;
  align-items: flex-start;
  gap: var(--wm-space-3);
}
.gallery-col {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--wm-space-3);
}

/* Tight masonry: full-bleed image + flush gray prompt strip, no card box. */
.gallery-tile {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: var(--wm-radius-sm, 6px);
  background: transparent;
  color: var(--wm-color-text);
  cursor: pointer;
  overflow: hidden;
  transition: box-shadow var(--wm-motion-duration-fast, 140ms) ease, transform var(--wm-motion-duration-fast, 140ms) ease;
}
.gallery-tile:hover { box-shadow: var(--wm-shadow-panel, 0 18px 48px rgba(9, 9, 9, 0.18)); }
.gallery-tile:focus-visible { outline: none; box-shadow: var(--wm-shadow-focus); }

.gallery-tile-media {
  position: relative;
  display: block;
  width: 100%;
  overflow: hidden;
  background: var(--wm-color-border-soft, #eee);
}
.gallery-tile-img {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  transition: transform 240ms ease;
}
.gallery-tile:hover .gallery-tile-img,
.gallery-tile:focus-visible .gallery-tile-img { transform: scale(1.05); }
.gallery-tile-mask {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(9, 9, 9, 0);
  opacity: 0;
  transition: opacity 160ms ease, background 160ms ease;
}
.gallery-tile:hover .gallery-tile-mask,
.gallery-tile:focus-visible .gallery-tile-mask {
  opacity: 1;
  background: rgba(9, 9, 9, 0.42);
}
.gallery-tile-start {
  color: #fff;
  font-weight: var(--wm-font-weight-bold, 700);
  font-size: var(--wm-font-size-lg, 1.3rem);
  letter-spacing: 0.02em;
}
.gallery-tile-foot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--wm-space-1, 4px);
  padding: var(--wm-space-3) var(--wm-space-4) var(--wm-space-4);
  background: color-mix(in srgb, var(--wm-color-canvas, #faf8f2) 90%, var(--wm-color-text, #111) 8%);
}
.gallery-tile-plus {
  font-size: 1.25rem;
  line-height: 1;
  font-weight: 700;
  color: var(--wm-color-text-muted, #5b5850);
}
.gallery-tile-prompt {
  display: block;
  text-align: center;
  font-weight: var(--wm-font-weight-medium, 550);
  line-height: 1.3;
}

.create-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--wm-space-2);
  min-height: 168px;
  border-style: dashed;
  background: color-mix(in srgb, var(--wm-color-surface) 88%, var(--wm-color-accent) 12%);
}
.create-tile-plus { font-size: 2rem; line-height: 1; font-weight: 700; }
.create-tile-label { font-weight: 600; }

.gallery-tile.is-skeleton { cursor: default; }
.gallery-tile.is-skeleton .gallery-tile-media {
  background: var(--wm-color-border-soft, #e8e6e1);
  animation: gallery-skeleton-pulse 1.4s ease-in-out infinite;
}
@keyframes gallery-skeleton-pulse { 0%, 100% { opacity: 0.55; } 50% { opacity: 0.9; } }
.gallery-empty {
  padding: var(--wm-space-6) var(--wm-space-4);
  color: var(--wm-color-text-muted, #5b5850);
}

.shuffle-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--wm-color-border);
  border-radius: var(--wm-radius-xs, 8px);
  background: var(--wm-color-surface);
  color: var(--wm-color-text);
  cursor: pointer;
  transition: background var(--wm-motion-duration-fast, 140ms) ease;
}
.shuffle-button:hover { background: color-mix(in srgb, var(--wm-color-surface) 88%, var(--wm-color-accent) 12%); }
.shuffle-button:focus-visible { outline: none; box-shadow: var(--wm-shadow-focus); }

/* Owner publish/unpublish control on a finished battle. */
.owner-visibility {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--wm-space-2);
  width: min(100%, 480px);
  margin: var(--wm-space-3) auto 0;
  padding: var(--wm-space-3) var(--wm-space-4);
  border: 1px solid var(--wm-color-border);
  border-radius: var(--wm-radius-xs, 8px);
  background: var(--wm-color-surface);
}
.owner-visibility-label {
  font-size: var(--wm-font-size-sm, 0.9rem);
  color: var(--wm-color-text-muted, #5b5850);
  text-align: center;
}
.visibility-toggle {
  box-sizing: border-box;
  max-width: 100%;
  padding: var(--wm-space-2) var(--wm-space-4);
  border: 1px solid var(--wm-color-border);
  border-radius: var(--wm-radius-xs, 8px);
  background: var(--wm-color-accent);
  color: var(--wm-color-text-inverse, #fff);
  font-weight: var(--wm-font-weight-medium, 550);
  cursor: pointer;
}
.visibility-toggle.is-public {
  background: var(--wm-color-surface);
  color: var(--wm-color-text);
}
.visibility-toggle:disabled { opacity: 0.6; cursor: default; }
.visibility-toggle:focus-visible { outline: none; box-shadow: var(--wm-shadow-focus); }

@media (prefers-reduced-motion: reduce) {
  .battle-shell.is-media-transitioning .battle-grid,
  .battle-shell:is(.is-media-prompt, .is-media-transitioning) .prompt-row,
  .battle-shell.is-media-transitioning .prompt-image-thumb,
  .battle-shell.is-media-transitioning .battle-source-pane,
  .battle-primary-action {
    animation-duration: 1ms !important;
    transition-duration: 1ms !important;
  }

  .gallery-tile.is-skeleton .gallery-tile-media,
  .spinner {
    animation: none;
  }
}
