/* Base layout (v17/v18-style single column) */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #090909;
  color: #f5f5f5;
  display: flex;
  justify-content: center;
  align-items: stretch;
  transition: background-color 0.4s ease;
}

#app {
  width: 100%;
  height: 100vh;
  display: flex;
  justify-content: center;
}

.game-shell {
  width: 100%;
  max-width: 420px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: inherit;
}

.screen-shake {
  animation: screen-shake 0.6s linear;
}

@keyframes screen-shake {
  0% {
    transform: translate(0, 0);
  }
  10% {
    transform: translate(-3px, -3px);
  }
  20% {
    transform: translate(3px, -2px);
  }
  30% {
    transform: translate(-4px, 2px);
  }
  40% {
    transform: translate(4px, 3px);
  }
  50% {
    transform: translate(-3px, -1px);
  }
  60% {
    transform: translate(3px, 2px);
  }
  70% {
    transform: translate(-2px, -3px);
  }
  80% {
    transform: translate(2px, 3px);
  }
  90% {
    transform: translate(-1px, -2px);
  }
  100% {
    transform: translate(0, 0);
  }
}

/* Extra special drop effects (beyond Omega) */
.screen-flash {
  animation: screen-flash 0.9s ease-out;
}

@keyframes screen-flash {
  0% {
    background-color: #090909;
  }
  15% {
    background-color: #ffe082;
  }
  35% {
    background-color: #ffcc80;
  }
  65% {
    background-color: #090909;
  }
  100% {
    background-color: #090909;
  }
}

.screen-soft-glow {
  box-shadow: 0 0 40px 8px rgba(255, 196, 0, 0.45);
}

.current-card-rainbow {
  animation: current-card-rainbow 0.9s linear;
}

@keyframes current-card-rainbow {
  0% {
    box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.0);
    border: 1px solid rgba(255, 255, 255, 0.15);
  }
  25% {
    box-shadow: 0 0 20px 4px rgba(255, 235, 59, 0.9);
    border-color: #ffeb3b;
  }
  50% {
    box-shadow: 0 0 22px 5px rgba(244, 67, 54, 0.9);
    border-color: #f44336;
  }
  75% {
    box-shadow: 0 0 22px 5px rgba(103, 58, 183, 0.9);
    border-color: #673ab7;
  }
  100% {
    box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.0);
    border-color: rgba(255, 255, 255, 0.15);
  }
}

.current-card {
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.roll-button-slow {
  animation: roll-button-pulse 0.45s ease-in-out 0s 3;
}

@keyframes roll-button-pulse {
  0% {
    transform: scale(1);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.7);
  }
  50% {
    transform: scale(1.03);
    box-shadow: 0 16px 32px rgba(0, 0, 0, 0.9);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.7);
  }
}

/* Top stats row */
.top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.stats {
  display: flex;
  gap: 6px;
  flex: 1;
}

.stat {
  flex: 1;
  padding: 6px 8px;
  border-radius: 12px;
  background: #181818;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-label {
  font-size: 10px;
  color: #a0a0a0;
}

.stat-value {
  font-size: 16px;
  font-weight: 600;
}

/* Current item card */
.current-card {
  margin-top: 2px;
  padding: 10px;
  border-radius: 14px;
  background: radial-gradient(circle at top left, #303030 0, #141414 55%);
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
  overflow: hidden;
}

.current-card-special {
  animation: current-card-shine 0.8s ease-out forwards;
}

@keyframes current-card-shine {
  0% {
    box-shadow: 0 0 0 0 rgba(255, 248, 225, 0.0);
  }
  20% {
    box-shadow: 0 0 24px 4px rgba(255, 248, 225, 0.9);
  }
  60% {
    box-shadow: 0 0 18px 3px rgba(255, 248, 225, 0.6);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(255, 248, 225, 0.0);
  }
}

.current-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
}

.current-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.current-name {
  font-size: 16px;
  font-weight: 600;
}

.current-meta-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
}

.rarity-pill {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 500;
}

.current-power {
  font-size: 11px;
  color: #d0d0d0;
}

/* Roll button area */
.action-area {
  margin-top: 2px;
}

/* Recent rolls list */
.recent-section {
  margin-top: 4px;
  padding: 6px 8px;
  border-radius: 12px;
  background: #181818;
  font-size: 11px;
}

.recent-header {
  font-size: 10px;
  color: #b5b5b5;
  margin-bottom: 4px;
  font-weight: 600;
}

.recent-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 72px;
  overflow-y: auto;
}

.recent-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 0;
}

.recent-emoji {
  width: 20px;
  text-align: center;
}

.recent-text {
  flex: 1;
  font-size: 10px;
  color: #e0e0e0;
}

.roll-button {
  width: 100%;
  padding: 10px 0;
  border-radius: 999px;
  border: none;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.06em;
  background: linear-gradient(90deg, #ffb300, #ff5722);
  color: #111;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.7), 0 12px 24px rgba(0, 0, 0, 0.7);
  transform: translateY(0);
  transition: transform 0.08s ease-out, box-shadow 0.08s ease-out, opacity 0.08s;
}

.roll-button:active {
  transform: translateY(1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.7);
}

.roll-button:disabled {
  opacity: 0.7;
}

/* Tabbed panel controls (v17/v18 style) */
.top-mode-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 6px;
  background: #151515;
  padding: 4px;
  border-radius: 12px;
}

