/*
 * Upgrade, and the shelf of things a player owns.
 *
 * Three columns: what is being put up, the dial, and what is being aimed at.
 * The dial is a ring with the chance drawn as its exact share of the circle
 * and a needle that stops where the roll fell. Underneath, the shop, which is
 * the same grid of tiles the inside of a box uses, because it is the same
 * catalogue.
 */

.up-panel,
.up-shop-panel,
.own-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 12px;
}

.up-board {
  display: grid;
  grid-template-columns: minmax(230px, 300px) 1fr minmax(230px, 300px);
  gap: 18px;
  align-items: center;
  padding: 20px 18px;
}

/* ------------------------------------------------------------- the stake */

.up-side {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #0b1424;
}

.up-label {
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.up-stake-row {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 36px;
  padding: 0 6px 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0a1120;
}

.up-unit {
  font-size: 11px;
  color: var(--text-faint);
}

.up-stake-row input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  outline: none;
}

.up-stake-row button {
  height: 24px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  color: var(--text-dim);
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}

.up-stake-row button:hover {
  color: #fff;
  border-color: var(--gold);
}

.up-worth {
  min-height: 14px;
  font-size: 11px;
  color: var(--text-faint);
}

.up-mults {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.up-mults button {
  height: 30px;
  min-width: 46px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0a1120;
  color: var(--text-dim);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.up-mults button:hover {
  color: #fff;
  border-color: var(--gold);
}

.up-go {
  height: 40px;
  margin-top: 4px;
  border-radius: 9px;
  background: var(--lime);
  border-color: var(--lime-dark);
  color: var(--on-lime);
  font-size: 14px;
}

.up-go:hover:not(:disabled) {
  background: var(--lime-soft);
}

.up-go:disabled {
  opacity: 0.45;
}

.up-note {
  margin: 0;
  min-height: 16px;
  font-size: 12px;
  color: var(--text-faint);
}

/* -------------------------------------------------------------- the dial */

.up-dial {
  position: relative;
  margin-bottom: 26px;
  display: grid;
  place-items: center;
  width: 100%;
  max-width: 300px;
  aspect-ratio: 1 / 1;
  margin: 0 auto;
}

/* The halo the old dial sat in, and the dark disc inside the ring. */
.up-dial-glow {
  position: absolute;
  inset: -6%;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    transparent 64%,
    color-mix(in srgb, var(--lime) 26%, transparent) 72%,
    transparent 78%
  );
  filter: blur(6px);
  pointer-events: none;
}

.up-dial-core {
  position: absolute;
  inset: 13%;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 120%, color-mix(in srgb, var(--lime) 26%, transparent), transparent 62%),
    radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.05), transparent 55%),
    #070b10;
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.8);
  pointer-events: none;
}

.up-dial-mark {
  position: absolute;
  left: 50%;
  top: 72%;
  transform: translate(-50%, -50%);
  font-family: var(--display);
  font-size: 13px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--lime) 14%, transparent);
  pointer-events: none;
  white-space: nowrap;
}

.up-dial.is-won .up-dial-core {
  background:
    radial-gradient(circle at 50% 120%, rgba(34, 197, 94, 0.3), transparent 62%),
    #070b10;
}

.up-dial.is-lost .up-dial-core {
  background:
    radial-gradient(circle at 50% 120%, rgba(248, 113, 113, 0.22), transparent 62%),
    #070b10;
}

/* Quick spin, under the dial, the way the old screen carried it. */
.up-quick {
  position: absolute;
  left: 50%;
  bottom: -26px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  color: var(--text-faint);
  cursor: pointer;
  white-space: nowrap;
}

.up-quick input {
  width: 13px;
  height: 13px;
  accent-color: var(--lime);
}

/* ------------------------------------------------------- start and auto */

.up-start {
  display: flex;
  gap: 8px;
}

.up-start .up-go {
  flex: 1;
}

.up-auto-wrap {
  position: relative;
}

.up-auto {
  height: 100%;
  min-width: 52px;
}

.up-auto.is-on {
  background: var(--down);
  border-color: var(--down);
  color: #fff;
}

.up-auto-menu {
  position: absolute;
  right: 0;
  bottom: calc(100% + 6px);
  z-index: 4;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.55);
}

.up-auto-presets {
  display: flex;
  gap: 6px;
}

.up-auto-presets button {
  min-width: 38px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-deep);
  color: var(--text-dim);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.up-auto-presets button:hover {
  border-color: var(--lime);
  color: var(--lime);
}

.up-dial svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.up-dial-track {
  fill: none;
  stroke: #161922;
  stroke-width: 5;
}

.up-dial-arc {
  fill: none;
  stroke: var(--gold);
  stroke-width: 5;
  transition:
    stroke-dashoffset 220ms ease,
    stroke 220ms ease;
}

/*
 * The ring of ticks behind the dial, which is what the old screen had. They
 * are drawn rather than pictured, so they stay sharp at any size and cost
 * nothing to load.
 */
