:root {
  --bg: #1e1f29;
  --panel: #2a2c3a;
  --cell: #343650;
  --cell-hover: #3f4260;
  --text: #f2f2f5;
  --muted: #9a9cb5;
  --x-color: #ff6b6b;
  --o-color: #4ecdc4;
  --win: #ffd166;
  --accent: #6c63ff;
  --red-color: #ef4444;
  --blue-color: #3b82f6;
  --c4-frame: #2f5bd3;
  --c4-red: #ef4444;
  --c4-yellow: #facc15;
  /* Simulator outcomes: an ordered good / neutral / bad scale, checked for
     colorblind separation on the panel color. */
  --outcome-win: #0f9f9a;
  --outcome-draw: #c3c5d4;
  --outcome-loss: #e8590c;
  --outcome-ink: #111218;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.game {
  background: var(--panel);
  padding: 2rem;
  border-radius: 1rem;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  width: min(90vw, 420px);
}

.game.c4-page {
  width: min(96vw, 560px);
  padding: 1.25rem;
}

.game.fence-page {
  width: min(96vw, 640px);
  padding: 1.25rem;
}

h1 {
  margin: 0;
  font-size: 1.8rem;
}

.title-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  position: relative;
}

.settings-link {
  position: absolute;
  right: 0;
  color: var(--muted);
  display: flex;
  padding: 0.3rem;
}

.settings-link:hover {
  color: var(--text);
}

.gear-icon {
  width: 1.4rem;
  height: 1.4rem;
}

.menu-wrap {
  position: absolute;
  left: 0;
}

.menu-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  display: flex;
  padding: 0.3rem;
  cursor: pointer;
}

.menu-btn:hover {
  color: var(--text);
}

.menu-icon {
  width: 1.4rem;
  height: 1.4rem;
}

.menu-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 0.4rem;
  background: var(--cell);
  border-radius: 0.6rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  overflow: hidden;
  z-index: 20;
  min-width: 9rem;
  text-align: left;
}

.menu-item {
  display: block;
  padding: 0.7rem 1rem;
  color: var(--text);
  text-decoration: none;
  font-size: 0.95rem;
}

.menu-item:hover {
  background: var(--cell-hover);
}

.menu-item.active {
  color: var(--accent);
  font-weight: 600;
}

.status {
  margin: 0 0 1.5rem;
  min-height: 1.4em;
  font-size: 1.1rem;
  color: var(--muted);
}

.board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
  margin: 0 auto 1.5rem;
}

.fence-board {
  width: 100%;
  margin: 0 auto 1.5rem;
  background: var(--cell);
  border-radius: 0.6rem;
  padding: 0.5rem;
}

.fence-svg {
  width: 100%;
  height: auto;
  display: block;
}

.dot {
  fill: var(--text);
}

.edge-hit {
  stroke: transparent;
  stroke-width: 14;
  stroke-linecap: round;
  cursor: pointer;
  touch-action: manipulation;
}

.edge-line {
  stroke-width: 4;
  stroke-linecap: round;
  opacity: 0.25;
  transition: opacity 0.15s ease, stroke-width 0.15s ease;
}

.edge-line.drawn {
  stroke-width: 6;
  opacity: 1;
}

.box-label {
  font-size: 1.6rem;
  font-weight: 700;
}

.score .p1-label {
  color: var(--red-color);
}

.score .p2-label {
  color: var(--blue-color);
}

.cell {
  aspect-ratio: 1 / 1;
  background: var(--cell);
  border: none;
  border-radius: 0.6rem;
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.15s ease, transform 0.1s ease;
}

.cell:active:not(:disabled) {
  transform: scale(0.94);
}

.cell:hover:not(:disabled) {
  background: var(--cell-hover);
}

.cell:disabled {
  cursor: default;
}

.cell.x {
  color: var(--x-color);
}

.cell.o {
  color: var(--o-color);
}

.cell.win {
  background: rgba(255, 209, 102, 0.25);
  box-shadow: inset 0 0 0 2px var(--win);
}

.cell.valid-drop {
  background: rgba(108, 99, 255, 0.25);
  box-shadow: inset 0 0 0 2px var(--accent);
}

