@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

@keyframes pop-in {
  0% { transform: translate(-50%, -50%) scale(0.6); opacity: 0; }
  60% { transform: translate(-50%, -50%) scale(1.08); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

body {
  background: #0b0b0f;
  color: #e8e8e8;
  font-family: "Courier New", monospace;
  text-align: center;
  margin: 0;
  padding: clamp(8px, 4vw, 24px);
  background-image: radial-gradient(circle at 50% 0%, #1a1330 0%, #0b0b0f 70%);
}

h1 {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25em;
  font-family: "Bungee", "Courier New", monospace;
  font-size: clamp(28px, 8vw, 64px);
  letter-spacing: 0.08em;
  margin-bottom: 16px;
  color: #3ddc3d;
  text-shadow: 0 0 8px #3ddc3d99, 0 0 24px #3ddc3d66, 0 0 48px #3ddc3d33;
}

#logo-mark {
  height: 1em;
  width: auto;
  image-rendering: pixelated;
  filter: drop-shadow(0 0 8px #3ddc3d99);
}

#setup {
  position: relative;
}

#setup-bg {
  /* Fixed to the viewport, not #setup's own box, so it reads as a full-page
     backdrop behind the title/progress-bar/form together, not a video
     confined to one card. Lives inside #setup purely so it hides for free
     when #setup gets .hidden at fight start - display:none on an ancestor
     still hides a position:fixed descendant. */
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  object-fit: cover;
  z-index: 0;
  /* Desaturate/darken at the source too, not just the overlay, so it reads
     as part of this site's dark palette instead of a bright video dropped
     on top of it. */
  filter: brightness(0.55) saturate(0.85);
}

#setup-content {
  position: relative;
  z-index: 1;
  max-width: min(96vw, 1400px);
  margin: 0 auto;
  padding: 40px 20px;
  background: linear-gradient(180deg, #0b0b0fcc 0%, #0b0b0f99 40%, #0b0b0fcc 100%);
  border-radius: 4px;
}

.hype {
  font-family: "Bungee", "Courier New", monospace;
  font-size: clamp(16px, 2.4vw, 24px);
  letter-spacing: 0.04em;
  color: #ffe066;
  text-shadow: 0 0 8px #ffe06699;
  margin: 0 0 20px;
}

.setup-form {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 10px 4px;
}

.setup-form label {
  font-size: 15px;
  letter-spacing: 0.05em;
}

#setup input {
  width: 80px;
  margin: 0 8px;
  background: #1a1a22;
  color: #fff;
  border: 1px solid #444;
  padding: 6px;
  font-family: inherit;
  font-size: 15px;
}

#setup button {
  padding: 10px 24px;
  background: #3ddc3d;
  color: #0b0b0f;
  border: none;
  cursor: pointer;
  font-family: "Bungee", "Courier New", monospace;
  font-size: 16px;
  letter-spacing: 0.1em;
  box-shadow: 0 0 0 2px #0b0b0f, 0 0 12px #3ddc3d88;
  transition: transform 0.1s ease-out;
}

#setup button:hover {
  transform: scale(1.05);
}

#setup button:disabled {
  background: #444;
  box-shadow: none;
  cursor: default;
  transform: none;
}

#connect-wallet-btn {
  padding: 12px 26px;
  background: transparent;
  color: #3ddc3d;
  border: 2px solid #3ddc3d;
  cursor: pointer;
  font-family: "Bungee", "Courier New", monospace;
  font-size: 15px;
  letter-spacing: 0.03em;
  box-shadow: 0 0 12px #3ddc3d44;
  transition: transform 0.1s ease-out;
}

#connect-wallet-btn:hover {
  transform: scale(1.03);
  background: #3ddc3d22;
}

#connect-wallet-btn:disabled {
  opacity: 0.5;
  cursor: default;
  transform: none;
}

#wallet-status {
  font-size: 15px;
  color: #d0d0d8;
  min-height: 1.2em;
}

#setup-status {
  font-size: 15px;
  color: #d0d0d8;
}

/* OpenSea's own brand blue rather than the site's green - reads as a
   distinct external "go buy one" action, not another same-page control. */
#opensea-btn {
  display: inline-block;
  margin-top: 4px;
  padding: 8px 20px;
  background: transparent;
  color: #2081e2;
  border: 2px solid #2081e2;
  cursor: pointer;
  font-weight: bold;
  font-family: inherit;
  font-size: 13px;
  letter-spacing: 0.05em;
  text-decoration: none;
  box-shadow: 0 0 12px #2081e244;
  transition: transform 0.1s ease-out;
}

#opensea-btn:hover {
  transform: scale(1.03);
  background: #2081e222;
}

#character-select {
  margin-top: 12px;
}

.select-title {
  font-family: "Bungee", "Courier New", monospace;
  font-size: 15px;
  letter-spacing: 0.12em;
  color: #ffe066;
  text-shadow: 0 0 6px #ffe06699;
  margin-bottom: 10px;
}

#character-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 10px;
  max-height: 320px;
  overflow-y: auto;
  padding: 4px;
}

.grid-loading {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 24px 0;
}

.grid-loading p {
  font-size: 13px;
  letter-spacing: 0.1em;
  color: #ffe066;
  text-shadow: 0 0 6px #ffe06699;
}

.spinner {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 4px solid #ffe06633;
  border-top-color: #3ddc3d;
  border-right-color: #ffe066;
  animation: spin 0.8s linear infinite;
  box-shadow: 0 0 12px #3ddc3d44;
}

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

.character-card {
  position: relative;
  background: #1a1a22;
  border: 2px solid #444;
  border-radius: 4px;
  padding: 6px;
  max-width: 100px;
  cursor: pointer;
  transition: transform 0.1s ease-out, border-color 0.1s;
  text-align: center;
}