.top-mode-tab {
  flex: 1;
  border: none;
  border-radius: 8px;
  padding: 6px 0;
  font-size: 11px;
  background: #181818;
  color: #b5b5b5;
}

.top-mode-tab-active {
  background: #f5f5f5;
  color: #111111;
  font-weight: 600;
}

.mode-container {
  display: none;
  flex-direction: column;
  gap: 6px;
}

.mode-container-active {
  display: flex;
}

/* Shop */
.shop-section {
  margin-top: 6px;
}

.shop-subtitle {
  font-size: 9px;
  color: #808080;
}

.shop-category-tabs {
  display: flex;
  gap: 4px;
  margin-top: 4px;
  margin-bottom: 4px;
  background: #181818;
  padding: 3px;
  border-radius: 10px;
}

.shop-category-tab {
  flex: 1;
  border: none;
  border-radius: 7px;
  padding: 5px 0;
  font-size: 10px;
  background: #141414;
  color: #a0a0a0;
}

.shop-category-tab-active {
  background: #f5f5f5;
  color: #111111;
  font-weight: 600;
}

.shop-category-section {
  display: none;
  margin-top: 4px;
}

.shop-category-section-active {
  display: block;
}

.shop-rows {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 6px;
}

.shop-section-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #808080;
  margin: 2px 0 2px;
}

.shop-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 6px;
  border-radius: 8px;
  background: #151515;
  font-size: 10px;
}

.shop-label {
  color: #b0b0b0;
}

.shop-value {
  font-weight: 600;
  color: #f5f5f5;
}