.cell.invalid-shake {
  animation: shake 0.3s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

.cell .piece-stack {
  width: 78%;
  height: 78%;
  pointer-events: none;
}

.piece-stack circle {
  transition: r 0.1s ease;
}

.trays {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 1.5rem;
}

.tray {
  background: var(--cell);
  border-radius: 0.6rem;
  padding: 0.5rem;
  opacity: 0.45;
  transition: opacity 0.15s ease;
}

.tray.active-tray {
  opacity: 1;
}

.tray-label {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  margin-bottom: 0.4rem;
}

.tray-slots {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.35rem;
}

.tray-slot {
  position: relative;
  width: clamp(2rem, 14vw, 2.6rem);
  height: clamp(2rem, 14vw, 2.6rem);
  background: var(--panel);
  border: none;
  border-radius: 0.4rem;
  padding: 0.2rem;
  touch-action: none;
  flex: 0 0 auto;
}

.tray.active-tray .tray-slot:not(:disabled) {
  cursor: grab;
}

.tray-slot:disabled {
  opacity: 0.25;
}

.tray-slot .piece-stack {
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.tray-slot .slot-count {
  position: absolute;
  bottom: -0.3rem;
  right: -0.3rem;
  background: var(--accent);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  border-radius: 999px;
  min-width: 1.1rem;
  height: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.2rem;
}

.tray-slot.selected {
  box-shadow: 0 0 0 2px var(--accent);
}

.drag-ghost {
  position: fixed;
  width: 3.2rem;
  height: 3.2rem;
  pointer-events: none;
  z-index: 50;
  transform: translate(-50%, -50%);
}

.drag-ghost .piece-stack {
  width: 100%;
  height: 100%;
}

.setting-block {
  text-align: left;
  margin-bottom: 1.5rem;
}

.setting-block label {
  display: block;
  margin-bottom: 0.6rem;
  font-size: 0.95rem;
}

.setting-block input[type="range"] {
  width: 100%;
  margin-bottom: 1rem;
}

.preview-stack-wrap {
  width: 8rem;
  height: 8rem;
  margin: 0 auto 1rem;
  background: var(--cell);
  border-radius: 0.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview-stack-wrap .piece-stack {
  width: 85%;
  height: 85%;
}

.preview-classic {
  font-size: 2rem;
  font-weight: 700;
  color: var(--muted);
}

.settings-hint {
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.4;
  margin: 0;
}

.settings-actions {
  display: flex;
  justify-content: center;
}

.size-options {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.size-option {
  flex: 1;
  background: var(--cell);
  color: var(--text);
  border: 2px solid transparent;
  border-radius: 0.6rem;
  padding: 0.7rem 0.4rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}

.size-option:hover {
  background: var(--cell-hover);
}

.size-option.selected {
  border-color: var(--accent);
  background: var(--cell-hover);
}

.fence-preview {
  margin: 0 auto 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--cell);
  border-radius: 0.6rem;
  padding: 0.5rem;
  max-width: 12rem;
}

.fence-preview svg {
  width: 100%;
  height: auto;
  display: block;
}

.scoreboard {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.score {
  flex: 1;
  background: var(--cell);
  border-radius: 0.6rem;
  padding: 0.6rem 0.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.score span {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.score strong {
  font-size: 1.3rem;
}

.reset-btn {
  background: var(--accent);
  color: var(--text);
  border: none;
  border-radius: 0.6rem;
  padding: 0.7rem 1.4rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s ease;
}

.reset-btn:hover {
  filter: brightness(1.1);
}

/* --- Connect 4 --- */
.c4-board {
  display: grid;
  grid-template-columns: repeat(var(--c4-cols, 7), 1fr);
  gap: 0.3rem;
  margin: 0 auto 1.5rem;
  padding: 0.45rem;
  background: var(--c4-frame);
  border-radius: 0.8rem;
  overflow: hidden;
  touch-action: manipulation;
}

.c4-column {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.15s ease;
}

.c4-column:disabled {
  cursor: default;
}

.c4-board[data-player="1"] .c4-column:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.3);
}

.c4-board[data-player="2"] .c4-column:hover:not(:disabled) {
  background: rgba(250, 204, 21, 0.3);
}

.c4-slot {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  background: var(--bg);
  box-shadow: inset 0 3px 6px rgba(0, 0, 0, 0.45);
}

.c4-chip {
  position: absolute;
  inset: 6%;
  border-radius: 50%;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.2), inset 0 0 0 4px rgba(255, 255, 255, 0.12);
}

.c4-chip.p1 {
  background: var(--c4-red);
}

.c4-chip.p2 {
  background: var(--c4-yellow);
}

.c4-chip.dropping {
  animation: c4-drop calc(0.12s + var(--fall) * 0.05s) cubic-bezier(0.5, 0, 1, 1);
}

@keyframes c4-drop {
  from { transform: translateY(calc(var(--fall) * -118%)); }
  to { transform: translateY(0); }
}

.c4-slot.win {
  box-shadow: 0 0 0 3px var(--win), inset 0 3px 6px rgba(0, 0, 0, 0.45);
}

.c4-slot.win .c4-chip {
  animation: c4-pulse 0.9s ease-in-out 0.3s infinite alternate;
}

@keyframes c4-pulse {
  to { transform: scale(0.85); }
}

.status[data-player="1"] {
  color: var(--c4-red);
}

.status[data-player="2"] {
  color: var(--c4-yellow);
}

.score .c4-red-label {
  color: var(--c4-red);
}

.score .c4-yellow-label {
  color: var(--c4-yellow);
}

.size-options + label {
  margin-top: 0.4rem;
}

.c4-preview {
  margin: 0 auto 1rem;
  max-width: 14rem;
}

.c4-preview svg {
  width: 100%;
  height: auto;
  display: block;
}

/* --- WildFlip --- */
.game.cc-page {
  width: min(96vw, 480px);
  padding: 1.25rem;
}

.cc-page [hidden] {
  display: none !important;
}

/* Room for two lines so the board doesn't jump when a message wraps. */
.cc-page .status {
  margin-bottom: 0.8rem;
  min-height: 2.6em;
  display: flex;
  align-items: center;
  justify-content: center;
}

.status[data-color="red"] {
  color: var(--red-color);
}

.status[data-color="blue"] {
  color: var(--blue-color);
}

.cc-note {
  color: var(--muted);
  line-height: 1.4;
  margin: 0 0 1rem;
}

.cc-muted {
  color: var(--muted);
  font-size: 0.85rem;
}

.cc-notice {
  background: rgba(108, 99, 255, 0.18);
  border: 1px solid var(--accent);
  border-radius: 0.6rem;
  padding: 0.6rem 0.8rem;
  font-size: 0.9rem;
  margin: 0 0 0.8rem;
}

.cc-form {
  display: flex;
  gap: 0.5rem;
}

.cc-input {
  flex: 1;
  width: 100%;
  min-width: 0;
  background: var(--cell);
  border: 2px solid transparent;
  border-radius: 0.6rem;
  color: var(--text);
  font: inherit;
  font-size: 1rem;
  padding: 0.65rem 0.8rem;
  -webkit-user-select: text;
  user-select: text;
}

.cc-input:focus {
  outline: none;
  border-color: var(--accent);
}

.cc-profile {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  background: var(--cell);
  border-radius: 0.6rem;
  padding: 0.6rem 0.8rem;
  margin-bottom: 0.8rem;
  text-align: left;
}

.cc-profile-name {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.cc-link {
  color: #a9a4ff;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.cc-link:hover {
  text-decoration: underline;
}

.cc-rules {
  text-align: left;
  margin-top: 1.2rem;
  font-size: 0.88rem;
  color: var(--muted);
}

.cc-rules summary {
  cursor: pointer;
  color: var(--text);
  text-align: center;
}

.cc-rules ul {
  padding-left: 1.2rem;
  line-height: 1.45;
}

.cc-red-text {
  color: var(--red-color);
  font-weight: 700;
}

.cc-blue-text {
  color: var(--blue-color);
  font-weight: 700;
}

/* A card: four side numbers around a picture. Sizes scale with the card. */
.cc-card {
  container-type: inline-size;
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr) minmax(0, 1fr);
  grid-template-rows: 1fr 1.5fr 1fr;
  place-items: center;
  border: 3px solid var(--rarity-color, var(--muted));
  border-radius: 12%;
  background: linear-gradient(160deg, #474a6e, #2a2c3a);
  color: #fff;
  font-weight: 800;
  line-height: 1;
  overflow: hidden;
}

.cc-card.red {
  border-color: var(--red-color);
  background: linear-gradient(160deg, #c2414b, #6b1d26);
}

.cc-card.blue {
  border-color: var(--blue-color);
  background: linear-gradient(160deg, #3c6fd8, #1b326e);
}

.cc-num {
  font-size: 19cqw;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
}

.cc-top { grid-area: 1 / 2; }
.cc-left { grid-area: 2 / 1; }
.cc-right { grid-area: 2 / 3; }
.cc-bottom { grid-area: 3 / 2; }

.cc-face {
  grid-area: 2 / 2;
  max-width: 100%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3cqw;
}

.cc-icon {
  font-size: 32cqw;
}

.cc-name {
  font-size: 10cqw;
  font-weight: 600;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Rare and better cards carry a gem in the corner, colored by rarity. */
.cc-gem {
  grid-area: 1 / 1;
  width: 12cqw;
  height: 12cqw;
  background: var(--rarity-color);
  border-radius: 2cqw;
  transform: rotate(45deg);
  box-shadow: 0 0 0 1.5cqw rgba(0, 0, 0, 0.35), 0 0 6cqw var(--rarity-color);
}

/* Epic cards stand out from rares: a faceted violet gem with a sparkle, a
   violet-to-pink gradient border, and in play (where the border shows the
   player's color) a violet inner ring. */
.cc-card[data-rarity="epic"] {
  border-color: transparent;
  background:
    linear-gradient(160deg, #4f3f78, #2a2340) padding-box,
    linear-gradient(135deg, #f0abfc, #c084fc 45%, #7c3aed) border-box;
}

.cc-card[data-rarity="epic"].red {
  border-color: var(--red-color);
  background: linear-gradient(160deg, #c2414b, #6b1d26);
}

.cc-card[data-rarity="epic"].blue {
  border-color: var(--blue-color);
  background: linear-gradient(160deg, #3c6fd8, #1b326e);
}

.cc-card[data-rarity="epic"].red::after,
.cc-card[data-rarity="epic"].blue::after {
  content: "";
  position: absolute;
  inset: 3cqw;
  border: 1.5px solid #e9c2ff;
  border-radius: 9%;
  box-shadow: 0 0 4cqw rgba(192, 132, 252, 0.6);
  pointer-events: none;
}

.cc-card[data-rarity="epic"] .cc-gem {
  width: 14cqw;
  height: 14cqw;
  background: linear-gradient(135deg, #fdf4ff 0%, #f0abfc 30%, #c084fc 60%, #7c3aed 100%);
  box-shadow: 0 0 0 1.5cqw rgba(0, 0, 0, 0.35), 0 0 8cqw #e879f9;
}

@container (max-width: 90px) {
  .cc-name {
    display: none;
  }
}

.cc-card.cc-placed {
  animation: cc-place 0.25s ease-out;
}

@keyframes cc-place {
  from { transform: scale(1.15); opacity: 0.3; }
  to { transform: scale(1); opacity: 1; }
}

.cc-card.cc-flipping {
  animation: cc-flip 0.5s ease-in-out;
}

@keyframes cc-flip {
  0% { transform: perspective(400px) rotateY(0); }
  50% { transform: perspective(400px) rotateY(90deg); }
  100% { transform: perspective(400px) rotateY(0); }
}

.cc-slot,
.cc-hand-card,
.cc-pick {
  font: inherit;
  padding: 0;
  border: none;
  background: none;
  color: inherit;
  touch-action: manipulation;
}

/* Board */
.cc-board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.4rem;
  width: min(100%, 330px);
  margin: 0.6rem auto;
  padding: 0.4rem;
  background: var(--cell);
  border-radius: 0.8rem;
}

.cc-slot {
  aspect-ratio: 1 / 1;
  background: var(--bg);
  border-radius: 0.6rem;
  cursor: default;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}

.cc-board.placing .cc-slot:not(:disabled) {
  cursor: pointer;
}

.cc-board.placing .cc-slot:not(:disabled):hover {
  background: var(--cell-hover);
  box-shadow: inset 0 0 0 2px var(--accent);
}

.cc-slot.cc-claimable .cc-card {
  box-shadow: 0 0 0 3px var(--win);
  animation: cc-glow 0.9s ease-in-out infinite alternate;
}

@keyframes cc-glow {
  to { box-shadow: 0 0 0 3px var(--win), 0 0 14px var(--win); }
}

/* Hands and player bars */
.cc-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.2rem 0.2rem;
}

.cc-who {
  font-weight: 700;
}

.cc-score {
  font-size: 1.3rem;
  min-width: 2.2rem;
  background: var(--cell);
  border-radius: 0.5rem;
  padding: 0.15rem 0.5rem;
}

.cc-side[data-color="red"] .cc-who,
.cc-side[data-color="red"] .cc-score {
  color: var(--red-color);
}

.cc-side[data-color="blue"] .cc-who,
.cc-side[data-color="blue"] .cc-score {
  color: var(--blue-color);
}

.cc-hand {
  display: flex;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.35rem 0;
  transition: opacity 0.2s ease;
}

/* Keeps an empty hand from collapsing so the board doesn't jump. */
.cc-hand:empty::before {
  content: "";
  flex: 0 0 calc((100% - 1.6rem) / 5);
  aspect-ratio: 1 / 1;
}

.cc-hand.waiting {
  opacity: 0.55;
}

.cc-hand-card {
  flex: 0 0 calc((100% - 1.6rem) / 5);
  border-radius: 12%;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.cc-hand-card:disabled,
div.cc-hand-card {
  cursor: default;
}

.cc-hand-card.selected {
  transform: translateY(-10%);
}

#oppHand .cc-hand-card.selected {
  transform: translateY(10%);
}

.cc-hand-card.selected .cc-card {
  box-shadow: 0 0 0 3px var(--win);
}

.cc-result {
  margin-top: 0.8rem;
}

.cc-result-score {
  margin: 0 0 0.6rem;
  font-size: 0.9rem;
  font-weight: 600;
}

.cc-result .cc-hand-card {
  flex-basis: min(32%, 130px);
}

.cc-result .reset-btn {
  margin-top: 0.8rem;
}

.cc-hand-card.cc-claimed {
  animation: cc-place 0.35s ease-out;
}

/* Hand picker */
.cc-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.5rem;
  margin-bottom: 1.2rem;
}

.cc-pick {
  position: relative;
  border-radius: 12%;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.cc-pick.selected {
  transform: translateY(-4px);
}

.cc-pick.selected .cc-card {
  box-shadow: 0 0 0 3px var(--accent);
}

.cc-pick.selected::after {
  content: "✓";
  position: absolute;
  top: -0.35rem;
  right: -0.35rem;
  width: 1.2rem;
  height: 1.2rem;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Collection page */
.cc-heading {
  font-size: 0.85rem;
  text-align: left;
  margin: 1.2rem 0 0.6rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.cc-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

.cc-collection {
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 0.8rem;
}

.cc-collect-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
}

.cc-collect-item.missing .cc-card {
  filter: grayscale(1) brightness(0.55);
}

.cc-caption {
  display: flex;
  flex-direction: column;
  font-size: 0.85rem;
  font-weight: 600;
  gap: 0.1rem;
}

.cc-caption .cc-muted {
  font-size: 0.7rem;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.cc-count {
  background: var(--cell);
  border-radius: 999px;
  padding: 0.1rem 0.6rem;
  font-size: 0.8rem;
  font-weight: 700;
}

.cc-collect-item.missing .cc-count {
  color: var(--muted);
  font-weight: 400;
}

.cc-history {
  list-style: none;
  padding: 0;
  margin: 0 0 1.5rem;
  text-align: left;
}

.cc-history li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem;
  background: var(--cell);
  border-radius: 0.5rem;
  padding: 0.5rem 0.7rem;
  margin-bottom: 0.4rem;
  font-size: 0.9rem;
}

.cc-win {
  color: #4ade80;
}

.cc-loss {
  color: var(--x-color);
}

.cc-draw {
  color: var(--win);
}

.cc-when {
  margin-left: auto;
  font-size: 0.75rem;
}

.cc-btn-link {
  display: inline-block;
  text-decoration: none;
}

.cc-danger {
  background: #b91c1c;
}

.setting-block .cc-input {
  margin-bottom: 0.4rem;
}

.setting-block .cc-danger {
  margin-top: 0.8rem;
}

/* Card Builder */
.cc-rarity-table {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.cc-rarity-row {
  display: grid;
  grid-template-columns: 1.4fr 1fr 0.6fr 1.3fr;
  gap: 0.5rem;
  align-items: center;
  background: var(--cell);
  border-radius: 0.6rem;
  padding: 0.45rem 0.6rem;
  text-align: left;
  font-size: 0.9rem;
}

.cc-rarity-row.cc-rarity-head {
  background: none;
  padding: 0 0.6rem;
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.cc-rarity-name {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 700;
  color: var(--rarity-color);
}

.cc-dot {
  flex: 0 0 auto;
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 2px;
  background: var(--rarity-color);
  transform: rotate(45deg);
}

.cc-pct-input {
  position: relative;
}

.cc-pct-input::after {
  content: "%";
  position: absolute;
  right: 0.55rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.cc-pct-input .cc-input {
  background: var(--panel);
  padding: 0.4rem 1.4rem 0.4rem 0.5rem;
  -moz-appearance: textfield;
}

.cc-pct-input .cc-input::-webkit-inner-spin-button,
.cc-pct-input .cc-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.cc-rarity-actual small {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
}

.cc-chance-total {
  font-weight: 600;
  margin: 0.7rem 0;
  color: #4ade80;
}

.cc-chance-total.bad {
  color: var(--x-color);
}

#chanceForm .reset-btn {
  margin-top: 0.8rem;
}

.reset-btn:disabled {
  opacity: 0.5;
  cursor: default;
  filter: none;
}

.cc-builder {
  text-align: left;
}

.cc-builder label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0.9rem 0 0.35rem;
}

.cc-builder-card {
  display: grid;
  grid-template-columns: auto min(160px, 42vw) auto;
  justify-content: center;
  align-items: center;
  gap: 0.4rem;
}

.cc-builder-preview {
  grid-area: 2 / 2;
}

.cc-sel-top { grid-area: 1 / 2; justify-self: center; }
.cc-sel-left { grid-area: 2 / 1; }
.cc-sel-right { grid-area: 2 / 3; }
.cc-sel-bottom { grid-area: 3 / 2; justify-self: center; }

.cc-side-select {
  background: var(--cell);
  color: var(--text);
  border: 2px solid transparent;
  border-radius: 0.5rem;
  font: inherit;
  font-size: 1rem;
  font-weight: 700;
  padding: 0.35rem 0.4rem;
  cursor: pointer;
}

.cc-side-select:focus {
  outline: none;
  border-color: var(--accent);
}

.cc-emoji-picks {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.45rem;
}

.cc-emoji-picks button {
  font-size: 1.25rem;
  line-height: 1;
  background: var(--cell);
  border: none;
  border-radius: 0.4rem;
  padding: 0.3rem 0.35rem;
  cursor: pointer;
  touch-action: manipulation;
}

.cc-emoji-picks button:hover {
  background: var(--cell-hover);
}

.size-option.cc-rarity-option {
  color: var(--rarity-color);
  font-size: 0.8rem;
  padding: 0.6rem 0.2rem;
}

.size-option.cc-rarity-option.selected {
  border-color: var(--rarity-color);
}

.cc-error {
  color: var(--x-color);
  font-size: 0.9rem;
  margin: 0.6rem 0 0;
}

.cc-form-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.cc-secondary {
  background: var(--cell);
}

.cc-pool-item {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
}

.cc-pool-item.editing .cc-card {
  box-shadow: 0 0 0 3px var(--accent);
}

.cc-admin-back {
  margin-top: 1.5rem;
}

.setting-block .cc-admin-link {
  margin-top: 0.8rem;
}

/* Collection groups and Card Builder pool filters */
.cc-heading-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.cc-toggle {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
  cursor: pointer;
}

.cc-toggle input {
  width: 1rem;
  height: 1rem;
  accent-color: var(--accent);
}

.cc-rarity-heading {
  font-size: 0.95rem;
  text-align: left;
  margin: 0.9rem 0 0.5rem;
}

.cc-none {
  text-align: left;
  margin: 0 0 0.5rem;
}

.cc-pool-filters {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}

.cc-pool-filters .cc-input {
  padding: 0.5rem 0.7rem;
}

.cc-pool-filters .cc-side-select {
  font-weight: 600;
  font-size: 0.9rem;
}

/* Simulator */
.cc-sim-note {
  margin: -0.4rem 0 0.4rem;
  text-align: center;
}

.cc-fields {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.5rem 0.8rem;
  align-items: center;
  text-align: left;
  font-size: 0.9rem;
  margin-bottom: 0.6rem;
}

.cc-fields label {
  color: var(--muted);
}

.cc-select {
  width: 100%;
  min-width: 0;
  background: var(--cell);
  color: var(--text);
  border: 2px solid transparent;
  border-radius: 0.5rem;
  font: inherit;
  font-size: 0.95rem;
  padding: 0.45rem 0.5rem;
  cursor: pointer;
}

.cc-select:focus {
  outline: none;
  border-color: var(--accent);
}

.cc-sim-preview {
  margin-bottom: 0.4rem;
}

.cc-sim-controls .size-options {
  margin-bottom: 0;
}

.cc-sim-controls .cc-form-actions {
  margin-top: 0.8rem;
}

#watchArea {
  margin-top: 1rem;
}

.cc-sim-results {
  margin-top: 1.2rem;
  text-align: left;
}

.cc-sim-title {
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.4;
  margin: 0 0 0.7rem;
}

/* One stacked bar: 2px panel-colored gaps between segments, rounded ends. */
.cc-outcome-bar {
  display: flex;
  gap: 2px;
  height: 2.2rem;
  border-radius: 4px;
  overflow: hidden;
  background: var(--panel);
}

.cc-outcome-seg {
  flex-basis: 0;
  min-width: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--outcome-ink);
  font-size: 0.85rem;
  font-weight: 700;
  white-space: nowrap;
}

.cc-outcome-win { background: var(--outcome-win); }
.cc-outcome-draw { background: var(--outcome-draw); }
.cc-outcome-loss { background: var(--outcome-loss); }

.cc-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 1rem;
  margin: 0.55rem 0 1rem;
  font-size: 0.82rem;
  color: var(--text);
}

.cc-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.cc-swatch {
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 2px;
}

.cc-kpis {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
  margin-bottom: 1rem;
  text-align: center;
}

.cc-sim-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 0.3rem;
  font-size: 0.9rem;
}

.cc-sim-table caption {
  text-align: left;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.2rem;
}

.cc-sim-table th,
.cc-sim-table td {
  padding: 0.45rem 0.6rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.cc-sim-table th:first-child {
  text-align: left;
}

.cc-sim-table thead th {
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
  padding-top: 0;
  padding-bottom: 0;
}

.cc-sim-table tbody th,
.cc-sim-table tbody td {
  background: var(--cell);
}

.cc-sim-table tbody th {
  border-radius: 0.5rem 0 0 0.5rem;
  font-weight: 600;
}

.cc-sim-table tbody td:last-child {
  border-radius: 0 0.5rem 0.5rem 0;
}

.setting-block .cc-admin-link + .cc-admin-link {
  margin-left: 0.4rem;
}

.cc-run-status {
  min-height: 1.3em;
  margin: 0.6rem 0 0;
  font-size: 0.9rem;
  color: var(--muted);
}

/* Coins and packs */
.cc-profile-links {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.3rem;
}

.cc-result-coins {
  margin: 0 0 0.6rem;
  font-weight: 700;
  color: var(--win);
}

.cc-wallet {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--cell);
  border-radius: 999px;
  padding: 0.35rem 0.95rem;
  margin-bottom: 0.8rem;
}

.cc-pack-art {
  position: relative;
  width: min(170px, 48vw);
  aspect-ratio: 3 / 4;
  margin: 0.2rem auto 1rem;
  border-radius: 0.9rem;
  background: linear-gradient(155deg, #8b7dff 0%, #6c63ff 45%, #3b2f9e 100%);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.45), inset 0 0 0 3px rgba(255, 255, 255, 0.18);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  color: #fff;
  overflow: hidden;
}

.cc-pack-art::before {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.06) 0 10px, transparent 10px 20px);
}

.cc-pack-brand {
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  opacity: 0.85;
}

.cc-pack-icon {
  font-size: 3rem;
  line-height: 1;
}

.cc-pack-name {
  font-weight: 800;
  font-size: 1.05rem;
}

.cc-pack-size {
  font-size: 0.8rem;
  opacity: 0.85;
}

.cc-pack-tear {
  animation: cc-tear 0.7s ease-in forwards;
}

@keyframes cc-tear {
  0% { transform: rotate(0); }
  15% { transform: rotate(-4deg); }
  30% { transform: rotate(4deg); }
  45% { transform: rotate(-3deg); }
  60% { transform: rotate(2deg); opacity: 1; }
  100% { transform: scale(1.25); opacity: 0; }
}

.cc-odds-table {
  margin-top: 1rem;
}

.cc-odds-table .cc-rarity-name {
  font-weight: 600;
}

.cc-pack-cards {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.6rem;
  margin: 0.4rem 0 0.6rem;
}

.cc-pack-slot {
  position: relative;
  flex: 0 0 min(30%, 130px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  padding: 0;
  border: none;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
  animation: cc-deal 0.35s ease-out both;
}

.cc-pack-slot:disabled {
  cursor: default;
}

@keyframes cc-deal {
  from { transform: translateY(30px) scale(0.8); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.cc-card-back {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 12%;
  border: 3px solid #8b7dff;
  background: repeating-linear-gradient(45deg, #4a3fb8 0 8px, #3b2f9e 8px 16px);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.85);
  transition: transform 0.15s ease;
}

.cc-pack-slot:not(:disabled):hover .cc-card-back {
  transform: translateY(-4px);
}

.cc-card.cc-glow {
  box-shadow: 0 0 0 2px var(--rarity-color), 0 0 18px var(--rarity-color);
}

.cc-new-badge {
  position: absolute;
  top: -0.45rem;
  right: -0.45rem;
  background: var(--win);
  color: #1e1f29;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  padding: 0.15rem 0.4rem;
  border-radius: 999px;
}

.cc-pack-slot .cc-caption {
  font-size: 0.8rem;
}

/* Collection groups: name, found / total, and a progress meter (the track
   is a darker step of the accent, the fill the accent itself). */
.cc-group-by {
  margin: 0.2rem 0 0.4rem;
}

.cc-group-head {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  gap: 0.3rem 0.5rem;
  margin: 1rem 0 0.6rem;
}

.cc-group-head .cc-rarity-heading {
  margin: 0;
}

.cc-group-count {
  font-size: 0.85rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.cc-meter {
  grid-column: 1 / -1;
  height: 0.45rem;
  border-radius: 999px;
  background: rgba(108, 99, 255, 0.22);
  overflow: hidden;
}

.cc-meter span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
}

/* The opponent's cards in hand: an outline in their color, face down. */
.cc-card-hidden {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 12%;
  border: 3px solid var(--muted);
  background: repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.04) 0 6px, transparent 6px 12px), var(--bg);
}

.cc-card-hidden.red {
  border-color: var(--red-color);
}

.cc-card-hidden.blue {
  border-color: var(--blue-color);
}

/* Catalog: unfound cards, tappable items and the close-up */
.cc-catalog-item {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
}

.cc-catalog-item:focus-visible .cc-card,
.cc-catalog-item:focus-visible .cc-card-unfound {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.cc-card-unfound {
  container-type: inline-size;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 12%;
  border: 3px dashed var(--rarity-color, var(--muted));
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4cqw;
}

.cc-unfound-no {
  font-size: 20cqw;
  font-weight: 800;
  color: var(--muted);
}

.cc-unfound-rarity {
  font-size: 10cqw;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--rarity-color);
}

.cc-tap-hint {
  margin: 0.4rem 0 0;
}

.cc-dialog {
  border: none;
  border-radius: 1rem;
  padding: 0;
  background: var(--panel);
  color: var(--text);
  width: min(92vw, 360px);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
}

.cc-dialog::backdrop {
  background: rgba(10, 10, 16, 0.7);
}

.cc-closeup {
  padding: 1.25rem;
  text-align: center;
}

.cc-closeup-card {
  width: min(200px, 56vw);
  margin: 0 auto 0.8rem;
}

.cc-closeup-title {
  margin: 0;
  font-size: 1.3rem;
}

.cc-closeup-meta {
  margin: 0.25rem 0 0.9rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.cc-closeup-stats {
  display: grid;
  grid-template-columns: auto auto;
  justify-content: space-between;
  gap: 0.35rem 1rem;
  margin: 0 0 0.6rem;
  padding: 0.7rem 0.9rem;
  background: var(--cell);
  border-radius: 0.6rem;
  text-align: left;
  font-size: 0.9rem;
}

.cc-closeup-stats dt {
  color: var(--muted);
}

.cc-closeup-stats dd {
  margin: 0;
  text-align: right;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.cc-closeup-stats:empty {
  display: none;
}

.cc-closeup .reset-btn {
  margin-top: 0.6rem;
}

/* Hand picker: Cards / My Decks tabs, saving a deck, the deck list */
.cc-tabs {
  margin-bottom: 0.8rem;
}

.cc-save-deck {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: -0.4rem 0 1rem;
}

.cc-save-deck .cc-input {
  flex: 1 1 10rem;
  padding: 0.55rem 0.7rem;
}

.cc-save-deck .reset-btn {
  padding: 0.55rem 1rem;
  font-size: 0.95rem;
}

.cc-play-btn {
  margin-top: 0.2rem;
}

.cc-deck-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 1.2rem;
  text-align: left;
}

.cc-deck-row {
  background: var(--cell);
  border: 2px solid transparent;
  border-radius: 0.8rem;
  padding: 0.6rem 0.7rem 0.4rem;
  transition: border-color 0.15s ease;
}

.cc-deck-row.selected {
  border-color: var(--accent);
}

.cc-deck-pick {
  display: block;
  width: 100%;
  padding: 0;
  border: none;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
}

.cc-deck-pick:disabled {
  cursor: default;
  opacity: 0.6;
}

.cc-deck-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
}

.cc-deck-cards {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.35rem;
}

.cc-deck-actions {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  margin-top: 0.35rem;
}

.cc-link-btn {
  background: none;
  border: none;
  padding: 0.25rem 0;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: #a9a4ff;
  cursor: pointer;
}

.cc-link-btn:hover {
  text-decoration: underline;
}

/* Online profile: Google sign-in button, status, profile choice */
.cc-cloud-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.6rem;
}

.cc-google-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  background: #fff;
  color: #1f1f1f;
  border: 1px solid #747775;
  border-radius: 999px;
  padding: 0.55rem 1.1rem 0.55rem 0.9rem;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}

.cc-google-btn:hover {
  background: #f2f2f2;
}

.cc-google-btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.cc-cloud-badge {
  font-size: 0.8rem;
  color: var(--muted);
  text-decoration: none;
}

.cc-cloud-badge:hover {
  color: var(--text);
}

.cc-setup-cloud {
  margin-top: 1rem;
}

.cc-setup-cloud .cc-cloud-actions {
  justify-content: center;
}

.cc-or {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0 0 0.6rem;
}

.cc-or::before,
.cc-or::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--cell-hover);
}

/* Play buttons: the computer, or (online) another player. */
.cc-play-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.6rem;
}

/* Find a Player: three cards shuffling while the queue looks. */
.cc-queue {
  padding: 1.2rem 0 0.4rem;
}

.cc-queue-cards {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.cc-queue-cards span {
  width: 3.2rem;
  aspect-ratio: 1 / 1;
  border-radius: 12%;
  background: linear-gradient(160deg, var(--accent), #3a3480);
  animation: cc-queue-bob 1.2s ease-in-out infinite;
}

.cc-queue-cards span:nth-child(2) {
  animation-delay: 0.2s;
}

.cc-queue-cards span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes cc-queue-bob {
  0%, 100% { transform: translateY(0); opacity: 0.6; }
  50% { transform: translateY(-0.5rem); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .cc-queue-cards span {
    animation: none;
  }
}

/* Live games: the turn clock beside the player whose turn it is. */
.cc-bar .cc-timer {
  margin-left: auto;
  margin-right: 0.6rem;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--muted);
}

.cc-bar .cc-timer.cc-low {
  color: var(--win);
}

.cc-resign {
  display: block;
  margin: 0.2rem auto 0;
  color: var(--muted);
}

/* Strikes on an owned copy: marks in the card's bottom-right corner, clear
   of the bottom number. */
.cc-strikes {
  position: absolute;
  right: 8%;
  bottom: 6%;
  display: flex;
  gap: 2cqi;
}

.cc-strike {
  width: 9cqi;
  height: 9cqi;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.6);
  background: rgba(0, 0, 0, 0.35);
}

.cc-strike.on {
  background: var(--red-color);
  border-color: #fff;
}

.cc-result-strikes .cc-note {
  margin-bottom: 0.2rem;
}

.cc-struck {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
}

.cc-struck .cc-caption {
  font-size: 0.75rem;
}

.cc-struck.cc-lost .cc-card {
  filter: grayscale(1) brightness(0.6);
}

.cc-struck.cc-lost .cc-caption {
  color: var(--red-color);
}

/* Claim choices can carry a NEW tag in the corner. */
#claimChoices .cc-hand-card {
  position: relative;
}

/* Rarity filter chips (hand picker, collection): smaller than the main
   options, each rarity's chip edged in its color. */
.cc-filter {
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.6rem;
}

.cc-filter .size-option {
  flex: 0 1 auto;
  padding: 0.35rem 0.8rem;
  font-size: 0.85rem;
  border-radius: 999px;
}

.cc-filter .size-option[style*="--rarity-color"] {
  box-shadow: inset 0 -2px 0 var(--rarity-color);
}

.cc-filter .size-option.selected[style*="--rarity-color"] {
  border-color: var(--rarity-color);
}

.cc-pick-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.4rem 0.6rem;
}

.cc-pick-tools .cc-filter {
  margin-bottom: 0;
}

.cc-sort {
  width: auto;
  margin-left: auto;
  margin-bottom: 0.6rem;
  padding: 0.35rem 0.6rem;
  font-size: 0.85rem;
}

/* The pack shop: one offer per pack, side by side when there's room. */
.cc-pack-offers {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr));
  gap: 1.2rem;
}

.cc-pack-art[data-pack="legend"] {
  background: linear-gradient(155deg, #fff3b0 0%, #f59e0b 35%, #b45309 70%, #451a03 100%);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.45), 0 0 22px rgba(245, 158, 11, 0.65),
    inset 0 0 0 3px rgba(255, 255, 255, 0.35);
}

.cc-pack-art[data-pack="apex"] {
  background: linear-gradient(155deg, #f0abfc 0%, #c084fc 35%, #7c3aed 70%, #3b1a6e 100%);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.45), 0 0 18px rgba(192, 132, 252, 0.55),
    inset 0 0 0 3px rgba(255, 255, 255, 0.3);
}

/* Upgraded numbers: gold, with a soft glow. */
.cc-num.cc-up {
  color: #fcd34d;
  text-shadow: 0 0 4cqw rgba(252, 211, 77, 0.75), 0 1px 2px rgba(0, 0, 0, 0.7);
}

/* Level and XP in the profile bar. */
.cc-level-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.15rem;
}

.cc-level {
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--win);
}

.cc-xp-bar {
  position: relative;
  width: 4.5rem;
  height: 0.4rem;
  border-radius: 999px;
  background: var(--cell-hover);
  overflow: hidden;
}

.cc-xp-bar > span {
  position: absolute;
  inset: 0 auto 0 0;
  background: var(--win);
  border-radius: 999px;
}

.cc-xp-text {
  font-size: 0.75rem;
}

.cc-result-xp {
  margin: -0.3rem 0 0.6rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
}

.cc-result-xp.cc-level-up {
  color: var(--win);
  font-weight: 800;
}

/* Upgrading a copy (collection close-up). */
.cc-upgrade {
  margin-top: 0.6rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--cell-hover);
  text-align: left;
}

