:root {
  --bg: #140b24;
  --bg2: #1d1033;
  --panel: #241540;
  --panel2: #2e1b50;
  --edge: #07030f;
  --text: #f4eaff;
  --dim: #a894c9;
  --red: #ff4d5e; --yellow: #ffd84d; --green: #4dff88; --cyan: #3bd9ff; --blue: #5b7bff; --magenta: #ff4dd2;
  --rainbow: linear-gradient(90deg, #ff4d5e, #ff9f1c, #ffd84d, #4dff88, #3bd9ff, #5b7bff, #c24dff, #ff4d5e);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  background-image:
    linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px);
  background-size: 16px 16px;
  color: var(--text);
  font-family: 'Press Start 2P', ui-monospace, Consolas, monospace;
  font-size: 10px;
  line-height: 1.7;
  min-height: 100vh;
  image-rendering: pixelated;
}
button, input, select { font: inherit; color: inherit; }
h2, h3 { margin: 0 0 12px; font-weight: normal; }
h2 { font-size: 13px; }
h3 { font-size: 11px; color: var(--dim); }
p { margin: 0 0 10px; }
.dim { color: var(--dim); }
.small { font-size: 8px; }

/* header */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 14px 16px 6px; max-width: 980px; margin: 0 auto; }
.logo {
  margin: 0; font-size: 18px; letter-spacing: 1px; font-weight: normal;
  background: var(--rainbow); background-size: 200% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: slide 4s steps(16) infinite;
  text-shadow: none; filter: drop-shadow(3px 3px 0 #000);
}
@keyframes slide { to { background-position: 200% 0; } }
.hud { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: 9px; }
.coin::before { content: ''; display: inline-block; width: 10px; height: 10px; background: var(--yellow); box-shadow: inset -3px -3px 0 #c9a21c, 0 0 0 2px #000; margin-right: 6px; vertical-align: -1px; }

/* nav */
.nav[hidden] { display: none; }   /* the logged-out login page must not show the menu */
.nav { display: flex; gap: 8px; flex-wrap: wrap; padding: 8px 16px; max-width: 980px; margin: 0 auto; }
.nav button { flex: 1 1 auto; }
.view { max-width: 980px; margin: 0 auto; padding: 8px 16px 60px; }

/* panels and buttons */
.panel {
  background: var(--panel); border: 4px solid var(--edge);
  box-shadow: inset 4px 4px 0 var(--panel2), inset -4px -4px 0 #170c2b, 6px 6px 0 #000;
  padding: 16px; margin-bottom: 18px;
}
.btn {
  background: #3d2870; border: 4px solid var(--edge); padding: 10px 14px; cursor: pointer;
  box-shadow: inset 3px 3px 0 #5b3fa0, inset -3px -3px 0 #2a1950, 0 4px 0 #000;
  text-transform: uppercase; letter-spacing: .5px; font-size: 9px;
}
.btn:hover { background: #4a3288; }
.btn:active { transform: translateY(4px); box-shadow: inset 3px 3px 0 #5b3fa0, inset -3px -3px 0 #2a1950, 0 0 0 #000; }
.btn[disabled] { opacity: .45; cursor: not-allowed; transform: none; }
.btn.on { background: #ff9f1c; color: #1a0d00; box-shadow: inset 3px 3px 0 #ffc766, inset -3px -3px 0 #c97300, 0 4px 0 #000; }
.btn.go { background: #24a85a; box-shadow: inset 3px 3px 0 #4de08b, inset -3px -3px 0 #137a3c, 0 4px 0 #000; }
.btn.danger { background: #a8243a; box-shadow: inset 3px 3px 0 #e04d66, inset -3px -3px 0 #7a1327, 0 4px 0 #000; }
.btn.big { padding: 14px 20px; font-size: 11px; }
.btn.small { padding: 6px 9px; font-size: 8px; }
input[type=text], input[type=password], select {
  background: #120a22; border: 4px solid var(--edge); padding: 9px 10px; min-width: 0;
  box-shadow: inset 3px 3px 0 #000;
}
input[type=text]:focus, input[type=password]:focus, select:focus { outline: 2px solid var(--cyan); outline-offset: 0; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1 1 160px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 14px; }
.cols { display: grid; grid-template-columns: minmax(180px, 260px) 1fr; gap: 18px; }
@media (max-width: 640px) { .cols { grid-template-columns: 1fr; } .logo { font-size: 14px; } }

/* sprites */
/* Each monster has its own hidden movement traits, set as CSS variables by sprite.js:
   --wx/--wy movement vector (direction and size), --wd cycle length (speed), --wdelay phase offset. */
.sprite { image-rendering: pixelated; display: block; animation: bob var(--wd, 1s) steps(1) infinite; animation-delay: var(--wdelay, 0s); }
.sprite.prism { animation: bob var(--wd, 1s) steps(1) infinite, hue 3s linear infinite; animation-delay: var(--wdelay, 0s), 0s; }
/* sprites are block elements, so center them explicitly inside centered text containers */
.card .sprite, .fighter .sprite, .throne .sprite { margin-left: auto; margin-right: auto; }
.sprite.void { filter: drop-shadow(0 0 6px rgba(150, 120, 255, .55)); }
.sprite.flip { transform: scaleX(-1); }
/* transform does not affect layout, so content below the sprite stays still */
@keyframes bob {
  0%   { transform: translate(0, 0); }
  25%  { transform: translate(var(--wx, 0px), var(--wy, -4px)); }
  50%  { transform: translate(0, 0); }
  75%  { transform: translate(calc(var(--wx, 0px) * -0.5), calc(var(--wy, -4px) * -0.5)); }
  100% { transform: translate(0, 0); }
}
@keyframes hue { to { filter: hue-rotate(360deg); } }
.stage { display: flex; justify-content: center; padding: 26px 0 20px; background: radial-gradient(circle at 50% 70%, #3a2466 0, transparent 70%); }

/* cards */
.card { cursor: pointer; text-align: center; padding: 12px 8px 14px; position: relative; }
.card:hover { outline: 4px solid var(--yellow); outline-offset: -4px; }
.card.sel { outline: 4px solid var(--cyan); outline-offset: -4px; }
.card .nm { margin-top: 8px; font-size: 10px; }
.card .meta { font-size: 8px; color: var(--dim); }
.card.empty { cursor: default; opacity: .4; display: flex; align-items: center; justify-content: center; min-height: 190px; border-style: dashed; }
.card.empty:hover { outline: none; }
.badge-ret { position: absolute; top: 8px; right: 8px; background: #6d6d7d; color: #fff; font-size: 7px; padding: 3px 5px; }

/* chips */
.chip { display: inline-block; padding: 2px 6px; border: 2px solid #000; font-size: 8px; color: #120a22; background: var(--c, #888); text-transform: uppercase; }
.chip.t7 { background: var(--rainbow); }
.chip.t8 { background: #0b0614; color: #c9b8ff; border-color: #8a6bff; }
.rar0 { color: #b8b8c8; } .rar1 { color: #7dff9a; } .rar2 { color: #6fb7ff; } .rar3 { color: #d98cff; }
.rar4 { background: var(--rainbow); background-size: 200% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: slide 3s steps(12) infinite; }

/* stats */
.stat { display: grid; grid-template-columns: 74px 1fr 40px 18px; gap: 8px; align-items: center; margin-bottom: 8px; font-size: 8px; }
.bar { height: 12px; background: #120a22; border: 2px solid #000; position: relative; }
.bar > i { display: block; height: 100%; background: var(--c); box-shadow: inset 0 3px 0 rgba(255,255,255,.3); }
.apt { text-align: center; color: var(--yellow); }
.swatch { display: inline-block; width: 28px; height: 28px; border: 3px solid #000; vertical-align: middle; box-shadow: 3px 3px 0 #000; }
.swatch.lg { width: 56px; height: 56px; }

/* scan */
.cam { position: relative; background: #000; border: 4px solid var(--edge); min-height: 150px; display: flex; align-items: center; justify-content: center; margin-bottom: 12px; overflow: hidden; }
.cam video { width: 100%; max-height: 320px; display: block; object-fit: cover; }
.cam .reticle { position: absolute; inset: 22% 12%; border: 3px dashed rgba(255,255,255,.7); pointer-events: none; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }

/* modal */
.modal { position: fixed; inset: 0; background: rgba(5, 2, 12, .86); display: flex; align-items: center; justify-content: center; padding: 14px; z-index: 20; overflow: auto; }
.modal[hidden] { display: none; }
.modal .panel { max-width: 640px; width: 100%; margin: 0; max-height: 96vh; overflow: auto; }
.pop { animation: pop .6s steps(6) 1; }
@keyframes pop { 0% { transform: scale(.2); filter: brightness(6); } 60% { transform: scale(1.15); } 100% { transform: scale(1); filter: none; } }
.flash { animation: flash .35s steps(3) 1; }
@keyframes flash { 0%, 100% { filter: none; } 50% { filter: brightness(3) saturate(0); } }
.lungeL { animation: lungeL .3s steps(3) 1; } .lungeR { animation: lungeR .3s steps(3) 1; }
@keyframes lungeL { 50% { transform: translateX(40px); } }
@keyframes lungeR { 50% { transform: translateX(-40px); } }

/* battle */
.arena { display: flex; justify-content: space-between; align-items: flex-end; gap: 8px; margin-bottom: 10px; }
.fighter { flex: 1; text-align: center; min-width: 0; }
.hp { height: 14px; background: #120a22; border: 3px solid #000; margin: 6px 0 2px; }
.hp > i { display: block; height: 100%; background: var(--green); transition: width .4s steps(8); }
.log { background: #0d0618; border: 4px solid var(--edge); padding: 10px; height: 150px; overflow: auto; font-size: 8px; line-height: 1.9; }
.log .me { color: var(--cyan); } .log .foe { color: var(--magenta); }
.banner { text-align: center; font-size: 16px; margin: 12px 0; }
.banner.win { color: var(--yellow); } .banner.lose { color: var(--red); }

/* splice mixer */
.mixer { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; margin: 12px 0; text-align: center; }
.op { font-size: 18px; color: var(--dim); }
.mixbar { height: 22px; border: 3px solid #000; margin: 8px 0; box-shadow: 3px 3px 0 #000; }

/* toast */
.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); background: #000; border: 4px solid var(--yellow); padding: 12px 16px; z-index: 40; max-width: 92vw; font-size: 9px; }
.toast.err { border-color: var(--red); }
.toast[hidden] { display: none; }

/* the "?" in a circle next to a signature move */
.qmark {
  display: inline-block; width: 18px; height: 18px; margin-left: 8px; padding: 0; vertical-align: middle;
  font-size: 9px; line-height: 14px; text-align: center; cursor: pointer;
  color: var(--yellow); background: #120a22; border: 2px solid var(--yellow); border-radius: 50%;
}
.qmark:hover { background: var(--yellow); color: #120a22; }

/* a cup opponent: one compact line, optionally opened up to its full stat block */
.oppentry { padding: 8px 0; border-bottom: 2px dashed #3b2468; }
.oppentry:last-child { border-bottom: 0; }
.oppdetail { margin-top: 10px; padding: 10px 12px; background: rgba(0, 0, 0, .25); border: 3px solid #07030f; }

/* shown in place of the Fight button when a Chromie is too tired for the cups */
.tiredtag {
  display: inline-block; max-width: 190px; text-align: center; font-size: 8px; line-height: 1.5; padding: 6px 8px;
  color: var(--yellow); background: rgba(255, 159, 28, .12); border: 3px dashed #ff9f1c; box-shadow: 3px 3px 0 #000;
}

/* thrones and hall of fame */
.thrones { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 12px; }
.throne { text-align: center; padding: 34px 8px 14px; margin: 0; position: relative; }
.throne .nm { margin-top: 6px; }
.seatno { position: absolute; top: 8px; left: 8px; background: #8a6bff; color: #120a22; font-size: 7px; padding: 3px 5px; }
.throne.mineseat { outline: 4px solid var(--yellow); outline-offset: -4px; }
.throne.emptyseat { opacity: .85; border-style: dashed; }
.hallrow { padding: 8px 0; border-bottom: 2px dashed #3b2468; }
.hallrow:last-child { border-bottom: 0; }
.hallrow.mine { background: rgba(255, 216, 77, .08); }
.rank { width: 30px; text-align: center; font-size: 12px; color: var(--dim); }
.rank.r1 { color: #ffd84d; } .rank.r2 { color: #d8d8e8; } .rank.r3 { color: #ff9f5a; }
.halltotal { text-align: right; min-width: 80px; }
.hallrow canvas.sprite { margin: 0; }

/* dye flyout and dye box */
.flyout { position: fixed; inset: 0; z-index: 30; background: rgba(5, 2, 12, .6); }
.flyout[hidden] { display: none; }
.flyout .drawer {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(440px, 94vw); overflow: auto;
  background: var(--panel); border-left: 4px solid var(--edge); box-shadow: inset 4px 0 0 var(--panel2), -6px 0 0 #000;
  padding: 18px; animation: slidein .28s steps(7) 1;
}
@keyframes slidein { from { transform: translateX(100%); } to { transform: translateX(0); } }
.dyegrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-top: 12px; }
.dyetile {
  display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 12px 8px; cursor: pointer;
  background: #1d1033; border: 4px solid var(--edge); box-shadow: inset 3px 3px 0 #2e1b50, 0 4px 0 #000; font-size: 9px;
}
.dyetile:hover { outline: 4px solid var(--yellow); outline-offset: -4px; }
.dyetile.sel { outline: 4px solid var(--cyan); outline-offset: -4px; }
.dyesq { display: block; width: 72px; height: 72px; border: 3px solid #000; box-shadow: 3px 3px 0 #000; }
.dyebox {
  position: relative; width: 150px; height: 150px; border: 4px solid #000; box-shadow: 4px 4px 0 #000;
  display: flex; align-items: flex-end; justify-content: center; padding-bottom: 10px; flex: 0 0 auto;
}
.dyebox .btn { white-space: normal; text-align: center; line-height: 1.4; max-width: 128px; }

/* help page */
.help .panel { scroll-margin-top: 12px; }
.help h3 { margin-top: 16px; color: var(--cyan); }
ul.hl, ol.hl { margin: 0 0 12px; padding-left: 20px; }
.hl li { margin-bottom: 9px; }
.hl ul.hl { margin-top: 8px; }
.help .callout { border-left: 4px solid var(--yellow); padding-left: 10px; background: rgba(255, 216, 77, .07); }
table.ht { width: 100%; border-collapse: collapse; }
table.ht td { vertical-align: top; padding: 8px 8px 8px 0; border-bottom: 2px dashed #3b2468; }
table.ht td:first-child { width: 90px; white-space: nowrap; }

.login { text-align: center; max-width: 560px; margin: 24px auto; }
.login .showcase { display: flex; justify-content: center; gap: 4px; flex-wrap: wrap; margin: 12px 0 18px; }
.stack { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.tag { display: inline-block; background: #000; border: 2px solid var(--dim); padding: 2px 6px; font-size: 7px; color: var(--dim); }

/* Logs page (administrators) */
.logrow { border: 2px solid var(--dim); margin-top: 10px; padding: 8px 10px; background: #000; }
.logrow summary { cursor: pointer; line-height: 1.7; font-size: 9px; }
.logmsg { color: #ff8a8a; word-break: break-word; }
.logtrace { white-space: pre-wrap; word-break: break-all; font-size: 8px; line-height: 1.6; margin: 8px 0 0; color: var(--dim); }

/* logo */
.brand { display: flex; align-items: center; gap: 10px; }
.brandimg { width: 36px; height: 36px; image-rendering: pixelated; filter: drop-shadow(3px 3px 0 #000); }
.herologo { width: 96px; height: 96px; image-rendering: pixelated; display: block; margin: 0 auto 6px; filter: drop-shadow(4px 4px 0 #000); }
.inlinelogo { width: 28px; height: 28px; image-rendering: pixelated; vertical-align: middle; margin-right: 10px; }
@media (max-width: 640px) { .brandimg { width: 28px; height: 28px; } .herologo { width: 72px; height: 72px; } }

/* tournaments */
.awards { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 8px; }
.award { display: inline-block; padding: 3px 7px; font-size: 8px; line-height: 1.5; border: 2px solid #000; color: #1b1030; box-shadow: 2px 2px 0 #000; }
.award.p1 { background: #ffd84d; }
.award.p2 { background: #d9e2ef; }
.award.p3 { background: #cd7f32; color: #fff; }
.award.p4 { background: #3bd9ff; }
.tcard { margin-top: 10px; }
.twrow { padding: 6px 0; border-bottom: 2px dashed rgba(168, 148, 201, .25); font-size: 9px; line-height: 1.7; }

/* cups */
.cup { display: inline-block; vertical-align: middle; flex: none; image-rendering: pixelated; filter: drop-shadow(2px 2px 0 #000); margin-right: 8px; }
.award { display: inline-flex; align-items: center; gap: 6px; }
.award .awardcup { margin: 0; filter: none; }
.cupgrid { display: grid; grid-template-columns: repeat(16, 18px); grid-auto-rows: 18px; gap: 1px; background: #000; padding: 1px; touch-action: none; user-select: none; cursor: crosshair; }
.cupgrid i { display: block; background-color: #2a1a48; background-image: linear-gradient(45deg, rgba(255,255,255,.05) 25%, transparent 25%, transparent 75%, rgba(255,255,255,.05) 75%); }
.cuppicks { display: flex; flex-wrap: wrap; gap: 4px; max-width: 220px; }
.cuppick { background: #2a1a48; border: 2px solid #000; padding: 2px; cursor: pointer; }
.cuppick .cup { margin: 0; filter: none; }
.palette { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; max-width: 300px; }
.palsw { width: 24px; height: 24px; border: 2px solid #000; cursor: pointer; padding: 0; color: #fff; font-size: 12px; line-height: 1; background: #2a1a48; }
.palsw.sel { outline: 3px solid var(--yellow); outline-offset: 1px; }
@media (max-width: 420px) { .cupgrid { grid-template-columns: repeat(16, 16px); grid-auto-rows: 16px; } }

/* Chroma-shards and cosmetics */
.shard::before { content: ''; display: inline-block; width: 11px; height: 11px; margin-right: 6px; vertical-align: -1px;
  background: linear-gradient(135deg, #ff4d5e 0%, #ffd84d 25%, #4dff88 50%, #3bd9ff 75%, #ff4dd2 100%); clip-path: polygon(50% 0, 100% 40%, 50% 100%, 0 40%); }
.shard { white-space: nowrap; }
.spritebox { display: block; position: relative; }
.card .spritebox, .fighter .spritebox, .throne .spritebox { margin-left: auto; margin-right: auto; }
.hallrow .spritebox { margin: 0; }
.itemicon { image-rendering: pixelated; display: block; flex: none; }
.iiph { display: inline-block; flex: none; min-width: 40px; }