.up-ticks line {
  stroke: #1d2536;
  stroke-width: 1.4;
  stroke-linecap: round;
}

#up-ring {
  transform-origin: 100px 100px;
}

.up-dial.is-won .up-dial-arc {
  stroke: #22c55e;
}

.up-dial.is-lost .up-dial-arc {
  stroke: #6b7280;
}

/*
 * The pointer does not move. The ring does, which is how the old wheel read:
 * the winning arc is turned until the place the roll fell is sitting under
 * the mark at the top.
 */
.up-pointer {
  position: absolute;
  left: 50%;
  top: 4%;
  width: 2px;
  height: 13%;
  margin-left: -1px;
  border-radius: 2px;
  background: #fff;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.7);
  pointer-events: none;
}

/* Static content would paint under the ring, so the reading is lifted. */
.up-dial-text {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  text-align: center;
}

.up-dial-text b {
  font-family: var(--display);
  font-size: 34px;
  font-weight: 800;
}

.up-dial-text small {
  font-size: 11px;
  color: var(--text-faint);
}

/* ------------------------------------------------------------ the target */

.up-target {
  display: grid;
  place-items: center;
  min-height: 240px;
  padding: 16px;
  border: 1px dashed var(--line-2);
  border-radius: 10px;
  background: #0b1424;
  text-align: center;
}

.up-target-empty {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--text-dim);
}

.up-target-empty b {
  font-family: var(--display);
  font-size: 18px;
  color: var(--text);
}

.up-target-empty small {
  font-size: 12px;
  color: var(--text-faint);
}

.up-target-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.up-target-card img {
  width: 120px;
  height: 120px;
  object-fit: contain;
  filter: drop-shadow(0 10px 22px rgba(0, 0, 0, 0.55));
}

.up-target-card b {
  font-size: 14px;
}

.up-target-value {
  padding: 4px 14px;
  border-radius: 9px;
  background: var(--gold);
  color: #fff;
  font-size: 13px;
}

/* -------------------------------------------------------------- the shop */

.up-shop {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(164px, 1fr));
  gap: 8px;
  margin: 0;
  padding: 12px 14px;
  list-style: none;
}

/*
 * The card the old shop used. A square, a diagonal wash in the colour of the
 * tier, the tag and the price along the top, then the picture, the name and
 * what it is worth. The shop and the player's own shelf share it.
 */
.up-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 100%;
  padding: 8px;
  border: 1px solid color-mix(in srgb, var(--tier) 22%, var(--line));
  border-radius: 14px;
  background:
    linear-gradient(
      145deg,
      color-mix(in srgb, var(--tier) 42%, transparent) -60%,
      rgba(0, 0, 0, 0.1) 45%,
      rgba(0, 0, 0, 0.1) 65%,
      color-mix(in srgb, var(--tier) 42%, transparent) 160%
    ),
    rgba(4, 5, 6, 0.5);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
}

.up-card:hover {
  border-color: color-mix(in srgb, var(--tier) 55%, var(--line));
}

.up-card.is-on {
  border-color: var(--lime);
  box-shadow: 0 0 0 1px var(--lime), 0 0 22px rgba(204, 255, 0, 0.18);
}

.up-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 8px;
}

.up-card-rarity {
  width: 30px;
  height: 8px;
  border-radius: 999px;
  background: var(--tier);
}

.up-card-price {
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
}

/* The picture keeps its own square, so rows line up whatever the art is. */
.up-card-art {
  display: grid;
  place-items: center;
  width: 100%;
  height: 84px;
  margin: 2px 0 6px;
}

.up-card-art img {
  max-width: 84%;
  max-height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.5));
}

.up-card-name {
  width: 100%;
  font-size: 12px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.up-card-sub {
  width: 100%;
  font-size: 11px;
  color: var(--text-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* The tick only shows on a card that is in. */
.up-card-tick {
  position: absolute;
  top: 8px;
  right: 8px;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--lime);
  opacity: 0;
  transform: scale(0.7);
  transition: 140ms ease;
}

.up-card-tick svg {
  width: 12px;
  height: 12px;
  fill: none;
  stroke: var(--on-lime);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.up-card.is-on .up-card-tick {
  opacity: 1;
  transform: scale(1);
}

.up-card.is-on .up-card-price {
  color: var(--lime);
}

/* ------------------------------------------------- what is going in */

.up-picked {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 4px;
  max-height: 168px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.up-chip {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 24px 5px 6px;
  border: 1px solid color-mix(in srgb, var(--tier) 40%, var(--line));
  border-radius: 9px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--tier) 16%, #0b1018), #0b1018);
}

.up-chip img {
  width: 26px;
  height: 26px;
  object-fit: contain;
}

.up-chip-coin {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  color: var(--lime);
  font-size: 15px;
}

.up-chip b {
  font-size: 11px;
  font-weight: 600;
}

.up-chip-off {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-faint);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}

.up-chip-off:hover {
  color: var(--down);
}

.up-picked-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 11px;
  color: var(--text-dim);
}

.up-picked-line b {
  color: var(--text);
}

/* ---------------------------------------------------- the whole shelf */

.up-mine-actions {
  display: flex;
  gap: 6px;
}

/* -------------------------------------------------- the shelf of my items */

.own-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 10px;
  margin: 0;
  padding: 12px 14px;
  list-style: none;
}