.cc-upgrade-title {
  margin: 0 0 0.2rem;
  font-size: 1rem;
}

.cc-upgrade-copies {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.4rem 0;
}

.cc-upgrade-copies .cc-hand-card {
  flex: 0 0 3.6rem;
}

.cc-upgrade-sides {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.4rem;
  margin: 0.4rem 0;
}

.cc-upgrade-sides .size-option {
  padding: 0.5rem 0.3rem;
  font-size: 0.85rem;
}

.cc-upgrade-sides .size-option:disabled {
  opacity: 0.5;
  cursor: default;
}

.cc-upgrade-cost {
  margin: 0.2rem 0 0.4rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.cc-upgrade .reset-btn {
  width: 100%;
}

/* The WildFlip logo beside the title. */
.cc-title {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.cc-logo {
  width: 1.3em;
  height: 1.3em;
}

/* Admin-only pages for everyone else: just the title, the note and the way back. */
.cc-locked > :not(h1):not(.cc-gate) {
  display: none !important;
}

/* --- The tour --- */
.cc-tour-dots {
  display: flex;
  justify-content: center;
  gap: 0.35rem;
  margin: 0.2rem 0 0.6rem;
}

.cc-tour-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--cell-hover);
}

.cc-tour-dot.done {
  background: var(--muted);
}

