:root {
  --bg: #fff4de;
  --bg-deep: #ffd39f;
  --ink: #26140a;
  --card: rgba(255, 250, 240, 0.86);
  --line: rgba(68, 34, 11, 0.12);
  --roll: #d93a2f;
  --buy: #2870ff;
  --gold: #ffb548;
  --gold-deep: #ff7d43;
  --success: #138a52;
  --shadow: 0 20px 60px rgba(109, 55, 8, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.65), transparent 35%),
    radial-gradient(circle at bottom right, rgba(255, 158, 54, 0.3), transparent 28%),
    linear-gradient(135deg, var(--bg), var(--bg-deep));
  transition: background 0.35s ease, color 0.35s ease;
}

body.event-rainbow {
  --bg: #fff0fa;
  --bg-deep: #ffd782;
  --card: rgba(255, 250, 253, 0.88);
}

body.event-radioactive {
  --bg: #2e0b12;
  --bg-deep: #593314;
  --ink: #ffffff;
  --card: rgba(55, 18, 26, 0.84);
  --line: rgba(255, 231, 214, 0.12);
  --shadow: 0 20px 60px rgba(11, 0, 0, 0.36);
}

body.event-radioactive .admin-panel,
body.event-radioactive .rebirth-panel,
body.event-radioactive .rebirth-card,
body.event-radioactive .rebirth-info-block,
body.event-radioactive .roll-timer-card,
body.event-radioactive .event-timer-card,
body.event-radioactive .character-stat,
body.event-radioactive .owned-card,
body.event-radioactive .stat-pill,
body.event-radioactive .sprite-frame {
  background: rgba(255, 245, 238, 0.9);
  color: #111111;
}

body.event-radioactive .topbar,
body.event-radioactive .roller-panel,
body.event-radioactive .collection-panel,
body.event-radioactive .headline-wrap h1,
body.event-radioactive .panel-title-row h2,
body.event-radioactive #characterName,
body.event-radioactive #characterFlavor,
body.event-radioactive #ownedViewerFlavor,
body.event-radioactive .owned-name,
body.event-radioactive #luckyBlockInventoryDisplay,
body.event-radioactive .chance-badge,
body.event-radioactive .eyebrow,
body.event-radioactive .small-note {
  color: #ffffff;
}

body.event-radioactive .admin-input,
body.event-radioactive .admin-select {
  background: rgba(255, 255, 255, 0.96);
  color: #111111;
  border-color: rgba(17, 17, 17, 0.12);
  -webkit-text-fill-color: #111111;
}

body.event-radioactive .admin-input::placeholder {
  color: rgba(17, 17, 17, 0.52);
  -webkit-text-fill-color: rgba(17, 17, 17, 0.52);
}

body.event-radioactive .admin-select option {
  color: #111111;
  background: #ffffff;
}

body.event-radioactive .rebirth-copy,
body.event-radioactive .status-text,
body.event-radioactive .flavor,
body.event-radioactive .owned-meta,
body.event-radioactive .label,
body.event-radioactive .rebirth-panel h2,
body.event-radioactive .rebirth-panel h3,
body.event-radioactive .character-stat span {
  color: rgba(17, 17, 17, 0.76);
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: auto;
  width: 18rem;
  height: 18rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
  filter: blur(12px);
  pointer-events: none;
}

body::before {
  top: 5%;
  right: 8%;
}

body::after {
  bottom: 2%;
  left: 4%;
}

.game-shell {
  max-width: 1240px;
  margin: 0 auto;
  padding: 24px;
}

.topbar,
.roller-panel,
.collection-panel,
.rebirth-panel {
  backdrop-filter: blur(14px);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  padding: 24px 28px;
}

.eyebrow,
.label,
.small-note,
.chance-badge,
.trait-tag,
.status-text,
.character-stat span {
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.eyebrow,
.small-note,
.status-text,
.label,
.character-stat span {
  font-size: 0.78rem;
}

.headline-wrap h1,
.panel-title-row h2,
#characterName {
  margin: 0;
}

.headline-wrap h1 {
  font-family: "Bungee", cursive;
  font-size: clamp(1.7rem, 3vw, 2.9rem);
  line-height: 1.08;
  max-width: 12ch;
}

.totals {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  align-items: flex-start;
}

.stat-pill {
  min-width: 170px;
  padding: 14px 16px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(38, 20, 10, 0.08);
}

