:root {
  color-scheme: dark;
  font-family: Arial, Helvetica, sans-serif;
  background: #101015;
  color: #f4f4f7;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  display: grid;
  place-items: center;
  background:
    linear-gradient(180deg, #15151d 0%, #0d0d12 100%);
}

.game-shell {
  position: relative;
  width: min(960px, calc(100vw - 24px));
}

.hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  font-size: 15px;
  color: #babac8;
}

.hud strong {
  color: #ffffff;
}

.hp-widget,
.xp-widget {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 190px;
}

.hp-bar,
.xp-bar {
  width: 96px;
  height: 12px;
  overflow: hidden;
  border: 1px solid #4b5563;
  border-radius: 999px;
  background: #2a1114;
}

.xp-bar {
  background: #0f2633;
}

#hpFill {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ef4444, #f97316);
  transition: width 120ms ease;
}
#hpFill.danger {
  animation: hpPulse 0.5s ease-in-out infinite alternate;
}
@keyframes hpPulse {
  from { background: linear-gradient(90deg, #ef4444, #f97316); }
  to   { background: linear-gradient(90deg, #dc2626, #b91c1c); filter: brightness(1.5); }
}

#xpFill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #0ea5e9, #38bdf8);
  transition: width 120ms ease;
}

.hud-button {
  min-height: 26px;
  padding: 0 10px;
  border-radius: 5px;
  font-size: 13px;
}

canvas {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  border: 1px solid #30303a;
  background: #171720;
}

.fusion-toast {
  position: absolute;
  top: 54px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 20px;
  border: 1px solid rgba(216, 180, 254, 0.5);
  border-radius: 999px;
  background: rgba(88, 28, 135, 0.85);
  color: #f0abfc;
  font-size: 15px;
  font-weight: 700;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 0 0 24px rgba(168, 85, 247, 0.4);
}

.wave-toast {
  position: absolute;
  top: 28px;
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: rgba(24, 24, 32, 0.82);
  color: #d0d0e0;
  font-size: 13px;
  font-weight: 600;
  pointer-events: none;
  white-space: nowrap;
}

.overlay {
  position: absolute;
  inset: 33px 0 0;
  display: grid;
  place-items: center;
  background: rgba(8, 8, 12, 0.68);
  z-index: 5;
}

.hidden {
  display: none;
}

.modal {
  width: min(520px, calc(100% - 32px));
  padding: 24px;
  border: 1px solid #3a3a46;
  border-radius: 8px;
  background: #181820;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.36);
  text-align: center;
}

.modal h1 {
  margin: 0 0 12px;
  font-size: 26px;
  letter-spacing: 0;
}

.modal p {
  margin: 0 0 20px;
  color: #c8c8d2;
  line-height: 1.5;
}

.modal.compact {
  width: min(260px, calc(100% - 32px));
}

.modal.compact p {
  margin: 0;
}

.modal.compact strong {
  font-size: 30px;
  color: #f0c14b;
}

.modal.compact .hint {
  margin-top: 10px;
  font-size: 14px;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 6px;
  padding: 0 18px;
  background: #f0c14b;
  color: #17130a;
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  background: #ffd86e;
}

button.secondary {
  background: #2f3340;
  color: #f5f5f8;
}

button.secondary:hover {
  background: #404656;
}

.button-row {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.meta-currency {
  margin: 0 0 14px;
  color: #c9c9d3;
  font-weight: 700;
}

.meta-currency strong {
  color: #67e8f9;
}

.character-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 0 0 18px;
}

.character-card {
  min-height: 112px;
  padding: 12px;
  border: 1px solid #3f4654;
  border-radius: 8px;
  background: #20212b;
  color: #f5f5f8;
  text-align: left;
  cursor: pointer;
}

.character-card:hover {
  background: #292b36;
}

.character-card.selected {
  border-width: 2px;
  border-color: #67e8f9;
  box-shadow: 0 0 20px rgba(103, 232, 249, 0.18);
}

.character-card.disabled {
  opacity: 0.55;
}

.character-card strong,
.character-card span,
.character-card small {
  display: block;
}

.character-card span {
  margin-top: 8px;
  color: #c9c9d3;
  font-size: 13px;
  line-height: 1.35;
}

.character-card small {
  margin-top: 10px;
  color: #f0c14b;
  font-weight: 700;
}

.help-list {
  margin: 0 0 20px;
  padding-left: 20px;
  color: #d6d6df;
  text-align: left;
  line-height: 1.55;
}

.reward-grid,
.shop-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 18px;
}

.shop-grid {
  margin-bottom: 18px;
}

.reward-card,
.shop-item {
  position: relative;
  min-height: 160px;
  padding: 14px;
  border: 1px solid #494956;
  border-radius: 8px;
  background: #22222c;
  color: #f5f5f8;
  text-align: left;
  cursor: pointer;
}

.reward-card:hover,
.shop-item:hover {
  background: #2a2a35;
}

.reward-reroll {
  position: absolute;
  top: 6px;
  right: 6px;
  min-width: unset;
  min-height: unset;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid rgba(120, 180, 255, 0.45);
  border-radius: 50%;
  background: rgba(80, 140, 230, 0.18);
  color: #d8e8ff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.reward-reroll:hover {
  background: rgba(120, 180, 255, 0.32);
}

.reward-reroll:disabled {
  opacity: 0.45;
  cursor: default;
  background: rgba(80, 80, 100, 0.2);
  border-color: rgba(120, 130, 150, 0.3);
}

.reward-card em {
  display: inline-block;
  margin-bottom: 10px;
  margin-right: 6px;
  border-radius: 999px;
  padding: 3px 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #d8d8e2;
  font-size: 12px;
  font-style: normal;
  font-weight: 700;
}

.reward-card em.type {
  background: rgba(103, 232, 249, 0.12);
  color: #a5f3fc;
}

.reward-card strong,
.shop-item strong {
  display: block;
  margin-bottom: 8px;
  font-size: 15px;
}

.reward-card span,
.shop-item span {
  display: block;
  color: #c9c9d3;
  font-size: 13px;
  line-height: 1.35;
}

.reward-card .set-hint {
  margin-top: 10px;
  color: #d8b4fe;
  font-size: 12px;
}

.shop-item small {
  display: inline-block;
  margin-top: 10px;
  margin-right: 8px;
  color: #f0c14b;
  font-size: 13px;
  font-weight: 700;
}

.shop-item em {
  display: inline-block;
  margin-bottom: 10px;
  border-radius: 999px;
  padding: 3px 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #d8d8e2;
  font-size: 12px;
  font-style: normal;
  font-weight: 700;
}

.shop-item .requirements {
  margin-top: 10px;
  color: #aeb7c7;
}

.shop-item.disabled {
  opacity: 0.45;
  cursor: default;
}

.reward-card.tier-stone {
  border-color: #737373;
}

.reward-card.tier-bronze {
  border-color: #a16207;
}

.reward-card.tier-silver {
  border-color: #94a3b8;
}

.reward-card.tier-gold {
  border-color: #f0c14b;
}

.reward-card.tier-diamond {
  border-color: #67e8f9;
}

.reward-card.tier-prism {
  border-color: #d8b4fe;
}

.reward-card.upgraded {
  box-shadow: 0 0 0 1px rgba(240, 193, 75, 0.45), 0 0 24px rgba(240, 193, 75, 0.16);
}

.reward-card.match-glow {
  border-width: 3px;
  box-shadow:
    inset 0 0 0 1px rgba(165, 243, 252, 0.42),
    0 0 0 1px rgba(165, 243, 252, 0.55),
    0 0 24px rgba(103, 232, 249, 0.28);
}

.reward-card.match-gold {
  border-width: 3px;
  border-color: #facc15;
  box-shadow:
    inset 0 0 0 1px rgba(254, 240, 138, 0.52),
    0 0 0 1px rgba(250, 204, 21, 0.72),
    0 0 34px rgba(250, 204, 21, 0.38);
}

.reward-card.match-rainbow {
  border: 3px solid transparent;
  background:
    linear-gradient(#22222c, #22222c) padding-box,
    linear-gradient(135deg, #ff5c8a, #facc15, #22c55e, #38bdf8, #a855f7) border-box;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.18),
    0 0 38px rgba(168, 85, 247, 0.38);
}

.reward-card.reward-chosen {
  position: relative;
  z-index: 10;
  transform: scale(1.18);
  transition: transform 0.2s ease;
}

.reward-card.reward-dimmed {
  opacity: 0.12;
  filter: blur(3px);
  pointer-events: none;
  transition: opacity 0.2s ease, filter 0.2s ease;
}

.shop-item.shop-final {
  cursor: pointer;
}

.shop-item.shop-final:not(.expanded)::after {
  content: "▼ 펼치기";
  display: block;
  margin-top: 8px;
  color: #67e8f9;
  font-size: 12px;
  font-weight: 700;
}

.shop-item.expanded {
  cursor: default;
  background: #2a2a35;
  border-color: #67e8f9;
  box-shadow: 0 0 0 1px rgba(103, 232, 249, 0.35);
}

.shop-item.owned {
  cursor: default;
  border-color: #4ade80;
  background: #0f2a1c;
}

.shop-item.owned:hover {
  background: #0f2a1c;
}

.shop-item.late-final {
  border-color: #7c3aed;
  background: #1a1030;
}
.shop-item.late-final:hover {
  background: #231445;
}
.shop-item.late-final.owned {
  border-color: #a78bfa;
  background: #1a1030;
}
.late-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  color: #a78bfa;
  background: #2e1065;
  border: 1px solid #7c3aed;
  border-radius: 4px;
  padding: 1px 6px;
  margin-bottom: 6px;
  letter-spacing: 0.5px;
}

.shop-item.shop-final.owned::after {
  content: none;
}

.purchased-tag {
  display: inline-block;
  margin-top: 10px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #1f3a2a;
  color: #4ade80;
  font-size: 12px;
  font-weight: 700;
}

.shop-recipe {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.shop-recipe-label {
  display: block;
  margin-bottom: 8px;
  color: #aeb7c7;
  font-size: 12px;
  font-weight: 700;
}

.shop-recipe-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.shop-component-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid #3a3a46;
  border-radius: 6px;
  background: #1c1c25;
}

.shop-component-info {
  flex: 1;
  text-align: left;
  min-width: 0;
}

.shop-component-info strong {
  display: block;
  margin-bottom: 2px;
  font-size: 13px;
}

.shop-component-info em {
  display: block;
  color: #aeb7c7;
  font-size: 11px;
  font-style: normal;
  background: none;
  padding: 0;
}

.shop-component-row.owned {
  border-color: #4ade80;
  background: #0f2a1c;
}

.shop-component-row.owned .shop-component-info strong::before {
  content: "✓ ";
  color: #4ade80;
}

.shop-component-buy {
  min-height: 30px;
  padding: 0 12px;
  font-size: 12px;
  flex-shrink: 0;
}

.shop-component-buy:disabled {
  opacity: 0.4;
  cursor: default;
}

.shop-component-buy.owned-tag {
  background: #1f3a2a;
  color: #4ade80;
}

.shop-craft-button {
  width: 100%;
  margin-top: 12px;
  background: #67e8f9;
  color: #07171c;
}

.shop-craft-button:hover:not(:disabled) {
  background: #a5f3fc;
}

.shop-craft-button:disabled {
  opacity: 0.4;
  cursor: default;
}

.shop-sell-button {
  min-height: 28px;
  padding: 0 10px;
  font-size: 12px;
  background: #3f2a2a;
  color: #fca5a5;
  border: 1px solid #7f1d1d;
  border-radius: 5px;
}
.shop-sell-button:hover {
  background: #5a1d1d;
  color: #fecaca;
}

.shop-collapse-button {
  display: block;
  width: 100%;
  margin-top: 8px;
  min-height: 28px;
  padding: 0 10px;
  background: transparent;
  color: #aeb7c7;
  font-size: 12px;
  font-weight: 400;
}

.shop-collapse-button:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #f5f5f8;
}

.fusion-table {
  border-collapse: collapse;
  font-size: 11px;
}

.fusion-table th,
.fusion-table td {
  padding: 5px 7px;
  border: 1px solid #2e2e3a;
  text-align: center;
  white-space: nowrap;
}

.fusion-table thead th {
  background: #1a1a26;
  color: #c4b5fd;
  font-size: 11px;
  font-weight: 700;
  position: sticky;
  top: 0;
  z-index: 1;
}

.fusion-table tbody th {
  background: #1a1a26;
  color: #c4b5fd;
  font-size: 11px;
  font-weight: 700;
  text-align: right;
}

.fusion-table td {
  background: #17171f;
  color: #c9c9d3;
}

.fusion-table td:not(:empty):hover {
  background: #2a2a38;
  color: #f0f0ff;
  cursor: default;
}

.fusion-table td.ft-empty {
  background: #0e0e14;
}

.fusion-table td.ft-active {
  background: #1e1040;
  color: #a78bfa;
  font-weight: 700;
  box-shadow: inset 0 0 0 1px rgba(167,139,250,0.5);
}

.fusion-table td.ft-owned-both {
  background: #1a2e1a;
  color: #4ade80;
  font-weight: 700;
  box-shadow: inset 0 0 0 1px rgba(74,222,128,0.5);
}

@media (max-width: 720px) {
  .reward-grid,
  .shop-grid,
  .character-list {
    grid-template-columns: 1fr;
  }

  .overlay {
    inset: 56px 0 0;
  }
}