.shop-button-row {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

.shop-buy-button {
  flex: 1;
  padding: 8px 0;
  border-radius: 999px;
  border: none;
  font-size: 12px;
  font-weight: 600;
  background: linear-gradient(90deg, #ffca28, #ff7043);
  color: #111;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.8);
}

.shop-buy-button:disabled {
  opacity: 0.4;
  box-shadow: none;
}

/* Shop item chances */
.shop-chances {
  margin-top: 6px;
  padding-top: 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.shop-chances-header {
  font-size: 9px;
  color: #808080;
  margin-bottom: 2px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.shop-chances-list {
  max-height: 120px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.shop-chance-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  padding: 2px 0;
  font-size: 9px;
  color: #e0e0e0;
}

.shop-chance-name {
  flex: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.shop-chance-meta {
  flex: 0.9;
  text-align: right;
  color: #aaaaaa;
}

.shop-chance-percent {
  flex: 0.6;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: #ffca28;
  font-weight: 600;
}

.panel-tabs {
  margin-top: 6px;
  display: flex;
  gap: 4px;
  background: #202020;
  padding: 4px;
  border-radius: 12px;
}

.panel-tab {
  flex: 1;
  border: none;
  border-radius: 8px;
  padding: 6px 0;
  font-size: 11px;
  background: #181818;
  color: #b5b5b5;
}

.panel-tab-active {
  background: #f5f5f5;
  color: #111111;
  font-weight: 600;
}

.panel-section {
  margin-top: 4px;
  padding: 8px;
  border-radius: 12px;
  background: #181818;
}

.panel-section-hidden {
  display: none;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: #b5b5b5;
  margin-bottom: 4px;
}

.panel-header span:first-child {
  font-weight: 600;
  color: #f0f0f0;
}

.best-count {
  font-size: 10px;
  color: #808080;
}

/* Lists for best and inventory */
.best-list {
  max-height: 160px;
  overflow-y: auto;
  padding-right: 2px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.best-card {
  border-radius: 10px;
  background: #202020;
  padding: 6px 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: background 0.1s, transform 0.08s;
}

.best-card:hover {
  background: #262626;
}

.best-card-showcased {
  outline: 1px solid #ffb300;
  box-shadow: 0 0 0 1px rgba(255, 179, 0, 0.3);
}

.best-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: #151515;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.best-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.best-name {
  font-size: 12px;
  font-weight: 500;
}

.best-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 10px;
  color: #b0b0b0;
}

.best-power {
  font-weight: 500;
}

.best-rarity-pill {
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 9px;
  text-transform: uppercase;
}

/* Rarity index */
.rarity-scale {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.rarity-tier {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 4px 6px;
  border-radius: 8px;
  background: #151515;
  font-size: 10px;
  color: #a0a0a0;
}

.rarity-tier.have {
  background: #1c1f14;
}

.rarity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #444;
}

.rarity-tier.have .rarity-dot {
  background: #cddc39;
}

.rarity-tier-label {
  flex: 1;
}

.rarity-tier-status {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

/* Leaderboard section */
.leaderboard-section {
  margin-top: 6px;
  border-radius: 14px;
  background: #202020;
  padding: 8px;
  font-size: 11px;
}

.leaderboard-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
}

.leaderboard-metric {
  background: #181818;
  border-radius: 10px;
  padding: 6px;
}

.leaderboard-metric-label {
  font-size: 10px;
  color: #a0a0a0;
  margin-bottom: 2px;
}

.leaderboard-entries {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 84px;
  overflow-y: auto;
}

.leaderboard-entry {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  padding: 2px 0;
}

.leaderboard-rank {
  width: 18px;
  color: #777;
}

.leaderboard-name {
  flex: 1;
  font-weight: 500;
}

.leaderboard-score {
  color: #e0e0e0;
}

.leaderboard-empty {
  font-size: 10px;
  color: #666;
}

/* Luck upgrade notification */
.luck-notification {
  position: fixed;
  right: 12px;
  bottom: 12px;
  max-width: 260px;
  padding: 8px 10px;
  border-radius: 10px;
  background: #202020;
  color: #f5f5f5;
  font-size: 11px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.8);
  z-index: 1000;
  opacity: 0;
  transform: translateY(8px);
  animation: luck-notification-in 0.2s ease-out forwards;
}

@keyframes luck-notification-in {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.luck-notification-hide {
  animation: luck-notification-out 0.2s ease-in forwards;
}

@keyframes luck-notification-out {
  to {
    opacity: 0;
    transform: translateY(8px);
  }
}

/* Profile section */
.profile-section {
  margin-top: 6px;
  border-radius: 14px;
  background: #202020;
  padding: 8px;
  font-size: 11px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.profile-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.profile-username {
  font-weight: 700;
  font-size: 13px;
}

.profile-gradient-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  color: #a0a0a0;
}

.profile-gradient-row label {
  display: flex;
  align-items: center;
  gap: 4px;
}

.profile-gradient-input {
  width: 32px;
  height: 18px;
  padding: 0;
  border-radius: 6px;
  border: none;
  background: transparent;
}

.profile-post-input {
  width: 100%;
  min-height: 40px;
  max-height: 60px;
  resize: none;
  border-radius: 10px;
  border: none;
  padding: 6px 8px;
  font-size: 11px;
  background: #181818;
  color: #f5f5f5;
}

.profile-post-input::placeholder {
  color: #666666;
}

.profile-best-wrapper {
  border-radius: 10px;
  background: #181818;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.profile-best-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 10px;
  color: #a0a0a0;
}

.profile-best-list {
  max-height: 72px;
  overflow-y: auto;
  padding-right: 2px;
}

/* Rarity Colors */
.rarity-common {
  background: #2a2a2a;
  color: #e0e0e0;
}

.rarity-uncommon {
  background: #1b5e20;
  color: #e8f5e9;
}

.rarity-rare {
  background: #0d47a1;
  color: #e3f2fd;
}

.rarity-epic {
  background: #4a148c;
  color: #f3e5f5;
}

.rarity-legendary {
  background: #ff8f00;
  color: #212121;
}

.rarity-exotic {
  background: #00695c;
  color: #e0f2f1;
}

.rarity-mythic {
  background: #b71c1c;
  color: #ffebee;
}

.rarity-omega {
  background: #263238;
  color: #eceff1;
}

.rarity-relic {
  background: #4e342e;
  color: #efebe9;
}

.rarity-ascended {
  background: #1a237e;
  color: #e8eaf6;
}

.rarity-celestial {
  background: #283593;
  color: #e8eaf6;
}

.rarity-eternal {
  background: #212121;
  color: #fafafa;
}

.rarity-transcendent {
  background: #311b92;
  color: #e8eaf6;
}

.rarity-cosmic {
  background: #1a237e;
  color: #e3f2fd;
}

.rarity-divine {
  background: #ffeb3b;
  color: #212121;
}

.rarity-primordial {
  background: #3e2723;
  color: #ffccbc;
}

.rarity-abyssal {
  background: #000022;
  color: #e0f7fa;
}

.rarity-singularity {
  background: #000000;
  color: #ffffff;
}

.rarity-omniscient {
  background: #004d40;
  color: #e0f2f1;
}

.rarity-paradox {
  background: #4a148c;
  color: #f3e5f5;
}

.rarity-anomalous {
  background: #263238;
  color: #eceff1;
}

.rarity-hypernova {
  background: #bf360c;
  color: #fff3e0;
}

.rarity-oblivion {
  background: #1b1b1b;
  color: #eeeeee;
}

.rarity-quantum {
  background: #006064;
  color: #e0f7fa;
}

.rarity-nebular {
  background: #4527a0;
  color: #ede7f6;
}

.rarity-galactic {
  background: #1a237e;
  color: #c5cae9;
}

.rarity-multiversal {
  background: #004d40;
  color: #e0f2f1;
}

.rarity-metaversal {
  background: #263238;
  color: #eceff1;
}

.rarity-ultra {
  background: #ff6f00;
  color: #212121;
}

.rarity-supreme {
  background: #c2185b;
  color: #fce4ec;
}

.rarity-omegaprime {
  background: #212121;
  color: #ffeb3b;
}

.rarity-ultimate {
  background: #f44336;
  color: #fffde7;
}

/* Frenzy background state */
body.frenzy-background {
  background: #201109;
}