.stat-pill strong {
  display: block;
  margin-top: 4px;
  font-size: 1.4rem;
}

.stat-pill.accent {
  background: linear-gradient(135deg, var(--gold), var(--gold-deep));
  color: white;
}

.stat-button {
  min-width: 170px;
  text-align: left;
  cursor: pointer;
  transition: transform 0.16s ease, filter 0.16s ease;
  border: none;
}

.stat-button:hover {
  transform: translateY(-2px);
  filter: brightness(1.04);
}

.stat-button:active {
  transform: translateY(0);
}

.rebirth-launch {
  min-height: 84px;
}

.admin-launch {
  min-height: 84px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(240, 232, 220, 0.95));
  color: var(--ink);
}

.main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  gap: 24px;
  margin-top: 24px;
}

.rebirth-page {
  margin-top: 24px;
}

.roller-panel,
.collection-panel,
.rebirth-panel {
  padding: 24px;
}

.panel-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.collection-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.viewer-panel {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid rgba(38, 20, 10, 0.08);
}

.chance-badge,
.trait-tag,
.rarity-tag {
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
}

.chance-badge {
  background: rgba(217, 58, 47, 0.12);
  color: #a7241c;
}

.sprite-card {
  margin-top: 18px;
  display: grid;
  grid-template-columns: minmax(240px, 320px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.compact-viewer {
  grid-template-columns: 140px minmax(0, 1fr);
}

.sprite-frame {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 26px;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(255, 186, 94, 0.4), rgba(255, 255, 255, 0.7)),
    #fff4e8;
  border: 1px solid rgba(38, 20, 10, 0.08);
}

.sprite-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.sprite-frame img.cutout-image {
  object-fit: contain;
  padding: 14px;
  background:
    radial-gradient(circle at center, rgba(255, 244, 222, 0.92), rgba(255, 255, 255, 0.72));
}

.sprite-frame img.mutation-rainbow {
  animation: rainbowImageShift 4s linear infinite;
}

.sprite-frame img.mutation-radioactive {
  animation: radioactivePulse 3.2s ease-in-out infinite;
}

.sprite-frame.rainbow {
  animation: rainbowGlow 3.6s linear infinite;
}

.sprite-frame.radioactive {
  animation: radioactiveGlow 2.8s ease-in-out infinite;
}

.name-line {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

#characterName {
  font-size: clamp(1.5rem, 3vw, 2.2rem);
}

.trait-tag {
  color: white;
  background: linear-gradient(135deg, #ff3f81, #ff9d00, #18b8ff, #58d84f);
  background-size: 200% 200%;
  animation: rainbowShift 4s ease infinite;
}

.trait-tag.radioactive {
  background: linear-gradient(135deg, #f32f3b, #7a1b92, #27b55f, #7d562d);
  background-size: 200% 200%;
  animation: rainbowShift 5s ease infinite;
}

.rarity-tag {
  background: rgba(38, 20, 10, 0.08);
  color: rgba(38, 20, 10, 0.82);
}

.rarity-tag.common {
  background: rgba(111, 118, 128, 0.16);
  color: #5f6670;
}

.rarity-tag.epic {
  background: rgba(130, 63, 255, 0.16);
  color: #7d32ff;
}

.rarity-tag.god {
  color: white;
  background: linear-gradient(135deg, #ff3f81, #ff9d00, #18b8ff, #58d84f);
  background-size: 200% 200%;
  animation: rainbowShift 4s ease infinite;
}

.rarity-tag.uncommon {
  background: rgba(31, 166, 86, 0.16);
  color: #16854a;
}

.rarity-tag.mythic {
  background: rgba(227, 41, 41, 0.16);
  color: #cf1f1f;
}

.rarity-tag.secret {
  background: linear-gradient(135deg, #111111, #f4f4f4);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.35);
}

.hidden {
  display: none;
}

.flavor {
  margin: 12px 0 18px;
  font-size: 1rem;
  line-height: 1.5;
  color: rgba(38, 20, 10, 0.8);
}

.character-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.character-stat {
  padding: 16px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid rgba(38, 20, 10, 0.08);
}

.character-stat strong {
  display: block;
  margin-top: 6px;
  font-size: 1.4rem;
}

.roll-timer-card {
  margin-top: 14px;
  padding: 16px;
  border-radius: 20px;
  background: linear-gradient(135deg, rgba(255, 193, 112, 0.3), rgba(255, 255, 255, 0.8));
  border: 1px solid rgba(38, 20, 10, 0.08);
}

.roll-timer-card span {
  display: block;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.roll-timer-card strong {
  display: block;
  margin-top: 6px;
  font-size: 1.4rem;
}

.event-timer-card {
  margin-top: 14px;
  padding: 16px;
  border-radius: 20px;
  border: 1px solid rgba(38, 20, 10, 0.08);
  background: rgba(255, 255, 255, 0.8);
}

.event-timer-card span {
  display: block;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.event-timer-card strong {
  display: block;
  margin-top: 6px;
  font-size: 1.4rem;
}

.event-timer-card.rainbow {
  background: linear-gradient(135deg, rgba(255, 91, 143, 0.18), rgba(255, 214, 120, 0.35), rgba(24, 184, 255, 0.18));
}

.event-timer-card.radioactive {
  background: linear-gradient(135deg, rgba(228, 41, 64, 0.2), rgba(115, 30, 164, 0.25), rgba(48, 164, 86, 0.2));
}

.button-row {
  display: flex;
  gap: 14px;
  margin-top: 20px;
}

.game-button {
  flex: 1;
  border: none;
  border-radius: 18px;
  padding: 16px 20px;
  font-size: 1rem;
  font-weight: 700;
  color: white;
  cursor: pointer;
  transition: transform 0.16s ease, filter 0.16s ease;
}

.game-button:hover {
  transform: translateY(-2px);
  filter: brightness(1.06);
}

.game-button:active {
  transform: translateY(0);
}

.game-button.buy {
  background: linear-gradient(135deg, #2363f4, #2d9dff);
}

.game-button.roll {
  background: linear-gradient(135deg, #ba1c11, #ff5c46);
}

.game-button.rebirth-action {
  margin-top: 22px;
  background: linear-gradient(135deg, #ff8f1f, #ff4e36);
}

.game-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  filter: none;
}

.mini-action {
  border: none;
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 0.8rem;
  font-weight: 700;
  color: white;
  cursor: pointer;
  background: linear-gradient(135deg, #ff8f1f, #ff4e36);
  transition: transform 0.16s ease, filter 0.16s ease;
}

.mini-action:hover {
  transform: translateY(-2px);
  filter: brightness(1.05);
}

.mini-action:active {
  transform: translateY(0);
}

.rebirth-grid,
.rebirth-info {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 20px;
}

.rebirth-card,
.rebirth-info-block {
  padding: 18px;
  border-radius: 24px;
  border: 1px solid rgba(38, 20, 10, 0.08);
  background: rgba(255, 255, 255, 0.8);
}

.rebirth-card strong,
.rebirth-info-block strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(1.5rem, 3vw, 2.2rem);
}

.rebirth-card.accent {
  background: linear-gradient(135deg, var(--gold), var(--gold-deep));
  color: white;
}

.rebirth-copy {
  margin: 22px 0 0;
  font-size: 1rem;
  line-height: 1.55;
  color: rgba(38, 20, 10, 0.82);
}

.back-button {
  border: none;
  border-radius: 18px;
  padding: 12px 18px;
  font-size: 0.95rem;
  font-weight: 700;
  color: white;
  cursor: pointer;
  background: linear-gradient(135deg, #3f4b68, #6c7896);
  transition: transform 0.16s ease, filter 0.16s ease;
}

.back-button:hover {
  transform: translateY(-2px);
  filter: brightness(1.05);
}

.back-button:active {
  transform: translateY(0);
}

.admin-panel {
  min-height: 360px;
}

.admin-auth-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px;
  gap: 14px;
  margin-top: 20px;
}

.admin-input,
.admin-select {
  width: 100%;
  border: 1px solid rgba(38, 20, 10, 0.12);
  border-radius: 18px;
  padding: 16px 18px;
  font: inherit;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.84);
}

.admin-input:focus,
.admin-select:focus {
  outline: 2px solid rgba(40, 112, 255, 0.22);
  border-color: rgba(40, 112, 255, 0.35);
}

.status-text {
  margin: 18px 4px 0;
  min-height: 1.2rem;
  color: rgba(38, 20, 10, 0.74);
}

.owned-list {
  margin-top: 18px;
  display: grid;
  gap: 12px;
}

.owned-card {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 12px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(38, 20, 10, 0.08);
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.owned-card:hover {
  transform: translateY(-2px);
  border-color: rgba(40, 112, 255, 0.2);
}

.owned-card.selected {
  border-color: rgba(40, 112, 255, 0.38);
  box-shadow: 0 12px 28px rgba(40, 112, 255, 0.12);
}

.owned-thumb {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 18px;
}

.owned-thumb.cutout-image {
  object-fit: contain;
  padding: 8px;
  background:
    radial-gradient(circle at center, rgba(255, 244, 222, 0.96), rgba(255, 255, 255, 0.84));
  border: 1px solid rgba(38, 20, 10, 0.08);
}

.owned-name {
  margin: 0 0 6px;
  font-weight: 700;
}

.owned-meta,
.owned-income {
  margin: 0;
  font-size: 0.92rem;
  color: rgba(38, 20, 10, 0.74);
}

.owned-income {
  text-align: right;
  font-weight: 700;
  color: var(--success);
}

.empty-state {
  padding: 22px;
  border-radius: 22px;
  border: 1px dashed rgba(38, 20, 10, 0.18);
  text-align: center;
  color: rgba(38, 20, 10, 0.68);
}

@keyframes rainbowShift {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

@keyframes rainbowGlow {
  0% {
    box-shadow: inset 0 0 0 4px rgba(255, 73, 118, 0.45);
  }
  33% {
    box-shadow: inset 0 0 0 4px rgba(255, 180, 56, 0.45);
  }
  66% {
    box-shadow: inset 0 0 0 4px rgba(17, 170, 255, 0.45);
  }
  100% {
    box-shadow: inset 0 0 0 4px rgba(255, 73, 118, 0.45);
  }
}

@keyframes radioactiveGlow {
  0% {
    box-shadow: inset 0 0 0 4px rgba(230, 54, 66, 0.5), 0 0 20px rgba(125, 86, 45, 0.15);
  }
  33% {
    box-shadow: inset 0 0 0 4px rgba(119, 30, 146, 0.52), 0 0 26px rgba(119, 30, 146, 0.18);
  }
  66% {
    box-shadow: inset 0 0 0 4px rgba(40, 181, 95, 0.52), 0 0 28px rgba(40, 181, 95, 0.18);
  }
  100% {
    box-shadow: inset 0 0 0 4px rgba(125, 86, 45, 0.5), 0 0 20px rgba(125, 86, 45, 0.15);
  }
}

@keyframes rainbowImageShift {
  0% {
    filter: hue-rotate(0deg) saturate(1.15) brightness(1.03);
  }
  100% {
    filter: hue-rotate(360deg) saturate(1.2) brightness(1.05);
  }
}

@keyframes radioactivePulse {
  0% {
    filter: hue-rotate(0deg) saturate(1.25) brightness(0.98) contrast(1.1) drop-shadow(0 0 0.35rem rgba(230, 54, 66, 0.38));
  }
  25% {
    filter: hue-rotate(26deg) saturate(1.35) brightness(1.02) contrast(1.15) drop-shadow(0 0 0.45rem rgba(119, 30, 146, 0.42));
  }
  50% {
    filter: hue-rotate(94deg) saturate(1.4) brightness(1.05) contrast(1.16) drop-shadow(0 0 0.5rem rgba(40, 181, 95, 0.45));
  }
  75% {
    filter: hue-rotate(-18deg) saturate(1.28) brightness(1.01) contrast(1.13) drop-shadow(0 0 0.4rem rgba(125, 86, 45, 0.42));
  }
  100% {
    filter: hue-rotate(0deg) saturate(1.25) brightness(0.98) contrast(1.1) drop-shadow(0 0 0.35rem rgba(230, 54, 66, 0.38));
  }
}

@media (max-width: 960px) {
  .topbar,
  .sprite-card,
  .main-grid,
  .rebirth-grid,
  .rebirth-info {
    display: grid;
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .game-shell {
    padding: 16px;
  }

  .topbar,
  .roller-panel,
  .collection-panel,
  .rebirth-panel {
    padding: 18px;
    border-radius: 22px;
  }

  .button-row,
  .character-stats,
  .rebirth-grid,
  .rebirth-info {
    grid-template-columns: 1fr;
  }

  .admin-auth-row {
    grid-template-columns: 1fr;
  }

  .owned-card {
    grid-template-columns: 60px minmax(0, 1fr);
  }

  .owned-income {
    text-align: left;
    grid-column: 2;
  }
}
