:root {
  --bg: #070a12;
  --panel: rgba(12, 17, 31, .88);
  --panel-2: rgba(22, 30, 53, .92);
  --ink: #f8fafc;
  --muted: #aab4c8;
  --line: rgba(214, 188, 114, .26);
  --gold: #d8b968;
  --gold-2: #fff0b0;
  --violet: #7c3cff;
  --blue: #2ab8ff;
  --red: #ff4f6d;
  --green: #31d28b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(4, 6, 14, .2), rgba(4, 6, 14, .92)),
    linear-gradient(135deg, #050711 0%, #101a2d 42%, #190d2b 68%, #050711 100%);
  font-family: "Hiragino Mincho ProN", "Yu Mincho", "Yu Gothic", serif;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(90deg, rgba(255,255,255,.03) 0 1px, transparent 1px 90px),
    repeating-linear-gradient(0deg, rgba(255,255,255,.025) 0 1px, transparent 1px 90px);
  mask-image: linear-gradient(180deg, rgba(0,0,0,.9), rgba(0,0,0,.18));
}

.game-shell {
  position: relative;
  width: min(1280px, calc(100% - 28px));
  margin: 0 auto;
  padding: 18px 0 44px;
}

.game-hero {
  min-height: 420px;
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(340px, .65fr);
  align-items: end;
  gap: 24px;
  overflow: hidden;
  border: 1px solid rgba(216, 185, 104, .3);
  border-radius: 18px;
  background:
    linear-gradient(90deg, rgba(4, 6, 14, .52), rgba(4, 6, 14, .86)),
    url("/assets/arcane-links-logo.png") center / cover no-repeat;
  box-shadow: 0 24px 80px rgba(0, 0, 0, .42), inset 0 0 80px rgba(124, 60, 255, .18);
  padding: 30px;
  margin-bottom: 18px;
}

.game-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border: 1px solid rgba(255, 240, 176, .18);
  border-radius: 18px;
  box-shadow: inset 0 0 0 1px rgba(42, 184, 255, .1);
}

.hero-art {
  align-self: center;
  justify-self: center;
  width: min(680px, 100%);
  filter: drop-shadow(0 16px 30px rgba(0, 0, 0, .72));
}

.game-logo {
  display: block;
  width: 100%;
  height: auto;
}

.hero-copy {
  position: relative;
  z-index: 1;
  padding: 22px;
  border-left: 2px solid rgba(216, 185, 104, .65);
  background: linear-gradient(90deg, rgba(7, 10, 18, .74), rgba(7, 10, 18, .18));
}

.game-eyebrow {
  margin: 0 0 10px;
  color: var(--gold-2);
  font-family: "Hiragino Sans", "Yu Gothic", sans-serif;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

h1, h2, h3, p { margin: 0; }

h1 {
  max-width: 11em;
  font-size: clamp(34px, 5vw, 68px);
  line-height: 1.08;
  letter-spacing: 0;
  text-shadow: 0 3px 18px rgba(42, 184, 255, .28);
}

h2 {
  font-size: 24px;
  line-height: 1.25;
}

.hero-copy p:last-child,
.section-title p,
.tiny-note {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.75;
  font-family: "Hiragino Sans", "Yu Gothic", sans-serif;
}

.command-grid,
.arena-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(330px, .85fr);
  gap: 18px;
}

.game-hero,
.profile-panel,
.summon-panel,
.new-card-panel,
.battle-panel,
.ranking-panel,
.deck-panel {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(18, 25, 45, .92), rgba(7, 10, 18, .92));
  box-shadow: 0 18px 54px rgba(0, 0, 0, .34), inset 0 1px 0 rgba(255,255,255,.07);
  padding: 22px;
  margin-bottom: 18px;
}

.section-title {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 18px;
}

.section-title > span {
  min-width: 52px;
  min-height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(216, 185, 104, .45);
  border-radius: 999px;
  color: var(--gold-2);
  background: linear-gradient(180deg, rgba(124, 60, 255, .25), rgba(10, 14, 26, .9));
  font-family: "Hiragino Sans", "Yu Gothic", sans-serif;
  font-weight: 900;
}