.cc-tour-dot.on {
  background: var(--win);
}

/* The coach: what to do now. */
.cc-coach {
  background: var(--cell);
  border-left: 4px solid var(--win);
  border-radius: 0.7rem;
  padding: 0.7rem 0.9rem;
  margin-bottom: 0.8rem;
  text-align: left;
}

.cc-coach-title {
  margin: 0 0 0.3rem;
  font-size: 1.05rem;
}

.cc-coach-text {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.45;
}

.cc-tour-stage {
  min-height: 12rem;
}

.cc-tour-nav {
  margin-top: 1rem;
}

.cc-tour-skip {
  margin: 0.6rem 0 0;
  font-size: 0.85rem;
}

/* Whatever the tour wants tapped next glows. */
.cc-tour-hint {
  animation: cc-tour-pulse 1.1s ease-in-out infinite;
  border-radius: 0.6rem;
}

@keyframes cc-tour-pulse {
  0%, 100% { box-shadow: 0 0 0 2px var(--win); }
  50% { box-shadow: 0 0 0 4px var(--win), 0 0 16px var(--win); }
}

@media (prefers-reduced-motion: reduce) {
  .cc-tour-hint {
    animation: none;
    box-shadow: 0 0 0 3px var(--win);
  }
}

.cc-tour-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.cc-tour-logo {
  width: 8rem;
  height: 8rem;
}

