:root {
  color-scheme: dark;
  --bg: #111111;
  --panel: rgba(255, 255, 255, 0.08);
  --panel-strong: rgba(255, 255, 255, 0.14);
  --text: #fff8e6;
  --muted: #cfc6ad;
  --gold: #f4bd28;
  --red: #ff5a4a;
  --green: #6ee78f;
  --line: rgba(255, 255, 255, 0.16);
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.35);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100svh;
  background:
    radial-gradient(circle at 20% 10%, rgba(244, 189, 40, 0.18), transparent 32rem),
    radial-gradient(circle at 80% 0%, rgba(255, 90, 74, 0.16), transparent 28rem),
    linear-gradient(145deg, #171717 0%, #070707 100%);
  color: var(--text);
}

button {
  border: 0;
  color: #17120a;
  background: var(--gold);
  border-radius: 8px;
  padding: 0.85rem 1rem;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(244, 189, 40, 0.22);
}

button:active {
  transform: translateY(1px);
}

.app {
  width: min(1180px, 100%);
  min-height: 100svh;
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  gap: 16px;
}

.stage,
.side-panel {
  border: 1px solid var(--line);
  background: rgba(12, 12, 12, 0.68);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.stage {
  border-radius: 14px;
  padding: 18px;
  display: grid;
  grid-template-rows: auto minmax(360px, 1fr) auto;
  gap: 14px;
}

.topbar,
.fighter-head,
.turn-line,
.energy-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--gold);
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.45rem, 4vw, 2.4rem);
  line-height: 1.05;
}

.ghost-button {
  color: var(--text);
  background: var(--panel-strong);
  box-shadow: none;
  border: 1px solid var(--line);
}

.arena {
  position: relative;
  display: grid;
  grid-template-columns: minmax(190px, 1fr) minmax(220px, 0.92fr) minmax(190px, 1fr);
  gap: 14px;
  align-items: stretch;
  min-height: 0;
}

.fighter {
  position: relative;
  overflow: hidden;
  border-radius: 12px;
  padding: 16px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.04)),
    repeating-linear-gradient(115deg, transparent 0 24px, rgba(255, 255, 255, 0.035) 24px 36px);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 180px;
}

.fighter.enemy {
  background-color: rgba(255, 90, 74, 0.1);
}

.fighter.player {
  background:
    linear-gradient(135deg, rgba(244, 189, 40, 0.24), rgba(255, 255, 255, 0.05)),
    repeating-linear-gradient(115deg, transparent 0 24px, rgba(255, 255, 255, 0.035) 24px 36px);
  border-color: rgba(244, 189, 40, 0.72);
  box-shadow:
    inset 0 0 0 1px rgba(244, 189, 40, 0.22),
    0 0 28px rgba(244, 189, 40, 0.18);
}

.fighter.player::before {
  content: "このキャラを操作";
  position: absolute;
  right: 12px;
  bottom: 12px;
  color: #17120a;
  background: var(--gold);
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 0.74rem;
  font-weight: 900;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.24);
}

.fighter-head span {
  color: var(--muted);
  font-weight: 700;
}

.fighter-head strong {
  text-align: right;
}

.role-badge {
  display: inline-grid;
  place-items: center;
  margin-right: 6px;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 0.72rem;
  line-height: 1;
  font-weight: 950;
  vertical-align: middle;
}

.player-badge {
  color: #17120a;
  background: var(--gold);
}

.enemy-badge {
  color: var(--text);
  background: rgba(255, 90, 74, 0.78);
}

.hp-row {
  display: grid;
  gap: 8px;
  font-weight: 900;
}

.hp-track {
  height: 13px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.hp-fill {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, var(--green), var(--gold));
  transition: width 240ms ease;
}

.enemy .hp-fill {
  background: linear-gradient(90deg, var(--red), var(--gold));
}

.hero-card {
  position: relative;
  overflow: hidden;
  min-height: 360px;
  border-radius: 12px;
  background:
    radial-gradient(circle at 50% 34%, rgba(244, 189, 40, 0.4), transparent 44%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.13), rgba(255, 255, 255, 0.03));
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
}