.section-title.compact {
  margin-bottom: 12px;
}

.player-form,
.summon-form,
.battle-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.battle-controls {
  margin-top: 8px;
  grid-template-columns: minmax(0, 1fr) auto auto;
}

label span {
  display: block;
  margin-bottom: 8px;
  color: var(--gold-2);
  font-family: "Hiragino Sans", "Yu Gothic", sans-serif;
  font-weight: 900;
}

input, select {
  width: 100%;
  min-height: 54px;
  border: 1px solid rgba(216, 185, 104, .32);
  border-radius: 10px;
  background: rgba(3, 7, 18, .82);
  color: var(--ink);
  font-size: 16px;
  padding: 0 14px;
  outline: none;
  box-shadow: inset 0 0 18px rgba(0,0,0,.28);
}

input:focus,
select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(42, 184, 255, .18), inset 0 0 18px rgba(0,0,0,.28);
}

button {
  min-height: 54px;
  border: 1px solid rgba(255, 240, 176, .36);
  border-radius: 10px;
  padding: 0 18px;
  color: #110914;
  background: linear-gradient(180deg, #ffe8a0, #c69536 58%, #7b4c16);
  font-size: 16px;
  font-weight: 900;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 12px 24px rgba(0,0,0,.26), inset 0 1px 0 rgba(255,255,255,.52);
}

button:hover {
  transform: translateY(-1px);
  filter: brightness(1.08);
}

button:disabled {
  opacity: .6;
  cursor: wait;
  transform: none;
}

.battle-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.battle-head .section-title {
  margin-bottom: 0;
}

.battle-head button,
#saveNameBtn {
  color: var(--ink);
  background: linear-gradient(180deg, rgba(42, 184, 255, .22), rgba(18, 25, 45, .94));
  border-color: rgba(42, 184, 255, .32);
}

.record-grid,
.collection-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.record-grid div,
.collection-grid div {
  min-height: 82px;
  border: 1px solid rgba(216, 185, 104, .2);
  border-radius: 12px;
  background: rgba(3, 7, 18, .58);
  padding: 12px;
}

.record-grid strong,
.collection-grid strong {
  display: block;
  font-family: "Hiragino Sans", "Yu Gothic", sans-serif;
  font-size: 30px;
  line-height: 1;
  color: var(--gold-2);
}

.record-grid span,
.collection-grid span {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-weight: 900;
  font-size: 12px;
}

.game-message,
.battle-result {
  margin-top: 14px;
  padding: 13px 15px;
  border: 1px solid rgba(42, 184, 255, .28);
  border-radius: 10px;
  background: rgba(42, 184, 255, .12);
  color: var(--ink);
  font-family: "Hiragino Sans", "Yu Gothic", sans-serif;
  font-weight: 900;
}

.game-message.error {
  border-color: rgba(255, 79, 109, .4);
  background: rgba(255, 79, 109, .15);
  color: #ffd6dd;
}

.battle-result strong {
  display: block;
  margin-bottom: 6px;
  font-size: 22px;
  color: var(--gold-2);
}