.cc-tour-list {
  text-align: left;
  line-height: 1.5;
  padding-left: 1.2rem;
}

.cc-tour-table {
  margin: 0.8rem 0;
}

.cc-tour-claim .cc-hand-card,
.cc-tour-copies .cc-hand-card {
  position: relative;
  flex-basis: min(30%, 110px);
}

.cc-tour-closeup {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.cc-tour-closeup .cc-card {
  width: 7rem;
}

.cc-tour-link {
  display: inline-block;
  margin: 0.3rem 0 0.6rem;
}

/* Levels: cards not released yet, and packs not unlocked yet. */
.cc-unfound-lock {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--muted);
}

.cc-pack-locked .cc-pack-art {
  filter: grayscale(0.7) brightness(0.7);
}

/* --- Bottom navigation (cards-ui.js) ---
   Fixed to the bottom of the screen on every WildFlip page except during a
   game; pages leave room for it. */
body.cc-with-nav {
  padding-bottom: calc(4.6rem + env(safe-area-inset-bottom));
}

.cc-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  justify-content: center;
  background: rgba(30, 31, 41, 0.96);
  border-top: 1px solid var(--cell);
  box-shadow: 0 -6px 20px rgba(0, 0, 0, 0.35);
  padding: 0.3rem env(safe-area-inset-right) calc(0.3rem + env(safe-area-inset-bottom)) env(safe-area-inset-left);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.cc-nav[hidden] {
  display: none;
}

