/* =========================
   battle / base
========================= */

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family:
    "Arial Rounded MT Bold",
    "Hiragino Maru Gothic ProN",
    "Yu Gothic",
    system-ui,
    sans-serif;
  color: #30283a;
  background:
    linear-gradient(rgba(255, 255, 255, 0.58), rgba(255, 255, 255, 0.58)),
    radial-gradient(circle, #d9cdfa 1.5px, transparent 1.5px),
    #fff7e8;
  background-size: auto, 18px 18px, auto;
}

button,
input {
  font-family: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.screen {
  display: none;
  min-height: 420px;
  padding-bottom: 64px;
}

.screen.active {
  display: block;
}

/* =========================
   page
========================= */

.battle-page {
  width: min(1040px, calc(100% - 32px));
  margin: 0 auto 80px;
}

/* =========================
   hero
========================= */

.battle-hero {
  margin: 34px auto 34px;
}

.battle-window {
  position: relative;
  overflow: hidden;
  padding: 42px 28px 34px;
  border: 4px solid #30283a;
  border-radius: 26px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(245, 238, 255, 0.95));
  box-shadow:
    8px 8px 0 #c7bdf4,
    0 18px 40px rgba(70, 55, 120, 0.18);
  text-align: center;
}

.battle-window::before {
  content: "";
  position: absolute;
  right: -58px;
  top: -68px;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: rgba(255, 149, 185, 0.38);
}

.battle-window::after {
  content: "";
  position: absolute;
  left: -64px;
  bottom: -74px;
  width: 178px;
  height: 178px;
  border-radius: 50%;
  background: rgba(142, 232, 223, 0.54);
}

.window-dots {
  position: absolute;
  top: 16px;
  left: 20px;
  display: flex;
  gap: 7px;
  z-index: 2;
}

.window-dots span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ff9fbc;
  box-shadow:
    17px 0 0 #ffe08a,
    34px 0 0 #8ee8df;
}

.battle-label {
  position: relative;
  z-index: 1;
  display: inline-block;
  margin: 0 0 16px;
  padding: 7px 16px;
  border: 3px solid #30283a;
  border-radius: 999px;
  background: #fff3bf;
  color: #6f5ab8;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  box-shadow:
    3px 3px 0 #c7bdf4,
    inset 0 -3px 0 rgba(0, 0, 0, 0.08);
}

.battle-window h1 {
  position: relative;
  z-index: 1;
  margin: 0;
  color: #30283a;
  font-size: clamp(38px, 6vw, 66px);
  line-height: 1.15;
  font-weight: 900;
  letter-spacing: 0.03em;
  text-shadow:
    3px 3px 0 #ffffff,
    6px 6px 0 #c7bdf4;
}

.battle-lead {
  position: relative;
  z-index: 1;
  max-width: 720px;
  margin: 18px auto 0;
  color: #5f5668;
  font-size: 16px;
  line-height: 1.8;
  font-weight: 800;
}

.battle-note {
  position: relative;
  z-index: 1;
  width: min(720px, 100%);
  margin: 18px auto 0;
  padding: 12px 16px;
  border: 3px dashed rgba(48, 40, 58, 0.36);
  border-radius: 18px;
  background: rgba(255, 243, 191, 0.72);
  color: #6c6174;
  font-size: 13px;
  line-height: 1.7;
  font-weight: 900;
}