.rooms {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.room {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid rgba(216, 185, 104, .22);
  border-radius: 12px;
  background: rgba(3, 7, 18, .54);
  padding: 12px;
}

.room strong {
  display: block;
  margin-bottom: 4px;
  font-size: 18px;
  color: var(--gold-2);
}

.room p,
.empty {
  color: var(--muted);
  font-family: "Hiragino Sans", "Yu Gothic", sans-serif;
}

.ranking-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.rank-row {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 150px 112px;
  gap: 12px;
  align-items: center;
  border: 1px solid rgba(216, 185, 104, .22);
  border-radius: 12px;
  background: rgba(3, 7, 18, .54);
  padding: 12px;
}

.rank-row.is-me {
  border-color: var(--blue);
  background: rgba(42, 184, 255, .12);
}

.rank-row:nth-child(1) {
  border-color: var(--gold);
  box-shadow: inset 0 0 24px rgba(216, 185, 104, .12);
}

.rank-num {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: linear-gradient(180deg, #fff0b0, #a66f22);
  color: #130d08;
  font-family: "Hiragino Sans", "Yu Gothic", sans-serif;
  font-weight: 900;
  font-size: 18px;
}

.rank-main strong,
.rank-record strong {
  display: block;
  font-size: 18px;
}

.rank-main span,
.rank-record span,
.rank-rares span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-family: "Hiragino Sans", "Yu Gothic", sans-serif;
  font-size: 13px;
  font-weight: 800;
}

.rank-rares {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.rank-rares span {
  border-radius: 8px;
  background: rgba(3, 7, 18, .72);
  padding: 8px;
  text-align: center;
  margin: 0;
}

.deck,
#newCard {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(520px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.game-card {
  min-height: 330px;
  aspect-ratio: 16 / 9;
  position: relative;
  overflow: hidden;
  border: 2px solid rgba(216, 185, 104, .38);
  border-radius: 18px;
  padding: 0;
  background:
    radial-gradient(circle at 24% 50%, rgba(124,60,255,.26), transparent 34%),
    linear-gradient(180deg, rgba(255,255,255,.08), transparent 16%),
    linear-gradient(145deg, #1b1730, #080b14 64%, #140a18);
  box-shadow: 0 18px 38px rgba(0,0,0,.36), inset 0 0 30px rgba(124, 60, 255, .08);
}

.game-card::before {
  content: "";
  position: absolute;
  inset: 8px;
  pointer-events: none;
  border: 1px solid rgba(255, 240, 176, .28);
  border-radius: 13px;
  z-index: 1;
}

.game-card::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(120deg, transparent 0 42%, rgba(255,255,255,.12) 48%, transparent 56% 100%);
  transform: translateX(-75%);
}

.game-card:hover::after {
  transform: translateX(75%);
  transition: transform .8s ease;
}

.monster-frame {
  position: absolute;
  inset: 0;
  height: auto;
  overflow: hidden;
  border: 0;
  border-radius: 16px;
  background: #050711;
  z-index: 0;
}

.monster-frame img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  object-position: center center;
  filter: saturate(1.08) contrast(1.04);
}

.monster-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 30% 34%, rgba(255,255,255,.05), transparent 30%),
    linear-gradient(90deg, rgba(3,7,18,.38) 0%, rgba(3,7,18,.08) 35%, rgba(3,7,18,.28) 62%, rgba(3,7,18,.74) 100%),
    linear-gradient(180deg, rgba(3,7,18,.28), rgba(3,7,18,.02) 40%, rgba(3,7,18,.9));
}