.cc-nav-item {
  flex: 1;
  max-width: 7.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  padding: 0.35rem 0.2rem;
  border-radius: 0.6rem;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  text-decoration: none;
}

.cc-nav-item svg {
  width: 1.5rem;
  height: 1.5rem;
}

.cc-nav-item:hover {
  color: var(--text);
}

.cc-nav-item[aria-current="page"] {
  color: var(--text);
  background: rgba(108, 99, 255, 0.22);
}

.cc-nav-item[aria-current="page"] svg {
  color: #a9a4ff;
}

/* The play buttons stay in reach above the bottom bar on Home and Play. */
.cc-play-bar {
  position: sticky;
  bottom: calc(4.6rem + env(safe-area-inset-bottom));
  z-index: 5;
  margin: 0.8rem -0.6rem 0.4rem;
  padding: 0.6rem;
  border-radius: 0.8rem;
  background: var(--panel);
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.35);
}

.cc-play-bar {
  flex-wrap: nowrap;
}

.cc-play-bar .reset-btn {
  flex: 1 1 0;
  max-width: 13rem;
  margin-top: 0;
  padding: 0.7rem 0.6rem;
  font-size: 0.95rem;
}

#cardsTab .cc-tap-hint {
  margin-bottom: 0.7rem;
}

/* The deck's cards on Home and Play, with "+" for each empty slot. */
.cc-home-deck {
  margin-bottom: 0.2rem;
}

.cc-empty-slot {
  aspect-ratio: 1 / 1;
  border-radius: 12%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed var(--cell-hover) !important;
  color: var(--muted);
  font-size: 1.4rem;
}

#homeView .cc-heading-row {
  margin-top: 0.4rem;
}

#homeView .cc-tour-link {
  display: inline-block;
  margin-top: 0.8rem;
}

/* Close-up extras: the corner close button, copies and deck panel. */
.cc-closeup {
  position: relative;
}

.cc-closeup-x {
  position: absolute;
  top: 0.4rem;
  right: 0.5rem;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.6rem;
  line-height: 1;
  padding: 0.3rem 0.5rem;
  cursor: pointer;
}

.cc-closeup-x:hover {
  color: var(--text);
}

.cc-closeup-copies {
  justify-content: center;
  margin: 0 0 0.6rem;
}

.cc-closeup-deck .reset-btn {
  width: 100%;
}

.cc-closeup-play {
  display: block;
  margin-top: 0.6rem;
  text-align: center;
}

.cc-dialog {
  max-height: 92dvh;
}

.cc-dialog [hidden] {
  display: none !important;
}

.cc-closeup-deck .cc-upgrade-copies {
  flex-wrap: nowrap;
}

.cc-closeup-deck .cc-upgrade-copies .cc-hand-card {
  flex: 1 1 0;
  min-width: 0;
}

/* --- Players waiting (online): Play in the bottom bar and Find a Player --- */
.cc-nav-item {
  position: relative;
}

.cc-nav-item.cc-nav-alert {
  color: var(--text);
  animation: cc-nav-glow 1.6s ease-in-out infinite;
}

.cc-nav-item.cc-nav-alert svg {
  color: var(--red-color);
}

@keyframes cc-nav-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
  50% { box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.45); }
}

.cc-nav-badge {
  position: absolute;
  top: 0.15rem;
  right: calc(50% - 1.5rem);
  min-width: 1.15rem;
  height: 1.15rem;
  padding: 0 0.3rem;
  border-radius: 999px;
  background: var(--red-color);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 800;
  line-height: 1.15rem;
}

.reset-btn.cc-find-hot {
  background: var(--red-color);
  color: #fff;
  animation: cc-nav-glow 1.6s ease-in-out infinite;
}

.cc-play-bar {
  flex-wrap: wrap;
}

.cc-lobby-note {
  flex-basis: 100%;
  margin: 0.2rem 0 0;
  color: #fca5a5;
  font-size: 0.85rem;
  font-weight: 700;
}

/* --- Bonus notes --- */
.cc-toasts {
  position: fixed;
  top: calc(0.8rem + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  width: min(92vw, 380px);
  pointer-events: none;
}

.cc-toast {
  background: var(--panel);
  border: 1px solid var(--win);
  color: var(--win);
  border-radius: 0.8rem;
  padding: 0.7rem 0.9rem;
  font-weight: 700;
  font-size: 0.95rem;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  animation: cc-toast-in 0.35s ease-out;
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.cc-toast-out {
  opacity: 0;
  transform: translateY(-0.5rem);
}

@keyframes cc-toast-in {
  from { opacity: 0; transform: translateY(-0.8rem) scale(0.96); }
  to { opacity: 1; transform: none; }
}

/* --- First upgrade walkthrough --- */
.cc-coach-note {
  margin: 0.4rem 0;
}

.cc-coach-pulse {
  border-radius: 0.6rem;
  animation: cc-coach-pulse 1.2s ease-in-out infinite;
}

@keyframes cc-coach-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 209, 102, 0); }
  50% { box-shadow: 0 0 0 4px rgba(255, 209, 102, 0.7); }
}

/* --- Flip effects: a ring from each flipped card, "+N" from the flipper --- */
.cc-slot {
  position: relative;
}

.cc-burst {
  position: absolute;
  inset: 8%;
  border-radius: 18%;
  border: 3px solid currentColor;
  pointer-events: none;
  animation: cc-burst 0.6s ease-out 0.15s both;
}

.cc-burst.red,
.cc-flip-count.red {
  color: var(--red-color);
}

.cc-burst.blue,
.cc-flip-count.blue {
  color: var(--blue-color);
}

