* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  background: #05060a;
  font-family: 'Segoe UI', system-ui, sans-serif;
  color: #e8ecff;
  padding: 30px 16px;
}

#wrap {
  width: 100%;
  max-width: 640px;
}

#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

#topbar h1 {
  margin: 0;
  font-size: 26px;
  letter-spacing: 1px;
  color: #39d6ff;
  text-shadow: 0 0 14px rgba(57, 214, 255, 0.5);
}

#shardsDisplay {
  font-size: 16px;
  font-weight: 700;
  background: #10131f;
  border: 1px solid #223047;
  border-radius: 20px;
  padding: 6px 14px;
}

.hidden {
  display: none;
}

.screen h2 {
  font-size: 16px;
  color: #9fb3d9;
  letter-spacing: 0.5px;
  margin: 18px 0 10px;
}

#homeActions {
  display: flex;
  gap: 14px;
  margin-bottom: 6px;
}

.actionCol {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
}

button {
  padding: 12px 20px;
  font-size: 15px;
  font-weight: 700;
  color: #05060a;
  background: #39d6ff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  width: 100%;
  transition: transform 0.1s ease, background 0.15s ease, opacity 0.15s ease;
}

button:hover:not(:disabled) {
  background: #7fe6ff;
}

button:active:not(:disabled) {
  transform: scale(0.97);
}

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.inlineMsg {
  min-height: 18px;
  font-size: 12px;
  color: #ff8a8a;
  margin-top: 6px;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.inlineMsg.show {
  opacity: 1;
}

.cardGrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
}

.card {
  --element-color: #39d6ff;
  position: relative;
  background: #10131f;
  border: 2px solid var(--element-color);
  border-radius: 10px;
  padding: 10px 8px;
  text-align: center;
  cursor: default;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(160deg, color-mix(in srgb, var(--element-color) 18%, transparent), transparent 60%);
  pointer-events: none;
}

.card.rarity-legendary {
  box-shadow: 0 0 16px color-mix(in srgb, var(--element-color) 70%, transparent);
}

.card.locked {
  --element-color: #3a3f52;
  opacity: 0.5;
}

.cardIcon {
  font-size: 30px;
  line-height: 1;
  margin-bottom: 6px;
}

.cardName {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 4px;
  min-height: 16px;
}

.cardMeta {
  display: flex;
  justify-content: center;
  gap: 6px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #9fb3d9;
  margin-bottom: 4px;
}

.cardCount {
  color: #39d6ff;
  font-weight: 700;
}

.cardStats {
  font-size: 11px;
  color: #c3cbea;
}

.card.selectable {
  cursor: pointer;
  transition: transform 0.1s ease, border-color 0.15s ease;
}

.card.selectable:hover {
  transform: translateY(-2px);
}

.card.selected {
  border-color: #39d6ff;
  box-shadow: 0 0 14px rgba(57, 214, 255, 0.6);
}

#tradeHint {
  font-size: 12px;
  color: #7c84a3;
  margin: 0 0 12px;
}

.tradeCardBtn {
  width: 100%;
  margin-top: 8px;
  padding: 6px 4px;
  font-size: 11px;
}

#tradeBackBtn {
  margin-top: 16px;
  max-width: 160px;
}

#emptyTradeMsg {
  color: #7c84a3;
  font-size: 13px;
}

.packSlot {
  position: relative;
  min-height: 118px;
  perspective: 900px;
}

.flipCard {
  position: relative;
  width: 100%;
  min-height: 118px;
  transform-style: preserve-3d;
  transition: transform 0.6s cubic-bezier(0.34, 1.1, 0.64, 1);
}

.flipCard.flipped {
  transform: rotateY(180deg);
}

.flipFace {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.cardBack {
  background: linear-gradient(155deg, #1a1f33, #10131f 60%);
  border: 2px dashed #3a4468;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  color: #4a5680;
  overflow: hidden;
}

.cardBack::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(115deg, transparent 40%, rgba(255, 255, 255, 0.14) 50%, transparent 60%);
  transform: translateX(-120%);
  animation: shimmer 1.8s ease-in-out infinite;
}

@keyframes shimmer {
  to { transform: translateX(120%); }
}

.flipBack {
  transform: rotateY(180deg);
}

.flipBack .card {
  height: 100%;
}

.revealBurst {
  position: absolute;
  inset: -22px;
  border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--element-color) 65%, transparent) 0%, transparent 70%);
  opacity: 0;
  pointer-events: none;
  animation: burstPop 0.6s ease-out forwards;
}

@keyframes burstPop {
  0% { opacity: 0.9; transform: scale(0.2); }
  100% { opacity: 0; transform: scale(1.6); }
}

.packSlot .card.legendary-flash {
  animation: legendaryPulse 1.1s ease 2;
}

@keyframes legendaryPulse {
  0%, 100% { box-shadow: 0 0 16px color-mix(in srgb, var(--element-color) 70%, transparent); }
  50% { box-shadow: 0 0 40px color-mix(in srgb, var(--element-color) 100%, transparent); }
}

#battleField {
  display: flex;
  flex-direction: column;
  gap: 18px;
  background: #10131f;
  border: 1px solid #223047;
  border-radius: 10px;
  padding: 18px;
  margin-top: 14px;
}

.combatant {
  display: flex;
  align-items: center;
  gap: 12px;
}

#opponentSide {
  flex-direction: row-reverse;
  text-align: right;
}

.combatantIcon {
  font-size: 40px;
  width: 60px;
  text-align: center;
}

.combatant > div:not(.combatantIcon) {
  flex: 1;
}

.combatantName {
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 4px;
}

.hpBarTrack {
  height: 10px;
  border-radius: 5px;
  background: #1c2136;
  overflow: hidden;
}

.hpBar {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #39d6ff, #7fe6ff);
  transition: width 0.35s ease, background 0.3s ease;
}

.hpBar.low {
  background: linear-gradient(90deg, #ff5a5a, #ff9d7a);
}

.hpText {
  font-size: 11px;
  color: #9fb3d9;
  margin-top: 3px;
}

#battleLog {
  margin-top: 14px;
  height: 110px;
  overflow-y: auto;
  background: #0a0c14;
  border: 1px solid #1c2136;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.6;
  color: #c3cbea;
}

#battleLog div {
  animation: logIn 0.2s ease;
}

@keyframes logIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

#moveButtons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

#screen-end {
  text-align: center;
  padding: 30px 0;
}

#endTitle {
  font-size: 28px;
  color: #39d6ff;
  text-shadow: 0 0 14px rgba(57, 214, 255, 0.6);
}

#endMsg {
  color: #c3cbea;
  margin-bottom: 20px;
}

#endContinueBtn {
  max-width: 220px;
  margin: 0 auto;
}

#startBattleBtn {
  margin-top: 14px;
  max-width: 220px;
}

#bulkSummary {
  margin-bottom: 16px;
}

#bulkSummaryTotals {
  color: #c3cbea;
  margin: 0 0 14px;
}

#bulkStatRow {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.bulkStat {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #10131f;
  border: 1px solid #223047;
  border-radius: 8px;
  padding: 10px 6px;
}

.bulkStatValue {
  font-size: 20px;
  font-weight: 700;
  color: #39d6ff;
}

.bulkStatLabel {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #9fb3d9;
  margin-top: 2px;
}

#bulkSummary h3 {
  font-size: 14px;
  color: #ffcf4d;
  margin: 0 0 10px;
}

#bulkContinueBtn {
  max-width: 220px;
}