.rarity-ur { border-color: var(--gold); box-shadow: 0 0 34px rgba(216, 185, 104, .18), 0 18px 38px rgba(0,0,0,.36); }
.rarity-sr { border-color: var(--blue); box-shadow: 0 0 34px rgba(42, 184, 255, .16), 0 18px 38px rgba(0,0,0,.36); }
.rarity-r { border-color: var(--violet); }
.rarity-n { border-color: #8893a8; }

.card-top,
.stats {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.card-content {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  min-height: 100%;
  margin: 0;
  padding: 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.card-top {
  margin-top: 0;
  flex-wrap: wrap;
  justify-content: flex-start;
}

.card-top span {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  border: 1px solid rgba(255, 240, 176, .22);
  border-radius: 999px;
  padding: 4px 10px;
  background: rgba(3, 7, 18, .78);
  color: var(--gold-2);
  font-family: "Hiragino Sans", "Yu Gothic", sans-serif;
  font-weight: 900;
  font-size: 14px;
  box-shadow: 0 8px 22px rgba(0,0,0,.34);
  backdrop-filter: blur(8px);
}

.card-bottom {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(236px, 38%);
  gap: 12px;
  align-items: end;
}

.card-lore {
  min-width: 0;
  border: 1px solid rgba(216, 185, 104, .24);
  border-radius: 14px;
  background:
    linear-gradient(90deg, rgba(3,7,18,.88), rgba(3,7,18,.58)),
    radial-gradient(circle at 0% 0%, rgba(42,184,255,.18), transparent 34%);
  padding: 12px;
  box-shadow: 0 16px 38px rgba(0,0,0,.4);
  backdrop-filter: blur(8px);
}

.game-card h3 {
  position: relative;
  z-index: 2;
  margin-top: 0;
  min-height: auto;
  font-size: clamp(20px, 2.1vw, 30px);
  line-height: 1.35;
  overflow-wrap: anywhere;
  text-shadow: 0 3px 18px rgba(0,0,0,.74), 0 0 16px rgba(42,184,255,.28);
}

.game-card p {
  position: relative;
  z-index: 2;
  margin-top: 6px;
  color: var(--muted);
  overflow-wrap: anywhere;
  font-family: "Hiragino Sans", "Yu Gothic", sans-serif;
}

.special-box {
  position: relative;
  z-index: 2;
  min-height: 52px;
  margin-top: 10px;
  border: 1px solid rgba(216, 185, 104, .2);
  border-radius: 10px;
  background: rgba(3, 7, 18, .52);
  padding: 8px 10px;
}

.special-box span {
  display: block;
  color: var(--muted);
  font-family: "Hiragino Sans", "Yu Gothic", sans-serif;
  font-size: 12px;
  font-weight: 900;
}

.special-box strong {
  display: block;
  margin-top: 5px;
  color: var(--gold-2);
  font-size: 15px;
  line-height: 1.35;
}

.stats {
  margin-top: 0;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 7px;
}

.stats span {
  flex: 1;
  border: 1px solid rgba(216, 185, 104, .26);
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(3, 7, 18, .88), rgba(3, 7, 18, .7)),
    radial-gradient(circle at 100% 0%, rgba(216,185,104,.16), transparent 42%);
  min-width: 0;
  padding: 8px 9px;
  color: var(--muted);
  font-family: "Hiragino Sans", "Yu Gothic", sans-serif;
  font-weight: 900;
  font-size: 12px;
  box-shadow: 0 12px 26px rgba(0,0,0,.34);
  backdrop-filter: blur(8px);
}

.stats strong {
  display: block;
  color: var(--ink);
  font-size: 25px;
  line-height: 1.05;
  text-shadow: 0 2px 12px rgba(0,0,0,.64);
}

.card-code {
  position: relative;
  z-index: 2;
  margin-top: 14px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  font-family: "Hiragino Sans", "Yu Gothic", sans-serif;
}

.battle-modal[hidden] {
  display: none;
}

.battle-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
}

.battle-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .72);
  backdrop-filter: blur(8px);
}

.battle-modal-panel {
  position: relative;
  width: min(1040px, 100%);
  max-height: min(92vh, 900px);
  overflow: auto;
  border: 1px solid rgba(216, 185, 104, .42);
  border-radius: 18px;
  background:
    radial-gradient(circle at 50% 0%, rgba(124, 60, 255, .28), transparent 40%),
    linear-gradient(180deg, rgba(18, 25, 45, .98), rgba(5, 7, 14, .98));
  box-shadow: 0 30px 90px rgba(0,0,0,.58), inset 0 1px 0 rgba(255,255,255,.08);
  padding: 24px;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  min-height: 38px;
  width: auto;
  padding: 0 14px;
  color: var(--ink);
  background: rgba(3, 7, 18, .84);
}

.battle-stage {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 14px;
  align-items: stretch;
  margin: 18px 0;
}

.fighter {
  border: 1px solid rgba(216, 185, 104, .24);
  border-radius: 14px;
  background: rgba(3, 7, 18, .58);
  padding: 16px;
}