@keyframes cc-burst {
  from { opacity: 0.9; transform: scale(0.85); }
  to { opacity: 0; transform: scale(1.35); }
}

.cc-flip-count {
  position: absolute;
  left: 50%;
  top: 10%;
  z-index: 2;
  font-size: 1.5rem;
  font-weight: 900;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.8), 0 0 2px #fff;
  pointer-events: none;
  animation: cc-flip-count 1s ease-out both;
}

@keyframes cc-flip-count {
  0% { opacity: 0; transform: translate(-50%, 20%) scale(0.6); }
  25% { opacity: 1; transform: translate(-50%, -10%) scale(1.15); }
  100% { opacity: 0; transform: translate(-50%, -80%) scale(1); }
}

/* --- Today's offer in the Store --- */
.cc-daily {
  background: linear-gradient(160deg, rgba(108, 99, 255, 0.22), rgba(255, 209, 102, 0.1));
  border: 1px solid var(--accent);
  border-radius: 0.9rem;
  padding: 0.8rem;
  margin-bottom: 1rem;
  text-align: center;
}

.cc-daily .cc-heading-row {
  align-items: center;
}

.cc-daily-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin: 0.6rem 0;
}

.cc-daily-item {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.cc-daily-face {
  position: relative;
}

.cc-daily-bought .cc-daily-face {
  opacity: 0.5;
}

.cc-daily-buy {
  padding: 0.45rem 0.3rem;
  font-size: 0.9rem;
}

/* --- My Progress --- */
.cc-progress {
  text-align: left;
}

.cc-progress-block {
  margin-bottom: 1.2rem;
}

.cc-progress-row {
  background: var(--cell);
  border-radius: 0.6rem;
  padding: 0.6rem 0.8rem;
  margin-bottom: 0.5rem;
}

.cc-progress-row p {
  margin: 0.3rem 0 0;
}

.cc-progress-row .cc-meter {
  margin-top: 0.4rem;
}

.cc-progress-head {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
}

.cc-progress-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}

.cc-progress-card {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  .cc-nav-item.cc-nav-alert,
  .reset-btn.cc-find-hot,
  .cc-coach-pulse,
  .cc-burst,
  .cc-flip-count,
  .cc-toast {
    animation: none;
  }

  .cc-burst,
  .cc-flip-count {
    display: none;
  }
}

.cc-progress-card .cc-caption .cc-muted {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
  font-size: 0.75rem;
}

/* --- Background theme (GameTheme in cards-ui.js): the deck's set colors and
   animals, on a layer fixed behind the page. --- */
body.cc-themed::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    var(--theme-pattern, none) 0 0 / 240px 240px repeat,
    radial-gradient(120% 80% at 50% 0%, rgba(255, 255, 255, 0.06), transparent 60%),
    linear-gradient(160deg, var(--theme-a, var(--bg)), var(--theme-b, var(--bg)));
  transition: opacity 0.4s ease;
}

body.cc-themed {
  background: var(--bg);
}

body.cc-themed .game.cc-page,
body.cc-themed .game {
  background: rgba(42, 44, 58, 0.82);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

body.cc-themed.cc-in-game .game.cc-page {
  background: rgba(42, 44, 58, 0.55);
}

/* Cards at the player's level (Collection, My Progress) */
.cc-avail-table {
  width: 100%;
}

.cc-avail-table td {
  font-variant-numeric: tabular-nums;
}

.cc-avail-total th,
.cc-avail-total td {
  font-weight: 800;
  border-top: 1px solid var(--cell-hover);
}

.cc-availability .settings-hint {
  margin-top: 0.4rem;
  text-align: left;
}

.cc-avail-next {
  display: block;
  font-size: 0.75rem;
}

/* A card's number on the cards to claim after a win. */
.cc-card-no {
  position: absolute;
  bottom: -1.35rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel);
  border: 1px solid var(--cell-hover);
  color: var(--text);
  font-size: 0.7rem;
  font-weight: 800;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  white-space: nowrap;
}

.cc-hand-card.cc-claimed {
  position: relative;
}

#claimChoices {
  padding-bottom: 1.6rem;
}

/* --- Analytics (admins) --- */
.game.cc-page.cc-wide {
  width: min(96vw, 960px);
}

.cc-an-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: flex-end;
  justify-content: center;
  margin-bottom: 1rem;
}

.cc-an-pick {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.8rem;
  color: var(--muted);
  text-align: left;
}

.cc-an-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.cc-an-kpi {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  background: var(--cell);
  border-radius: 0.6rem;
  padding: 0.6rem 0.7rem;
  text-align: left;
}

.cc-an-kpi strong {
  font-size: 1.5rem;
  font-variant-numeric: tabular-nums;
}

.cc-an-kpi-label {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 600;
}

.cc-an-recs {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.cc-an-rec {
  background: var(--cell);
  border-left: 4px solid var(--muted);
  border-radius: 0.5rem;
  padding: 0.6rem 0.8rem;
}

.cc-an-rec p {
  margin: 0.25rem 0 0;
  line-height: 1.4;
  font-size: 0.92rem;
}

.cc-an-change {
  border-left-color: #e8590c;
}

.cc-an-watch {
  border-left-color: var(--win);
}

.cc-an-ok {
  border-left-color: #0f9f9a;
}

.cc-an-tag {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
}

.cc-an-charts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr));
  gap: 0.8rem;
  margin-bottom: 1rem;
}

.cc-an-chart {
  background: var(--cell);
  border-radius: 0.6rem;
  padding: 0.6rem 0.7rem;
  text-align: left;
}

.cc-an-chart-title {
  margin: 0 0 0.3rem;
  font-size: 0.92rem;
}

.cc-an-svg {
  width: 100%;
  height: auto;
  display: block;
  overflow: visible;
}

.cc-an-bar {
  fill: #3987e5;
}

.cc-an-line {
  fill: none;
  stroke: #3987e5;
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.cc-an-dot {
  fill: #3987e5;
  stroke: var(--cell);
  stroke-width: 2;
}

.cc-an-axis {
  stroke: var(--muted);
  stroke-width: 1;
}

.cc-an-grid {
  stroke: var(--cell-hover);
  stroke-width: 1;
  stroke-dasharray: 3 3;
}

.cc-an-tick,
.cc-an-sub {
  fill: var(--muted);
  font-size: 11px;
}

.cc-an-sub {
  font-weight: 700;
}

.cc-an-hit {
  fill: transparent;
  cursor: default;
}

.cc-an-hit:hover,
.cc-an-hit:focus {
  fill: rgba(255, 255, 255, 0.06);
  outline: none;
}

.cc-an-tip {
  position: fixed;
  z-index: 60;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--cell-hover);
  border-radius: 0.4rem;
  padding: 0.3rem 0.5rem;
  font-size: 0.8rem;
  pointer-events: none;
  white-space: nowrap;
}

.cc-an-table summary {
  cursor: pointer;
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.3rem;
}

.cc-an-brief {
  text-align: left;
  background: var(--cell);
  border-radius: 0.6rem;
  padding: 0.6rem 1rem;
  line-height: 1.5;
  font-size: 0.92rem;
  -webkit-user-select: text;
  user-select: text;
}

.cc-an-brief h2 {
  font-size: 1.1rem;
}

.cc-an-brief h3 {
  font-size: 0.98rem;
  margin: 0.9rem 0 0.3rem;
}

.cc-an-brief ul {
  padding-left: 1.2rem;
  margin: 0.2rem 0;
}

/* Analytics: the Players table */
#playersBox {
  margin-top: 1rem;
}

.cc-an-search {
  flex: 0 1 14rem;
  padding: 0.4rem 0.7rem;
  font-size: 0.9rem;
}

.cc-an-scroll {
  overflow-x: auto;
  margin-bottom: 1rem;
}

.cc-an-players {
  width: 100%;
  min-width: 640px;
  font-variant-numeric: tabular-nums;
}

.cc-an-players thead button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-transform: inherit;
  letter-spacing: inherit;
}

.cc-an-players thead button::after {
  content: attr(data-arrow);
  margin-left: 0.25rem;
  font-size: 0.7em;
}

.cc-tour-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4rem 1.2rem;
  margin: 0.8rem 0 0;
}

#homeView .cc-tour-links .cc-tour-link {
  margin-top: 0;
}

/* Cards with an upgrade ready: a bright yellow border, everywhere they show. */
:root {
  --upgrade-ready: #ffd400;
}

.cc-upgradable {
  position: relative;
}