.character-card:hover {
  border-color: #3ddc3d;
  transform: scale(1.05);
}

.character-card img {
  width: 100%;
  aspect-ratio: 1;
  image-rendering: pixelated;
  border-radius: 3px;
  background: #0b0b0f;
}

.character-card .card-label {
  font-size: 12px;
  font-weight: bold;
  margin-top: 4px;
  color: #e8e8e8;
  letter-spacing: 0.03em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-badge {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  background: #0b0b0fcc;
  border: 1px solid #3ddc3d88;
  border-radius: 50%;
  box-shadow: 0 0 6px #3ddc3d55;
  cursor: help;
}

/* A single shared node appended straight to <body> (see attachBadgeTooltip
   in main.js), not nested inside any card - position: fixed is supposed to
   escape all ancestor clipping/scrolling, but .character-card:hover applies
   its own transform: scale(), and CSS hover state bubbles to ancestors, so
   while a badge is hovered its parent card is ALSO :hover and gets
   transformed - which per spec makes that card the containing block for
   any position:fixed descendant instead of the viewport, trapping the
   tooltip right back inside it (and behind the grid's own overflow clip).
   Living outside every card entirely sidesteps that. */
#badge-tooltip {
  position: fixed;
  width: max-content;
  max-width: 180px;
  background: #0b0b0ff2;
  border: 1px solid #3ddc3d88;
  border-radius: 4px;
  padding: 8px 10px;
  font-size: 11px;
  line-height: 1.5;
  color: #e8e8e8;
  text-align: left;
  white-space: pre-line;
  box-shadow: 0 0 16px #000c;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.12s ease-out;
  z-index: 9999;
  pointer-events: none;
}

#badge-tooltip.visible {
  opacity: 1;
  visibility: visible;
}

.hidden {
  display: none !important;
}

#arena {
  max-width: min(96vw, 1500px);
  margin: 16px auto;
  position: relative;
}

.hud {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 4px;
}

.bars {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.healthbar,
.powerbar {
  height: 22px;
  background: #161620;
  border: 2px solid #555;
  box-shadow: inset 0 0 0 1px #000;
}

.powerbar {
  height: 11px;
}

.health-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(#5cf25c, #2fae2f);
  transition: width 0.15s ease-out;
}

.power-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(#ffe066, #d9a300);
  transition: width 0.1s linear;
}

.power-fill.power-ready {
  animation: pulse 0.5s infinite;
  box-shadow: 0 0 8px #ffd700, 0 0 16px #ffd700aa;
}

#p1-health,
#p1-power {
  margin-left: auto;
}

#timer {
  width: 60px;
  font-family: "Bungee", "Courier New", monospace;
  font-size: 30px;
  color: #ffe066;
  text-shadow: 0 0 6px #ffe06699;
}

.names {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 2px 8px;
  font-size: 16px;
  opacity: 0.9;
  margin-bottom: 4px;
  letter-spacing: 0.05em;
}

#round-info {
  font-size: 14px;
  color: #ffe066;
  opacity: 0.9;
  letter-spacing: 0.1em;
}

#canvas-wrap {
  position: relative;
}

canvas {
  background: #1b1330;
  border: 2px solid #444;
  box-shadow: 0 0 0 4px #0b0b0f, 0 0 24px #3ddc3d22;
  image-rendering: pixelated;
  width: 100%;
  max-width: min(96vw, 1500px);
  aspect-ratio: 800 / 360;
  display: block;
}

/* Positioned relative to #canvas-wrap, which matches the canvas's own
   bounds exactly - percentages here line up with the 800x360 game-world
   coordinates fighters are drawn in, so this tracks their head height
   instead of floating relative to the whole arena (HUD included). */
.taunt {
  position: absolute;
  top: 34%;
  background: #fff;
  color: #000;
  padding: 6px 10px;
  border-radius: 6px;
  max-width: 240px;
  font-size: 14px;
  box-shadow: 0 2px 10px #0008;
}

#taunt-p1 {
  left: 10%;
}

#taunt-p2 {
  right: 10%;
}

#countdown {
  position: absolute;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 64px;
  font-weight: bold;
  color: #ffe066;
  text-shadow: 0 0 12px #ffe066cc, 0 0 30px #ffe06666;
  animation: pop-in 0.25s ease-out;
}

#result {
  position: absolute;
  top: 12%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation: pop-in 0.3s ease-out;
  max-width: 90%;
  text-align: center;
}

#result-title {
  font-family: "Bungee", "Courier New", monospace;
  font-size: clamp(28px, 5vw, 48px);
  font-weight: bold;
  letter-spacing: 0.06em;
  color: #ffe066;
  text-shadow: 0 0 12px #ffe066cc, 0 0 30px #ffe06666;
}

#result-quote {
  font-size: 16px;
  font-style: italic;
  color: #ffe066;
  opacity: 0.8;
  margin-top: 6px;
  letter-spacing: normal;
  text-shadow: 0 0 8px #ffe06699;
}

.controls {
  font-size: 15px;
  color: #b8b8c2;
  margin-top: 10px;
}

#build-footer {
  font-size: 12px;
  color: #9a9aa4;
  margin: 24px 0 8px;
  letter-spacing: 0.03em;
}

#build-footer a {
  color: #3ddc3d;
  text-decoration: underline;
}

#build-footer:empty {
  display: none;
}

#cheat-toast {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  font-family: "Bungee", "Courier New", monospace;
  font-size: 16px;
  letter-spacing: 0.08em;
  color: #ff3b3b;
  background: #0b0b0ff2;
  border: 2px solid #ff3b3b;
  padding: 10px 20px;
  box-shadow: 0 0 20px #ff3b3b88;
  animation: pop-in 0.25s ease-out;
  pointer-events: none;
}