.own-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 8px 10px;
  border: 1px solid color-mix(in srgb, var(--tier) 34%, var(--line));
  border-radius: 8px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--tier) 14%, #0b1424), #0b1424);
  overflow: hidden;
}

.own-item img {
  width: 82px;
  height: 82px;
  object-fit: contain;
}

.own-name {
  width: 100%;
  font-size: 12px;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.own-value {
  font-size: 13px;
  font-weight: 700;
  color: var(--gold);
}

.own-eth {
  font-size: 10px;
  color: var(--text-faint);
}

.own-actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

.own-total {
  font-size: 12px;
  color: var(--text-dim);
}

/* ------------------------------------------------------- what was just won */

.won-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 18px 12px 12px;
  border: 1px solid color-mix(in srgb, var(--tier) 40%, var(--line));
  border-radius: 10px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--tier) 18%, #0b1424), #0b1424);
  position: relative;
  overflow: hidden;
}

.won-bar {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 3px;
  background: var(--tier);
}

.won-item img {
  width: 128px;
  height: 128px;
  object-fit: contain;
}

.won-name {
  margin: 4px 0 0;
  font-size: 14px;
  text-align: center;
}

.won-value {
  margin: 0;
  font-family: var(--display);
  font-size: 22px;
  font-weight: 800;
  color: var(--gold);
}

.won-eth {
  margin: 0;
  font-size: 11px;
  color: var(--text-faint);
}

.won-note {
  margin: 6px 0 0;
  font-size: 11px;
  text-align: center;
  color: var(--text-faint);
}

@media (max-width: 900px) {
  .up-board {
    grid-template-columns: 1fr;
  }

  .up-target {
    min-height: 180px;
  }
}

/* ------------------------------------------------------------ the header */

.up-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px 0;
}

.up-head h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-family: var(--display);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.up-head-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 10px var(--gold);
}

/* --------------------------------------------------------- the price range */

/* --------------------------------------------------------- the filter row */

.up-filters {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 16px 0;
}

.up-range-value {
  display: grid;
  place-items: center;
  min-width: 96px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0a1120;
  font-size: 12px;
  color: var(--text-dim);
}

/*
 * Two range inputs stacked on one track. Each one is transparent apart from
 * its handle, and the lit part of the track between them is a separate strip
 * underneath, which is the only way to get a two ended slider without a
 * library.
 */
.up-slider {
  position: relative;
  flex: 1;
  min-width: 160px;
  height: 32px;
}

.up-slider-track,
.up-slider-fill {
  position: absolute;
  top: 50%;
  height: 4px;
  margin-top: -2px;
  border-radius: 4px;
  pointer-events: none;
}

.up-slider-track {
  left: 8px;
  right: 8px;
  background: #17223a;
}

.up-slider-fill {
  background: var(--gold);
}

.up-slider input[type='range'] {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 32px;
  margin: 0;
  background: none;
  pointer-events: none;
  appearance: none;
  -webkit-appearance: none;
}

.up-slider input[type='range']::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border: 0;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.6);
  cursor: pointer;
  pointer-events: auto;
}

.up-slider input[type='range']::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: 0;
  border-radius: 50%;
  background: var(--gold);
  cursor: pointer;
  pointer-events: auto;
}

.up-select {
  height: 32px;
  min-width: 190px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0a1120;
  color: var(--text);
  font: inherit;
  font-size: 12px;
}

.up-search {
  height: 32px;
  border-radius: 8px;
}

/* ------------------------------------------------- readable on gold */

.up-go,
.up-target-value {
  color: var(--on-lime);
  font-weight: 700;
}

.up-steps {
  margin: 0;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.5;
}

.up-steps li::marker {
  color: var(--gold);
  font-weight: 700;
}

/* An empty shelf still reads as a shelf, so the message sits in the middle. */
.own-grid .flip-empty,
.up-shop .flip-empty {
  grid-column: 1 / -1;
  padding: 34px 12px;
  text-align: center;
  color: var(--text-faint);
}

.up-target-card small {
  font-size: 10px;
  color: var(--text-faint);
}

.own-value {
  font-size: 13px;
  font-weight: 700;
  color: var(--gold);
}

.own-eth {
  font-size: 10px;
  color: var(--text-faint);
}

.won-value {
  font-size: 20px;
}

.won-eth {
  font-size: 12px;
  color: var(--text-faint);
}

.up-clear {
  height: 32px;
  border-radius: 8px;
  white-space: nowrap;
}