.battle-action-row {
  position: relative;
  z-index: 1;
  margin-top: 24px;
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* =========================
   common buttons
========================= */

.battle-main-btn,
.battle-sub-btn,
.battle-action-btn {
  min-height: 44px;
  padding: 10px 16px;
  border: 3px solid #30283a;
  border-radius: 15px;
  color: #30283a;
  font-size: 14px;
  font-weight: 900;
  box-shadow: 4px 4px 0 #30283a;
}

.battle-main-btn {
  background: #ff95b9;
  color: #ffffff;
}

.battle-sub-btn,
.battle-action-btn {
  background: #fff3bf;
}

.battle-action-btn.danger {
  background: #ffe0e8;
  color: #8a3148;
}

.battle-main-btn:hover,
.battle-sub-btn:hover,
.battle-action-btn:hover {
  transform: translate(3px, 3px);
  box-shadow: 1px 1px 0 #30283a;
}

.battle-main-btn:disabled,
.battle-sub-btn:disabled,
.battle-action-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

/* =========================
   panel / section
========================= */

.battle-panel {
  padding: 24px 0 0;
}

.section-title {
  margin-bottom: 28px;
  text-align: center;
}

.section-title p {
  display: inline-block;
  margin: 0 0 12px;
  padding: 6px 14px;
  border: 3px solid #30283a;
  border-radius: 999px;
  background: #fff3bf;
  color: #6f5ab8;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  box-shadow: 3px 3px 0 #c7bdf4;
}

.section-title h2 {
  margin: 0;
  color: #30283a;
  font-size: clamp(30px, 5vw, 44px);
  line-height: 1.2;
  font-weight: 900;
  text-shadow:
    2px 2px 0 #ffffff,
    4px 4px 0 #a8edf0;
}

.screen-lead {
  max-width: 720px;
  margin: 0 auto 30px;
  color: #5f5668;
  text-align: center;
  line-height: 1.9;
  font-weight: 800;
}

/* =========================
   lobby
========================= */

.lobby-grid {
  width: min(880px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
}

.lobby-card {
  padding: 26px;
  border: 4px solid #30283a;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 7px 7px 0 #c7bdf4;
}

.lobby-card h3 {
  margin: 0 0 12px;
  color: #30283a;
  font-size: 26px;
  font-weight: 900;
  text-shadow:
    2px 2px 0 #ffffff,
    4px 4px 0 #fff3bf;
}

.lobby-card p {
  margin: 0 0 20px;
  color: #5f5668;
  font-size: 14px;
  line-height: 1.8;
  font-weight: 800;
}

.battle-input-label {
  display: block;
  margin: 0 0 8px;
  color: #6c6174;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.room-input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  margin-bottom: 12px;
}

.battle-input {
  width: 100%;
  min-height: 44px;
  padding: 10px 13px;
  border: 3px solid #30283a;
  border-radius: 15px;
  background: #ffffff;
  color: #30283a;
  font-size: 16px;
  font-weight: 900;
  outline: none;
  box-shadow: inset 0 -3px 0 rgba(48, 40, 58, 0.08);
}

.battle-input:focus {
  background: #fffdf5;
  box-shadow:
    inset 0 -3px 0 rgba(48, 40, 58, 0.08),
    0 0 0 4px rgba(142, 232, 223, 0.36);
}

/* =========================
   waiting
========================= */

.room-info-card {
  width: min(680px, 100%);
  margin: 0 auto 24px;
  padding: 18px;
  border: 4px solid #30283a;
  border-radius: 22px;
  background: #ffffff;
  box-shadow: 6px 6px 0 #c7bdf4;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}

.room-info-card span {
  display: block;
  margin-bottom: 4px;
  color: #8f7a66;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.room-info-card strong {
  color: #30283a;
  font-size: clamp(28px, 6vw, 42px);
  line-height: 1;
  font-weight: 900;
  letter-spacing: 0.1em;
}

.waiting-players {
  width: min(920px, 100%);
  margin: 0 auto 28px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
}

.waiting-player-card,
.battle-player-card,
.result-player-card {
  position: relative;
  min-width: 0;
  padding: 18px;
  border: 4px solid #30283a;
  border-radius: 22px;
  background: #ffffff;
  box-shadow: 6px 6px 0 #c7bdf4;
  text-align: center;
}

.waiting-player-card.empty {
  background: rgba(255, 255, 255, 0.62);
  border-style: dashed;
  color: #9a8aa6;
}

.player-icon {
  width: 76px;
  height: 76px;
  margin: 0 auto 12px;
  border: 4px solid #30283a;
  border-radius: 22px;
  background: #fff7e8;
  object-fit: cover;
  display: block;
  box-shadow: 4px 4px 0 #fff3bf;
}

.player-name {
  display: block;
  min-width: 0;
  color: #30283a;
  font-size: 15px;
  font-weight: 900;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-role {
  display: inline-flex;
  margin-top: 7px;
  padding: 5px 9px;
  border: 2px solid #30283a;
  border-radius: 999px;
  background: #fff3bf;
  color: #6c6174;
  font-size: 11px;
  font-weight: 900;
}

.host-badge {
  position: absolute;
  top: -12px;
  left: 12px;
  padding: 5px 10px;
  border: 3px solid #30283a;
  border-radius: 999px;
  background: #ff95b9;
  color: #ffffff;
  font-size: 11px;
  font-weight: 900;
  box-shadow: 3px 3px 0 #c7bdf4;
}

.kick-btn {
  margin-top: 10px;
  min-height: 34px;
  padding: 7px 10px;
  border: 3px solid #30283a;
  border-radius: 999px;
  background: #ffe0e8;
  color: #8a3148;
  font-size: 12px;
  font-weight: 900;
  box-shadow: 3px 3px 0 #c7bdf4;
}

.watcher-area {
  width: min(720px, 100%);
  margin: 0 auto 28px;
  padding: 18px;
  border: 3px dashed rgba(48, 40, 58, 0.28);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.72);
}

.watcher-area h3 {
  margin: 0 0 12px;
  color: #30283a;
  font-size: 18px;
  font-weight: 900;
}

.watcher-list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.watcher-chip {
  padding: 7px 11px;
  border: 2px solid #30283a;
  border-radius: 999px;
  background: #fff3bf;
  color: #6c6174;
  font-size: 12px;
  font-weight: 900;
}

.waiting-actions,
.result-actions {
  display: flex;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
}

/* =========================
   battle screen
========================= */

.battle-topbar {
  width: min(920px, 100%);
  margin: 0 auto 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.battle-room-mini,
.turn-text {
  padding: 9px 14px;
  border: 3px solid #30283a;
  border-radius: 999px;
  background: #fff3bf;
  color: #30283a;
  font-size: 13px;
  font-weight: 900;
  box-shadow: 3px 3px 0 #c7bdf4;
}

.turn-text {
  background: #8ee8df;
}

.battle-message {
  width: min(920px, 100%);
  margin: 0 auto 18px;
  padding: 16px 18px;
  border: 4px solid #30283a;
  border-radius: 20px;
  background: #ffffff;
  box-shadow: 5px 5px 0 #c7bdf4;
  color: #30283a;
  text-align: center;
  font-size: 16px;
  font-weight: 900;
  line-height: 1.8;
}

.players-area {
  width: min(960px, 100%);
  margin: 0 auto 22px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.battle-player-card.dead {
  opacity: 0.55;
  filter: grayscale(0.8);
}

.battle-player-head {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  text-align: left;
}

.battle-player-head .player-icon {
  width: 72px;
  height: 72px;
  margin: 0;
}

.battle-player-name {
  min-width: 0;
}

.battle-player-name strong {
  display: block;
  color: #30283a;
  font-size: 17px;
  font-weight: 900;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.battle-player-name span {
  display: inline-flex;
  margin-top: 6px;
  padding: 4px 8px;
  border: 2px solid #30283a;
  border-radius: 999px;
  background: #fff3bf;
  color: #6c6174;
  font-size: 11px;
  font-weight: 900;
}

.status-bars {
  margin-top: 14px;
  display: grid;
  gap: 10px;
}

.status-row {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 48px;
  gap: 8px;
  align-items: center;
}

.status-row span {
  color: #6c6174;
  font-size: 12px;
  font-weight: 900;
}

.status-row strong {
  color: #30283a;
  font-size: 13px;
  font-weight: 900;
  text-align: right;
}

.status-bar {
  height: 16px;
  border: 3px solid #30283a;
  border-radius: 999px;
  background: #fff7e8;
  overflow: hidden;
}

.status-bar-fill {
  height: 100%;
  width: 0%;
  background: #ff95b9;
}

.status-bar-fill.sp {
  background: #8ee8df;
}

.selected-command {
  margin-top: 12px;
  padding: 9px 10px;
  border: 3px dashed rgba(48, 40, 58, 0.26);
  border-radius: 14px;
  background: #fff7e8;
  color: #6c6174;
  font-size: 12px;
  font-weight: 900;
}

/* =========================
   commands
========================= */

.command-panel {
  width: min(960px, 100%);
  margin: 0 auto 20px;
  padding: 20px;
  border: 4px solid #30283a;
  border-radius: 24px;
  background: #ffffff;
  box-shadow: 7px 7px 0 #c7bdf4;
}

.command-title {
  margin-bottom: 16px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.command-title span {
  padding: 5px 12px;
  border: 3px solid #30283a;
  border-radius: 999px;
  background: #fff3bf;
  color: #6f5ab8;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.command-title strong {
  color: #30283a;
  font-size: 16px;
  font-weight: 900;
}

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

.command-btn {
  min-height: 104px;
  padding: 12px 8px;
  border: 3px solid #30283a;
  border-radius: 18px;
  background: #fff7e8;
  color: #30283a;
  box-shadow: 4px 4px 0 #c7bdf4;
  display: grid;
  place-items: center;
  gap: 6px;
  text-align: center;
  font-weight: 900;
}

.command-btn:hover {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 #c7bdf4;
  background: #fff3bf;
}

.command-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.command-icon {
  width: 42px;
  height: 42px;
  object-fit: contain;
  image-rendering: pixelated;
}

.command-name {
  font-size: 13px;
  line-height: 1.25;
}

.command-cost {
  padding: 3px 8px;
  border: 2px solid #30283a;
  border-radius: 999px;
  background: #ffffff;
  color: #6c6174;
  font-size: 11px;
  font-weight: 900;
}

/* =========================
   battle log
========================= */

.battle-log {
  width: min(960px, 100%);
  max-height: 220px;
  margin: 0 auto;
  padding: 16px;
  border: 4px solid #30283a;
  border-radius: 20px;
  background: #30283a;
  color: #fffdf5;
  box-shadow: 6px 6px 0 #c7bdf4;
  overflow-y: auto;
  font-size: 13px;
  line-height: 1.8;
  font-weight: 800;
}

.log-line {
  padding: 5px 0;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.2);
}

.log-line:last-child {
  border-bottom: none;
}

/* =========================
   result
========================= */

.battle-result-card {
  width: min(760px, 100%);
  margin: 0 auto;
  padding: 28px;
  border: 4px solid #30283a;
  border-radius: 26px;
  background: #ffffff;
  box-shadow: 7px 7px 0 #c7bdf4;
  text-align: center;
}

.result-text {
  margin: 0 0 24px;
  color: #30283a;
  font-size: clamp(26px, 5vw, 42px);
  line-height: 1.35;
  font-weight: 900;
  text-shadow:
    2px 2px 0 #ffffff,
    4px 4px 0 #fff3bf;
}

.result-players {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

/* =========================
   modal
========================= */

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

.battle-modal-bg {
  position: absolute;
  inset: 0;
  background: rgba(48, 40, 58, 0.56);
}

.battle-modal-card {
  position: relative;
  z-index: 1;
  width: min(520px, 100%);
  max-height: calc(100dvh - 36px);
  padding: 28px;
  border: 4px solid #30283a;
  border-radius: 26px;
  background: #ffffff;
  box-shadow: 8px 8px 0 #c7bdf4;
  text-align: center;
  overflow-y: auto;
}

.modal-close-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 40px;
  height: 40px;
  border: 3px solid #30283a;
  border-radius: 50%;
  background: #ffe0e8;
  color: #30283a;
  font-size: 20px;
  font-weight: 900;
  line-height: 1;
  box-shadow: 3px 3px 0 #c7bdf4;
}

.modal-skill-icon-wrap {
  width: 92px;
  height: 92px;
  margin: 0 auto 16px;
  border: 4px solid #30283a;
  border-radius: 24px;
  background: #fff7e8;
  display: grid;
  place-items: center;
  box-shadow: 5px 5px 0 #fff3bf;
}

.modal-skill-icon {
  width: 62px;
  height: 62px;
  object-fit: contain;
  image-rendering: pixelated;
}

.modal-skill-name {
  margin: 0 0 10px;
  color: #30283a;
  font-size: 28px;
  font-weight: 900;
}

.modal-skill-description {
  margin: 0 auto 20px;
  color: #5f5668;
  font-size: 14px;
  line-height: 1.8;
  font-weight: 800;
}

.target-select-area {
  margin: 18px auto 20px;
  display: grid;
  gap: 10px;
}

.target-btn {
  min-height: 48px;
  padding: 10px 12px;
  border: 3px solid #30283a;
  border-radius: 16px;
  background: #fff7e8;
  color: #30283a;
  font-size: 14px;
  font-weight: 900;
  box-shadow: 3px 3px 0 #c7bdf4;
}

.target-btn.active,
.target-btn:hover {
  background: #8ee8df;
}

.modal-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* =========================
   mobile
========================= */

@media (max-width: 820px) {
  .battle-page {
    width: min(100% - 24px, 1040px);
    margin-bottom: 56px;
  }

  .battle-hero {
    margin: 24px auto 28px;
  }

  .battle-window {
    padding: 40px 18px 30px;
    border-radius: 24px;
  }

  .lobby-grid {
    grid-template-columns: 1fr;
  }

  .waiting-players {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .players-area {
    grid-template-columns: 1fr;
  }

  .command-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .result-players {
    grid-template-columns: 1fr;
  }

  .room-info-card {
    align-items: stretch;
    flex-direction: column;
    text-align: center;
  }
}

@media (max-width: 520px) {
  .battle-page {
    width: min(100% - 20px, 1040px);
  }

  .battle-window {
    padding: 38px 14px 28px;
  }

  .room-input-row {
    grid-template-columns: 1fr;
  }

  .waiting-players {
    grid-template-columns: 1fr;
  }

  .command-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .command-btn {
    min-height: 96px;
  }

  .battle-modal-card {
    padding: 24px 16px;
  }
}

.room-code-input {
  margin-bottom: 14px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.guest-name-help {
  margin: 8px 0 16px !important;
  color: #7a6f82 !important;
  font-size: 12px !important;
  line-height: 1.7 !important;
  font-weight: 800 !important;
}

.join-action-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

@media (max-width: 520px) {
  .join-action-row {
    grid-template-columns: 1fr;
  }
}

.create-mode-box {
  margin: 18px 0 20px;
  padding: 16px;
  border: 3px dashed rgba(48, 40, 58, 0.28);
  border-radius: 18px;
  background: #fff7e8;
}

.create-mode-title {
  margin: 0 0 12px !important;
  color: #6c6174 !important;
  font-size: 12px !important;
  font-weight: 900 !important;
  letter-spacing: 0.12em;
}

.create-mode-option {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 10px 0;
  padding: 10px 12px;
  border: 3px solid #30283a;
  border-radius: 15px;
  background: #ffffff;
  color: #30283a;
  font-size: 14px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 3px 3px 0 #c7bdf4;
}

.create-mode-option input {
  width: 18px;
  height: 18px;
  accent-color: #ff95b9;
}

.create-mode-option:has(input:checked) {
  background: #fff3bf;
}