.hero-card img {
  position: relative;
  z-index: 1;
  width: min(108%, 460px);
  height: 100%;
  object-fit: cover;
  filter: drop-shadow(0 22px 30px rgba(0, 0, 0, 0.45));
}

.hero-glow {
  position: absolute;
  inset: auto 16% 10% 16%;
  height: 26%;
  background: rgba(244, 189, 40, 0.3);
  filter: blur(34px);
}

.controls {
  display: grid;
  gap: 12px;
}

.turn-line {
  color: var(--muted);
  font-weight: 800;
}

.hand {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.card {
  position: relative;
  min-height: 246px;
  border-radius: 10px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.06)),
    linear-gradient(135deg, rgba(244, 189, 40, 0.16), rgba(255, 90, 74, 0.08));
  color: var(--text);
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.25);
  text-align: left;
  display: grid;
  grid-template-rows: minmax(118px, 1fr) auto;
  gap: 10px;
}

.card:disabled {
  opacity: 0.42;
  cursor: not-allowed;
  box-shadow: none;
}

.card-cost {
  position: absolute;
  right: 10px;
  top: 10px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--gold);
  color: #111;
  font-weight: 950;
  z-index: 2;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
}

.card-art {
  overflow: hidden;
  border-radius: 8px;
  min-height: 118px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.card-art img {
  width: 100%;
  height: 100%;
  min-height: 118px;
  display: block;
  object-fit: cover;
}

.card-body {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.card-icon {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.32);
  color: var(--gold);
  font-size: 1.35rem;
}

.card h3 {
  margin: 0 32px 6px 0;
  font-size: 1.05rem;
}

.card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
  font-size: 0.93rem;
}

.pips {
  display: flex;
  gap: 6px;
}

.pip {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.pip.on {
  background: var(--gold);
  box-shadow: 0 0 16px rgba(244, 189, 40, 0.62);
}

.side-panel {
  border-radius: 14px;
  padding: 16px;
  align-self: stretch;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.mini-art {
  overflow: hidden;
  border-radius: 10px;
  aspect-ratio: 1 / 1;
  border: 1px solid var(--line);
  background: #fff;
}

.mini-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 24%;
}

.side-panel h2 {
  margin-bottom: 0;
}

.side-panel p {
  color: var(--muted);
  line-height: 1.6;
}

.log {
  min-height: 180px;
  max-height: 38svh;
  overflow: auto;
  border-top: 1px solid var(--line);
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--muted);
  font-size: 0.92rem;
}

.log b {
  color: var(--text);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.72);
}

.modal[hidden] {
  display: none;
}

.modal-card {
  width: min(420px, 100%);
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #171717;
  padding: 22px;
  box-shadow: var(--shadow);
}

.modal-card p {
  color: var(--muted);
}

.modal-card button {
  width: 100%;
}

@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
  }

  .side-panel {
    order: 2;
  }

  .mini-art {
    display: none;
  }
}

@media (max-width: 680px) {
  .app {
    padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  }

  .stage {
    padding: 12px;
    grid-template-rows: auto auto auto;
  }

  .topbar {
    align-items: start;
  }

  .ghost-button {
    padding: 0.65rem 0.76rem;
    white-space: nowrap;
  }

  .arena {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "enemy enemy"
      "hero player";
  }

  .enemy {
    grid-area: enemy;
  }

  .hero-card {
    grid-area: hero;
    min-height: 250px;
  }

  .hero-card img {
    width: 132%;
  }

  .player {
    grid-area: player;
  }

  .fighter {
    min-height: 150px;
    padding: 12px;
  }

  .fighter.player::before {
    right: 10px;
    bottom: 10px;
    font-size: 0.68rem;
    padding: 4px 7px;
  }

  .fighter-head {
    align-items: start;
    flex-direction: column;
  }

  .hand {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    padding-bottom: 6px;
  }

  .card {
    min-width: min(76vw, 260px);
    min-height: 260px;
    scroll-snap-align: center;
  }

  .card-art,
  .card-art img {
    min-height: 132px;
  }
}
