:root {
  color-scheme: dark;
  --ink: #f7ead8;
  --muted: #cebdce;
  --line: #433346;
  --warm: #efb466;
  background: #14111c;
  color: var(--ink);
  font: 16px/1.45 system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }

.entrance {
  position: relative;
  isolation: isolate;
  display: grid;
  justify-items: center;
  align-items: end;
  min-height: 100svh;
  padding: max(245px, 46svh) max(18px, env(safe-area-inset-right))
    max(24px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
}

.island {
  position: absolute;
  inset: 0 0 auto;
  z-index: -1;
  height: min(73svh, 680px);
  min-height: 390px;
  background:
    linear-gradient(180deg, transparent 47%, #14111c 100%),
    url("/arena/island.webp") center 60% / cover no-repeat,
    #292036;
}

.gate {
  width: min(100%, 430px);
}

.world {
  margin: 0 0 4px;
  color: #f2c38d;
  font-size: .75rem;
  font-weight: 720;
  letter-spacing: .13em;
  text-transform: uppercase;
}

h1 {
  margin: 0 0 18px;
  font: 600 clamp(2rem, 8.6vw, 3rem) / 1.04 Georgia, serif;
  text-shadow: 0 2px 14px #14111c;
}

.access {
  display: grid;
  gap: 16px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #1d1726;
  box-shadow: 0 16px 48px #100c16a6;
}

.status {
  margin: 0;
  color: var(--muted);
}

.status[data-error] { color: #ffc4ad; }

form { display: grid; gap: 7px; }
form label { color: var(--muted); font-size: .875rem; }

input {
  width: 100%;
  min-height: 44px;
  margin-bottom: 5px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #15101b;
  color: var(--ink);
  font: inherit;
}

button, .button {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 46px;
  padding: 9px 13px;
  border: 0;
  border-radius: 9px;
  background: var(--warm);
  color: #241527;
  cursor: pointer;
  font: 700 1rem/1.25 system-ui, sans-serif;
  text-align: center;
  text-decoration: none;
}

button:disabled { opacity: .65; cursor: wait; }
:is(button, .button, input):focus-visible { outline: 2px solid #ffd492; outline-offset: 3px; }

.arena-potion {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px 11px;
  padding: 10px;
  border: 1px solid #665068;
  border-radius: 10px;
  background: linear-gradient(110deg, #302239, #231a2d);
}

.arena-potion-icon {
  position: relative;
  justify-self: center;
  width: 24px;
  height: 23px;
  margin-top: 6px;
  border: 1px solid #d4b2e8;
  border-radius: 44% 44% 40% 40%;
  background: radial-gradient(circle at 31% 61%, #ead0ff 0 7%, transparent 10%),
    linear-gradient(165deg, #765481 35%, #c78bee 38%, #754caa 78%);
}

.arena-potion-icon::before {
  content: "";
  position: absolute;
  inset: -7px 6px auto;
  height: 6px;
  border-radius: 2px;
  background: #d1a67a;
}

.arena-potion-info small { display: block; color: var(--muted); }
.arena-potion button { min-width: 70px; font-variant-numeric: tabular-nums; }
.arena-potion button:disabled { cursor: default; }
.arena-potion-message { grid-column: 2 / -1; }

.pet {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.pet img {
  flex: none;
  object-fit: contain;
  border-radius: 10px;
  background: #15101b;
}

.pet div { min-width: 0; }
.pet span { display: block; color: var(--muted); font-size: .8125rem; }
.pet strong { font-size: 1.25rem; overflow-wrap: anywhere; }

.camp {
  display: grid;
  gap: 12px;
  margin-top: 12px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #1d1726;
}

.camp-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.camp-header h2 { margin: 0; font: 600 1.45rem/1.15 Georgia, serif; }
.camp-count { color: var(--muted); font-size: .875rem; }

.ready-toggle {
  display: flex;
  min-height: 44px;
  gap: 12px;
  align-items: center;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}

.ready-toggle input {
  width: 20px;
  height: 20px;
  min-height: 0;
  margin: 0;
  accent-color: var(--warm);
}

.ready-toggle:has(input:checked) { border-color: #916d40; background: #342535; }
.ready-toggle:has(input:disabled) { opacity: .65; cursor: default; }

.camp-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.camp-list li { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 6px 0; }
.camp-avatar {
  display: grid;
  place-items: center;
  flex: 0 0 42px;
  height: 42px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #15101b;
  color: var(--warm);
}

.camp-avatar img { width: 100%; height: 100%; object-fit: contain; }
.camp-identity { display: grid; min-width: 0; flex: 1; }
.camp-name { overflow-wrap: anywhere; }
.camp-ready { color: var(--warm); font-size: .8125rem; }
.camp-exit { border: 1px solid var(--line); background: transparent; color: var(--ink); }
.camp-challenge {
  width: auto;
  min-height: 40px;
  padding: 7px 10px;
  font-size: .875rem;
}
.camp-duel {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid #916d40;
  border-radius: 10px;
  background: #342535;
}
.camp-duel p { margin: 0; }
.camp-duel small { color: var(--muted); }
.duel-actions { display: flex; gap: 8px; }
.duel-actions:not(:has(button:not([hidden]))) { display: none; }
#duel-decline, #duel-cancel { background: transparent; border: 1px solid #916d40; color: var(--ink); }
.return-map {
  display: inline-grid;
  align-items: center;
  min-height: 44px;
  margin-top: 6px;
  padding: 0 6px;
  color: var(--ink);
  text-underline-offset: .2em;
}
.return-map:focus-visible { outline: 2px solid #ffd492; outline-offset: 3px; }
.fight-arena-island {
  padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right))
    max(12px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
}
.fight-arena-island .fight-backdrop {
  background-image: url("/arena/ring.webp");
  background-position: center 57%;
}
.fight-arena-island .fight-fighter.look-pending.no-look .fight-figure { visibility: visible; }
.fight-arena-island .fight-name {
  display: block !important;
  max-width: min(40vw, 180px);
  overflow: hidden;
  margin-bottom: 4px;
  text-overflow: ellipsis;
  text-shadow: 0 1px 4px #140d1a, 0 0 6px #140d1a;
}
.fight-arena-island .fight-btn { display: inline-grid; width: auto; min-height: 44px; }
.fight-arena-island .fight-log { height: 43px; }
.fight-arena-island .fight-menu { max-height: min(50vh, 360px); overflow: auto; }
.arena-result { margin-top: 12px; }
.arena-result .fight-plate {
  position: static;
  translate: none;
  width: 100%;
  max-width: none;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #1d1726;
  color: var(--ink);
  pointer-events: auto;
}
.arena-result .fight-plate-head { font-size: 1.35rem; }
.arena-result .fight-plate.win .fight-plate-head { color: #b1e8ac; }
.arena-result .fight-plate.loss .fight-plate-head { color: #ffc4ad; }
.arena-result .fight-plate-line { margin: 6px 0 10px; font-size: .875rem; }
.arena-result button { width: auto; margin-top: 8px; }

.camp-profile {
  display: block;
  width: fit-content;
  max-width: 100%;
  min-height: 30px;
  padding: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: .18em;
}
.duel-kit-actions { display: flex; gap: 8px; }
.duel-kit-actions button { padding-inline: 8px; font-size: .875rem; }
.preparation {
  width: min(calc(100% - 24px), 490px);
  max-height: min(90svh, 770px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: #1d1726;
  color: var(--ink);
}
.preparation::backdrop { background: #100b17cf; }
.preparation-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  background: #1d1726;
}
.preparation-head h2 { margin: 0; font: 600 1.4rem/1.12 Georgia, serif; overflow-wrap: anywhere; }
.preparation-head button { width: auto; flex: none; }
.preparation-status { padding: 10px 16px 0; }
.preparation-body { display: grid; gap: 14px; padding: 14px 16px 18px; }
.kit-portrait {
  justify-self: center;
  width: min(100%, 136px);
  height: 132px;
  object-fit: contain;
}
.kit-health {
  margin: 0;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #b1e8ac;
}
.kit-health small { display: block; color: #ffc4ad; }
.kit-section { display: grid; gap: 9px; }
.kit-section h3 { margin: 0; color: var(--warm); font: 600 1.1rem/1.2 Georgia, serif; }
.kit-list { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.kit-row, .kit-slot {
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #18121f;
}
.kit-row { display: flex; align-items: center; gap: 9px; padding: 7px 9px; }
.kit-icon { flex: 0 0 34px; width: 34px; height: 38px; object-fit: contain; }
.kit-identity { display: grid; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.kit-identity small, .kit-balance { color: var(--muted); }
.kit-button { width: auto; min-height: 40px; flex: none; padding-inline: 10px; font-size: .875rem; }
.kit-slot { display: grid; gap: 7px; padding: 10px; }
.kit-field { display: grid; gap: 4px; font-size: .875rem; }
.kit-field select {
  width: 100%;
  min-height: 44px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #201827;
  color: var(--ink);
  font: inherit;
}
.kit-field select:focus-visible { outline: 2px solid #ffd492; }

@media (min-width: 760px) {
  .entrance { justify-items: start; padding-left: max(9vw, 32px); }
  .island { height: 100%; background-position: center 55%; }
  .gate { margin-bottom: 5svh; }
}