.cc-upgradable .cc-card,
.cc-upgradable .cc-card-unfound {
  box-shadow: 0 0 0 3px var(--upgrade-ready), 0 0 14px rgba(255, 212, 0, 0.55);
  border-radius: 12%;
}

.cc-upgradable::before {
  content: "⬆";
  position: absolute;
  top: -0.45rem;
  left: -0.35rem;
  z-index: 2;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  background: var(--upgrade-ready);
  color: #1e1f29;
  font-size: 0.75rem;
  font-weight: 900;
  line-height: 1.25rem;
  text-align: center;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

/* The "ready to upgrade" banner at the top of Collection. */
.cc-ready {
  background: rgba(255, 212, 0, 0.12);
  border: 2px solid var(--upgrade-ready);
  border-radius: 0.9rem;
  padding: 0.8rem;
  margin-bottom: 1.2rem;
  text-align: center;
}

.cc-ready-title {
  margin: 0;
  font-size: 1.15rem;
  color: var(--upgrade-ready);
}

.cc-ready-hint {
  margin: 0.2rem 0 0.7rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.cc-ready-cards {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.7rem;
}

.cc-ready-cards .cc-hand-card {
  flex: 0 0 calc((100% - 2.8rem) / 5);
  max-width: 5.2rem;
}

@media (prefers-reduced-motion: no-preference) {
  .cc-ready .cc-upgradable .cc-card {
    animation: cc-ready-glow 1.8s ease-in-out infinite;
  }
}

@keyframes cc-ready-glow {
  0%, 100% { box-shadow: 0 0 0 3px var(--upgrade-ready), 0 0 8px rgba(255, 212, 0, 0.35); }
  50% { box-shadow: 0 0 0 3px var(--upgrade-ready), 0 0 18px rgba(255, 212, 0, 0.75); }
}

/* Lost cards (third strike): greyed out in Collection and the close-up. */
.cc-lost-card .cc-card,
.cc-lost-face {
  filter: grayscale(1);
  opacity: 0.55;
}

.cc-lost-card .cc-count {
  background: var(--cell-hover);
  color: var(--muted);
}

/* BACK: a lost card that's on offer again. */
.cc-back-badge {
  background: #9ad7ff;
  color: #10202c;
}

/* Collection: search, sort and show controls */
.cc-collect-tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0.5rem;
  margin-bottom: 0.8rem;
}

.cc-collect-search {
  grid-column: 1 / -1;
  padding: 0.5rem 0.7rem;
  font-size: 0.95rem;
}

.cc-collect-tool {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  text-align: left;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.cc-collect-tool .cc-select {
  font-size: 0.9rem;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
}

/* MAX (all upgrades) and ULTRA (two Max copies merged) cards */
/* The tag sits in the card's empty bottom-right corner. */
.cc-tier {
  position: absolute;
  bottom: 5%;
  right: 4%;
  z-index: 2;
  padding: 0.1em 0.35em;
  border-radius: 999px;
  font-size: 7.5cqw;
  font-weight: 900;
  letter-spacing: 0.06em;
  line-height: 1.3;
  white-space: nowrap;
  pointer-events: none;
}

.cc-max .cc-tier {
  background: #ffd166;
  color: #1e1f29;
}

.cc-ultra {
  box-shadow: 0 0 0 2px #fff, 0 0 12px rgba(255, 255, 255, 0.5);
}

.cc-ultra .cc-tier {
  background: linear-gradient(90deg, #ff6b6b, #ffd166, #4ecdc4, #6c63ff, #f472b6);
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

.cc-merge .cc-closeup-play {
  margin-top: 0.4rem;
}

/* Legendary cards: a molten gold border and gem, a slow shimmer, and in play
   (where the border shows the player's color) a gold inner ring. */
.cc-card[data-rarity="legendary"] {
  border-color: transparent;
  background:
    linear-gradient(160deg, #5a3d12, #2b1c08) padding-box,
    linear-gradient(135deg, #fff3b0, #f59e0b 40%, #b45309 70%, #fde68a) border-box;
}

.cc-card[data-rarity="legendary"].red {
  border-color: var(--red-color);
  background: linear-gradient(160deg, #c2414b, #6b1d26);
}

.cc-card[data-rarity="legendary"].blue {
  border-color: var(--blue-color);
  background: linear-gradient(160deg, #3c6fd8, #1b326e);
}

.cc-card[data-rarity="legendary"].red::after,
.cc-card[data-rarity="legendary"].blue::after {
  content: "";
  position: absolute;
  inset: 3cqw;
  border: 1.5px solid #fde68a;
  border-radius: 9%;
  box-shadow: 0 0 5cqw rgba(245, 158, 11, 0.7);
  pointer-events: none;
}

.cc-card[data-rarity="legendary"] .cc-gem {
  width: 15cqw;
  height: 15cqw;
  background: linear-gradient(135deg, #fffbeb 0%, #fde68a 30%, #f59e0b 60%, #b45309 100%);
  box-shadow: 0 0 0 1.5cqw rgba(0, 0, 0, 0.35), 0 0 9cqw #fbbf24;
}

@media (prefers-reduced-motion: no-preference) {
  .cc-card[data-rarity="legendary"].neutral::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(115deg, transparent 35%, rgba(255, 236, 160, 0.22) 50%, transparent 65%);
    background-size: 250% 100%;
    animation: cc-legend-shine 3.5s ease-in-out infinite;
    pointer-events: none;
  }
}

@keyframes cc-legend-shine {
  0% { background-position: 120% 0; }
  60%, 100% { background-position: -120% 0; }
}

/* A card whose strikes a win just cleared. */
.cc-cleared .cc-caption {
  color: #6ee7b7;
}

/* --- Blurry Ware studio splash (blurryware-splash.js): plays once a session
   over the game page while the player's data loads. --- */
html.bw-splash-on,
html.bw-splash-on body {
  overflow: hidden;
}

.bw-splash {
  position: fixed;
  inset: 0;
  z-index: 1000;
  overflow: hidden;
  background: radial-gradient(130% 80% at 50% 42%, #182134 0%, #070a12 72%);
  perspective: 700px;
  cursor: pointer;
  transition: opacity 0.55s ease;
}

.bw-splash.bw-splash-out {
  opacity: 0;
  pointer-events: none;
}

/* Larger than the screen, so the tilted plane's edges stay out of view. */
.bw-splash-tilt {
  position: absolute;
  inset: -18%;
  transform-style: preserve-3d;
  transform: rotateX(12deg) rotateY(-14deg);
  animation: bw-splash-sway 9s ease-in-out infinite alternate;
}

@keyframes bw-splash-sway {
  from { transform: rotateX(14deg) rotateY(-16deg); }
  to { transform: rotateX(6deg) rotateY(13deg); }
}

.bw-splash-tilt canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.bw-splash-soft {
  opacity: 0;
  will-change: filter, opacity, transform;
}

.bw-splash-loader {
  position: absolute;
  left: max(14%, env(safe-area-inset-left, 0px));
  right: max(14%, env(safe-area-inset-right, 0px));
  bottom: calc(11% + env(safe-area-inset-bottom, 0px));
  display: grid;
  gap: 10px;
}

.bw-splash-row {
  display: flex;
  justify-content: space-between;
  font: 500 10px/1 "Unbounded", "Arial Black", Impact, sans-serif;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(196, 208, 230, 0.8);
  font-variant-numeric: tabular-nums;
}

.bw-splash-track {
  height: 3px;
  border-radius: 3px;
  background: rgba(196, 208, 230, 0.18);
  overflow: hidden;
}

.bw-splash-bar {
  height: 100%;
  width: 0%;
  border-radius: 3px;
  background: linear-gradient(90deg, #c4d0e6, #ffb37a);
  box-shadow: 0 0 10px #ffb37a;
}

/* Privacy policy and terms */
.cc-legal {
  text-align: left;
  line-height: 1.55;
}

.cc-legal h1 {
  text-align: center;
}

.cc-legal h2 {
  font-size: 1.05rem;
  margin: 1.2rem 0 0.4rem;
}

.cc-legal ul {
  padding-left: 1.2rem;
  margin: 0.3rem 0;
}

.cc-legal li {
  margin-bottom: 0.35rem;
}

.cc-legal-draft {
  background: rgba(255, 209, 102, 0.12);
  border: 1px solid var(--win);
  border-radius: 0.6rem;
  padding: 0.6rem 0.8rem;
  font-size: 0.88rem;
}

.cc-legal-links {
  margin-top: 1.2rem;
  text-align: center;
  font-size: 0.9rem;
}