.fighter-name span {
  color: var(--muted);
  font-family: "Hiragino Sans", "Yu Gothic", sans-serif;
  font-size: 12px;
  font-weight: 900;
}

.fighter-name strong {
  display: block;
  margin-top: 6px;
  font-size: 24px;
}

.hp-shell {
  height: 18px;
  overflow: hidden;
  border: 1px solid rgba(255, 240, 176, .28);
  border-radius: 999px;
  background: rgba(0, 0, 0, .48);
  margin-top: 14px;
}

.hp-fill {
  width: 100%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #31d28b, #fff0b0);
  transition: width .55s ease;
}

.fighter.is-hit {
  animation: hitShake .34s ease;
}

.hp-text {
  display: block;
  margin-top: 8px;
  color: var(--gold-2);
  font-family: "Hiragino Sans", "Yu Gothic", sans-serif;
  font-size: 18px;
  font-weight: 900;
}

@keyframes hitShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  55% { transform: translateX(7px); }
  80% { transform: translateX(-4px); }
}

.versus-mark {
  width: 72px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: #140b07;
  background: linear-gradient(180deg, #fff0b0, #a66f22);
  font-size: 24px;
  font-weight: 900;
}

.battle-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.battle-cards .game-card {
  min-height: 290px;
}

.battle-cards .card-bottom {
  grid-template-columns: minmax(0, 1fr) minmax(220px, 42%);
}

.battle-cards h3 {
  margin-bottom: 10px;
  color: var(--gold-2);
}

.battle-note {
  margin-top: 16px;
  border: 1px solid rgba(42, 184, 255, .26);
  border-radius: 12px;
  background: rgba(42, 184, 255, .12);
  padding: 13px 15px;
  color: var(--ink);
  font-family: "Hiragino Sans", "Yu Gothic", sans-serif;
  font-weight: 900;
}

.battle-log {
  display: grid;
  gap: 8px;
  max-height: 150px;
  overflow: auto;
  margin-top: 16px;
  border: 1px solid rgba(216, 185, 104, .2);
  border-radius: 12px;
  background: rgba(3, 7, 18, .5);
  padding: 12px;
}

.battle-log p {
  color: var(--ink);
  font-family: "Hiragino Sans", "Yu Gothic", sans-serif;
  font-weight: 800;
}

@media (max-width: 980px) {
  .game-hero,
  .command-grid,
  .arena-grid {
    grid-template-columns: 1fr;
  }

  .game-hero {
    min-height: auto;
  }

  .hero-copy {
    border-left: 0;
    border-top: 2px solid rgba(216, 185, 104, .65);
  }
}

@media (max-width: 720px) {
  .game-shell {
    width: min(100% - 18px, 1280px);
    padding-top: 10px;
  }

  .game-hero,
  .profile-panel,
  .summon-panel,
  .new-card-panel,
  .battle-panel,
  .ranking-panel,
  .deck-panel {
    padding: 16px;
    border-radius: 14px;
  }

  .player-form,
  .summon-form,
  .battle-controls,
  .battle-head,
  .room,
  .rank-row {
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .battle-head {
    align-items: stretch;
  }

  .record-grid,
  .collection-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .section-title {
    gap: 10px;
  }

  .section-title > span {
    min-width: 44px;
  }

  button {
    width: 100%;
  }

  .deck,
  #newCard,
  .battle-cards,
  .battle-stage {
    grid-template-columns: 1fr;
  }

  .deck,
  #newCard {
    grid-template-columns: 1fr;
  }

  .game-card {
    min-height: 520px;
    aspect-ratio: auto;
  }

  .card-content {
    width: 100%;
    min-height: 100%;
    margin: 0;
    justify-content: flex-end;
    border-left: 0;
    border-top: 0;
  }

  .card-top {
    position: absolute;
    top: 14px;
    left: 14px;
    right: 14px;
  }

  .card-bottom,
  .battle-cards .card-bottom {
    grid-template-columns: 1fr;
  }

  .stat-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .versus-mark {
    width: 100%;
    height: 48px;
  }
}
