:root {
  color-scheme: dark;
  --ink: #f5f6fa;
  --battle-base: #0e1a27;
  --space: clamp(0.875rem, 2vw, 1.75rem);
  --top-space: max(var(--space), env(safe-area-inset-top));
}

:root,
.language [lang] {
  font-family: Rubik, sans-serif;
}

:is(:root, .language [lang]):lang(ja) {
  font-family: "Noto Sans JP", Rubik, sans-serif;
}

:is(:root, .language [lang]):lang(zh) {
  font-family: "Noto Sans SC", Rubik, sans-serif;
}

:is(:root, .language [lang]):lang(ko) {
  font-family: "Noto Sans KR", Rubik, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  background: var(--battle-base);
  color: var(--ink);
  font-size: 1rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.scene {
  position: absolute;
  z-index: -1;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.scene::after {
  position: absolute;
  z-index: 0;
  inset: 0;
  background: linear-gradient(transparent 66%, #08131e35 83%, #08131ea8);
  content: "";
}

.battle-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: right top;
}

.scene-brand {
  position: absolute;
  z-index: 1;
  top: clamp(1.6rem, 5svh, 4rem);
  left: 50%;
  width: clamp(13rem, 28vw, 31rem);
  aspect-ratio: 2172 / 420;
  background: url("assets/imtank-logo.png") center 42.3% / 100% auto no-repeat;
  transform: translateX(-50%);
  filter: drop-shadow(0 .32rem .7rem #000b);
}

.battle-brand {
  display: none;
}

.arena-scene {
  --arena-position: center top;
  background: url("assets/arena-poster.jpg") var(--arena-position) / cover no-repeat;
}

.arena-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: var(--arena-position);
  opacity: 0;
}

.arena-video.is-visible {
  opacity: 1;
}

.top-bar {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: flex-end;
  min-height: calc(var(--top-space) + 2.75rem);
  padding: var(--top-space) max(var(--space), env(safe-area-inset-right)) 0
    max(var(--space), env(safe-area-inset-left));
}

.motion-toggle {
  display: grid;
  flex: 0 0 auto;
  width: 2.75rem;
  height: 2.75rem;
  margin-inline-end: auto;
  padding: 0;
  place-items: center;
  border: 1px solid #85a1b06b;
  border-radius: .45rem;
  background: #0b1723eb;
  color: var(--ink);
  box-shadow: 0 .2rem .75rem #02081178;
  cursor: pointer;
}

.motion-toggle:hover {
  background: #182c3e;
}

.motion-icon {
  width: .78rem;
  height: .9rem;
  border-inline: .2rem solid currentColor;
}

.motion-toggle[data-action="play"] .motion-icon {
  border: 0;
  background: currentColor;
  clip-path: polygon(0 0, 100% 50%, 0 100%);
  transform: translateX(.05rem);
}

.language {
  position: relative;
  align-self: flex-start;
}

.language button {
  display: flex;
  align-items: center;
  gap: .65rem;
  border: 0;
  color: var(--ink);
  font: inherit;
  text-align: start;
  cursor: pointer;
}

.language .language-trigger {
  min-height: 2.75rem;
  padding: .45rem .75rem;
  border: 1px solid #85a1b06b;
  border-radius: .45rem;
  background: #0b1723eb;
  box-shadow: 0 .2rem .75rem #02081178;
  font-weight: 700;
}

.language .language-trigger:hover {
  background: #182c3e;
}

.language-flag {
  display: block;
  flex: 0 0 auto;
  width: 1.75rem;
  height: 1.375rem;
  object-fit: contain;
}

.language-chevron {
  width: .43rem;
  height: .43rem;
  margin: -.2rem .12rem 0 .2rem;
  border: solid #a0d9f4;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.language-trigger[aria-expanded="true"] .language-chevron {
  margin-top: .22rem;
  transform: rotate(225deg);
}

.language-options {
  position: absolute;
  top: calc(100% + .4rem);
  right: 0;
  width: max-content;
  min-width: 100%;
  max-width: calc(100vw - 2 * var(--space));
  max-height: calc(100dvh - var(--top-space) - 4rem - env(safe-area-inset-bottom));
  margin: 0;
  padding: .3rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid #85a1b06b;
  border-radius: .5rem;
  background: #0b1724fa;
  box-shadow: 0 .5rem 1.5rem #0009;
  list-style: none;
}

.language-option {
  width: 100%;
  min-height: 2.5rem;
  padding: .4rem .6rem;
  border-radius: .3rem;
  background: transparent;
  white-space: nowrap;
}

.language-option:hover,
.language-option[aria-current="true"] {
  background: #1b3247;
}

.language-option[aria-current="true"]::after {
  flex: 0 0 auto;
  width: .36rem;
  height: .68rem;
  margin-left: auto;
  border: solid #9dea9c;
  border-width: 0 2px 2px 0;
  transform: translateY(-.08rem) rotate(45deg);
  content: "";
}

.main-content {
  display: grid;
  align-content: end;
  justify-items: center;
  min-height: 0;
  padding: 1.5rem max(var(--space), env(safe-area-inset-right)) clamp(.85rem, 2.7svh, 1.6rem)
    max(var(--space), env(safe-area-inset-left));
}

.actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(.8rem, 2vw, 2.1rem);
  width: min(100%, 52rem, max(32rem, 50vw));
}

.action {
  position: relative;
  display: grid;
  align-items: center;
  min-height: 3.25rem;
  aspect-ratio: 1785 / 384;
  padding: .6rem 10%;
  color: #f8fbff;
  font-size: clamp(1.1875rem, min(2.25vw, 4.9svh), 2.35rem);
  font-weight: 900;
  line-height: 1.08;
  overflow-wrap: anywhere;
  text-align: center;
  text-decoration: none;
  text-shadow: 0 2px 3px #000d;
  text-transform: uppercase;
  filter: drop-shadow(0 .32rem .5rem #000b);
  transition: filter .16s ease;
}

.action::before,
.action::after {
  position: absolute;
  inset: 0;
  pointer-events: none;
  content: "";
}

.action::before {
  background: var(--action-fill);
  clip-path: polygon(8.4% 4.5%, 96.4% 4.5%, 99% 17%, 99% 63%, 92.6% 95.5%,
    3.7% 95.5%, 1.1% 81.5%, 1.1% 42%);
}

.action::after {
  /* Keep the outer art continuous and fade each side before the baked text. */
  background: var(--action-frame) center / 100% 100% no-repeat;
  mask-image:
    linear-gradient(#000 21%, transparent 28.2%),
    linear-gradient(to top, #000 16.5%, transparent 23.6%),
    linear-gradient(to right, #000 8%, transparent 13.5%),
    linear-gradient(to left, #000 8%, transparent 13.5%);
  mask-composite: add;
}

.action span {
  position: relative;
  z-index: 1;
}

.action:hover {
  filter: brightness(1.16) drop-shadow(0 .32rem .55rem #000c);
}

.action-portal {
  --action-frame: url("assets/button-portal.png");
  --action-fill: linear-gradient(#012a57 28%, #012f63 50%, #003775 65%, #003f89 76%);
}

.action-play {
  --action-frame: url("assets/button-play.png");
  --action-fill: linear-gradient(#546e08 28%, #608309 50%, #6f990b 65%, #7dac0c 76%);
}

.action:focus-visible,
.motion-toggle:focus-visible,
.language button:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 3px;
}

.language-option:focus-visible {
  outline-offset: -3px;
}

.footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0 1rem;
  padding: .18rem max(var(--space), env(safe-area-inset-right)) calc(.18rem + env(safe-area-inset-bottom))
    max(var(--space), env(safe-area-inset-left));
  border-top: 1px solid #a9c5dc24;
  background: #071321a8;
  color: #bdcbd9;
  text-align: center;
}

.footer-logos {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: .25rem;
}

.footer-logos img {
  display: block;
  width: auto;
  height: clamp(2.05rem, 4.45svh, 2.8rem);
}

.footer p {
  margin: .24rem 0;
  font-size: .8125rem;
  line-height: 1.4;
}

@media (min-aspect-ratio: 3/2) {
  .battle-page .language-name {
    display: none;
  }
}

@media (max-aspect-ratio: 3/2) {
  .battle-art {
    /* Keep the focal crop to the left of the logo printed in the photograph. */
    --photo-width: max(177.778dvh, 170vw);
    inset: 0 auto auto clamp(calc(100% - var(--photo-width)), calc(50% - var(--photo-width) * .275), 0px);
    width: var(--photo-width);
    height: auto;
  }

  .battle-brand,
  .arena-brand {
    top: calc(var(--top-space) + 3.35rem);
    display: block;
    width: clamp(11rem, 49vw, 23rem);
  }
}

@media (max-aspect-ratio: 5/6) {
  .arena-scene {
    --arena-position: 41% center;
  }
}

@media (max-width: 35rem) {
  .actions {
    grid-template-columns: minmax(0, 1fr);
    gap: .68rem;
    width: min(100%, 24rem);
  }

  .action {
    min-height: 3.65rem;
    font-size: clamp(1.25rem, 4.5vw, 1.5rem);
  }

  .footer {
    flex-direction: column;
    padding-top: .14rem;
    padding-bottom: calc(.38rem + env(safe-area-inset-bottom));
  }

  .footer p {
    margin-top: 0;
  }
}

@media (max-height: 29rem) and (min-aspect-ratio: 6/5) {
  :root {
    --space: .75rem;
  }

  .main-content {
    padding-bottom: .65rem;
  }

  .action {
    min-height: 3.1rem;
  }

  .battle-page .language-trigger {
    column-gap: .35rem;
    padding-inline: .45rem;
  }

  .footer-logos img {
    height: 1.9rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .action {
    transition: none;
  }
}
