:root {
  color-scheme: dark;
  --ink: #f8fafc;
  --muted: #b9c0c9;
  --screen: #11151b;
  --tile: #2a3038;
  --tile-dark: #171a20;
  --line: rgba(255, 255, 255, 0.16);
  --gold: #ffd23f;
  --blue: #178bff;
  --pink: #ff4fa4;
  --red: #f04438;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  overflow: hidden;
  background:
    linear-gradient(105deg, rgba(41, 0, 160, 0.82) 0 24%, transparent 24% 100%),
    radial-gradient(circle at 58% 70%, rgba(255, 255, 255, 0.8), transparent 9rem),
    linear-gradient(135deg, #16a8ff 0%, #83eeff 46%, #ffd1e8 72%, #2030d2 100%);
  color: var(--ink);
  font-family: Impact, Haettenschweiler, "Arial Narrow Bold", system-ui, sans-serif;
  letter-spacing: 0;
}

button {
  font: inherit;
}

.select-screen {
  position: relative;
  display: grid;
  grid-template-rows: 44px auto 1fr 220px;
  height: 100vh;
  min-height: 0;
  padding: 0;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.08), rgba(255, 255, 255, 0.16) 62%, rgba(0, 0, 0, 0.9) 62% 100%);
}

.select-screen.ready-armed .roster,
.select-screen.ready-armed .bottom-bar {
  filter: brightness(0.52) saturate(0.85);
}

.game-header {
  position: relative;
  display: grid;
  grid-template-columns: 92px 1fr 92px;
  align-items: stretch;
  background: #050507;
  border-bottom: 4px solid #23252b;
  box-shadow: 0 4px 0 rgba(255, 255, 255, 0.18);
}

.game-header::before,
.game-header::after {
  content: "";
  background: linear-gradient(135deg, #09a4ff, #006ee8);
}

.game-header::before {
  grid-column: 1;
  clip-path: polygon(0 0, 100% 0, 76% 100%, 0 100%);
}

.game-header::after {
  grid-column: 3;
  clip-path: polygon(24% 0, 100% 0, 100% 100%, 0 100%);
}

.back-button {
  position: absolute;
  left: 14px;
  top: 4px;
  z-index: 1;
  width: 48px;
  height: 36px;
  border: 0;
  background: transparent;
  color: #d8f5ff;
  cursor: pointer;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 2rem;
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 2px 0 #005199;
}

.mode-title {
  grid-column: 2;
  align-self: center;
  justify-self: center;
  width: min(760px, calc(100vw - 210px));
  height: 100%;
  display: grid;
  place-items: center;
  background: #08090c;
  color: #f3f5f7;
  font-family: Arial, Helvetica, sans-serif;
  font-size: clamp(1rem, 2.35vw, 1.75rem);
  font-weight: 900;
  clip-path: polygon(5% 0, 95% 0, 100% 100%, 0 100%);
}

.message-strip {
  display: grid;
  grid-template-columns: minmax(220px, auto) minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  padding: 5px 20px 6px;
  background: rgba(0, 0, 0, 0.86);
  border-bottom: 3px solid rgba(255, 255, 255, 0.22);
}

.message-strip h1 {
  margin: 0;
  color: var(--gold);
  font-size: clamp(1.35rem, 3.15vw, 2.6rem);
  line-height: 0.88;
  text-transform: uppercase;
  text-shadow: 4px 4px 0 #000;
  white-space: nowrap;
}

.message-strip p {
  min-height: 1.35em;
  margin: 0;
  color: #fff;
  font-family: Arial, Helvetica, sans-serif;
  font-size: clamp(0.95rem, 1.75vw, 1.35rem);
  font-weight: 900;
  line-height: 1.15;
  text-align: right;
  text-shadow: 2px 2px 0 #000;
  overflow-wrap: anywhere;
}

.roster-wrap {
  min-height: 0;
  display: flex;
  align-items: start;
  padding: 9px 18px 10px;
  background:
    linear-gradient(180deg, rgba(5, 7, 10, 0.92), rgba(15, 18, 24, 0.86) 86%, rgba(0, 0, 0, 0));
}

.roster {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(58px, 1fr));
  grid-auto-rows: 1fr;
  gap: 3px;
}

.fighter {
  position: relative;
  min-width: 0;
  min-height: 0;
  border: 2px solid #07080b;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.2), transparent 40%),
    linear-gradient(180deg, var(--accent), #161a20 72%);
  color: var(--ink);
  cursor: pointer;
  padding: 0;
  overflow: hidden;
  box-shadow: inset 0 -20px 18px rgba(0, 0, 0, 0.52), 0 1px 0 rgba(255, 255, 255, 0.45);
  transition: transform 120ms ease, border-color 120ms ease, filter 120ms ease;
}

.fighter::before {
  content: attr(data-initial);
  position: absolute;
  inset: 3px 4px 17px;
  display: grid;
  place-items: end center;
  background:
    radial-gradient(circle at 50% 22%, rgba(255, 255, 255, 0.72), transparent 18%),
    linear-gradient(135deg, rgba(255, 255, 255, 0.14), transparent 48%),
    color-mix(in srgb, var(--accent), white 16%);
  color: rgba(255, 255, 255, 0.9);
  font-size: clamp(1.45rem, 3.2vw, 2.7rem);
  line-height: 1;
  text-shadow: 3px 3px 0 rgba(0, 0, 0, 0.35);
  clip-path: polygon(13% 0, 100% 0, 88% 100%, 0 100%);
}

.fighter.has-sprite::before {
  content: "";
  background:
    radial-gradient(circle at 50% 20%, rgba(255, 255, 255, 0.48), transparent 18%),
    linear-gradient(135deg, rgba(255, 255, 255, 0.16), transparent 48%),
    color-mix(in srgb, var(--accent), white 10%);
}

.fighter-portrait {
  position: absolute;
  z-index: 1;
  left: 50%;
  bottom: 13px;
  width: 92%;
  height: 86%;
  object-fit: contain;
  transform: translateX(-50%);
  filter: drop-shadow(2px 3px 0 rgba(0, 0, 0, 0.58));
  pointer-events: none;
}

.fighter::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 26px;
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.94) 48%);
}

.fighter span {
  position: absolute;
  z-index: 2;
  left: 2px;
  right: 2px;
  bottom: 2px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-family: Arial, Helvetica, sans-serif;
  font-size: clamp(0.45rem, 0.75vw, 0.62rem);
  font-weight: 900;
  text-transform: uppercase;
  text-shadow: 1px 1px 0 #000;
}

.fighter:hover:not(:disabled),
.fighter.selected {
  z-index: 1;
  transform: translateY(-3px) scale(1.06);
  border-color: var(--gold);
  filter: saturate(1.2);
}

.fighter.selected {
  box-shadow: inset 0 -18px 30px rgba(0, 0, 0, 0.28), 0 0 0 4px var(--gold), 0 12px 22px rgba(0, 0, 0, 0.5);
}

.fighter:disabled {
  cursor: not-allowed;
  filter: grayscale(1) brightness(0.35);
}

.fighter:disabled span {
  color: rgba(255, 255, 255, 0.46);
}

.bottom-bar {
  display: grid;
  grid-template-columns: minmax(245px, 1fr) minmax(170px, 0.52fr) minmax(245px, 1fr);
  gap: 12px;
  align-items: end;
  padding: 8px 7vw 0;
  background:
    linear-gradient(90deg, rgba(93, 19, 190, 0.9), rgba(55, 230, 255, 0.8) 52%, rgba(242, 250, 255, 0.85)),
    radial-gradient(circle at 50% 10%, rgba(255, 255, 255, 0.9), transparent 14rem);
  border-top: 3px solid rgba(255, 255, 255, 0.2);
  overflow: hidden;
}

.ready-banner {
  position: absolute;
  z-index: 20;
  left: 50%;
  top: 42%;
  width: min(96vw, 1220px);
  height: clamp(116px, 18vw, 190px);
  border: 0;
  padding: 0;
  color: #ff9400;
  cursor: pointer;
  background: transparent;
  transform: translate(-50%, -50%) rotate(-7deg);
  filter: drop-shadow(0 18px 12px rgba(0, 0, 0, 0.64));
}

.ready-banner::before {
  content: "";
  position: absolute;
  inset: 5% 0 4%;
  background:
    linear-gradient(180deg, #fff 0 19%, transparent 19% 75%, rgba(255, 255, 255, 0.9) 75% 100%),
    linear-gradient(90deg, rgba(255, 0, 0, 0.96) 0 18%, rgba(255, 0, 0, 0.82) 18% 100%);
  clip-path: polygon(1% 22%, 100% 0, 98% 86%, 0 100%);
}

.ready-banner::after {
  content: "";
  position: absolute;
  inset: 19% 9% 22%;
  background: rgba(0, 0, 0, 0.94);
  clip-path: polygon(7% 17%, 100% 0, 93% 82%, 0 100%);
}

.ready-banner span {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: clamp(7px, 1.1vw, 15px);
  height: 100%;
  font-size: clamp(3rem, 9vw, 8.6rem);
  font-style: italic;
  line-height: 0.8;
  text-transform: uppercase;
  text-shadow:
    5px 5px 0 #000,
    8px 8px 0 rgba(255, 0, 0, 0.44);
  transform: skew(-11deg);
}

.ready-banner small {
  color: #ff9400;
  font-size: 0.42em;
}

.ready-banner:hover span,
.ready-banner:focus-visible span {
  color: #ffd03d;
}

.ready-banner:focus-visible {
  outline: 5px solid #fff;
  outline-offset: 8px;
}

.fight-reveal {
  position: fixed;
  z-index: 40;
  inset: 0;
  overflow: hidden;
  background: #000;
  pointer-events: none;
}

.fight-panel {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 50.15%;
  background-image: url("assets/reveal/zeldavslink.png");
  background-size: 200% 100%;
  background-repeat: no-repeat;
  transform: translateX(0);
  will-change: transform, filter;
}

.fight-panel-left {
  left: 0;
  background-position: left center;
}

.fight-panel-right {
  right: 0;
  background-position: right center;
}

.fight-reveal.shake .fight-panel {
  animation: revealShake 90ms linear 12;
}

.fight-reveal.split .fight-panel-left {
  animation: splitLeft 820ms cubic-bezier(0.2, 0.9, 0.18, 1) forwards;
}

.fight-reveal.split .fight-panel-right {
  animation: splitRight 820ms cubic-bezier(0.2, 0.9, 0.18, 1) forwards;
}

.fight-flash {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #ff9400;
  font-size: clamp(4rem, 16vw, 13rem);
  font-style: italic;
  line-height: 0.8;
  text-transform: uppercase;
  text-shadow:
    6px 6px 0 #000,
    11px 11px 0 rgba(255, 0, 0, 0.55);
  opacity: 0;
  transform: scale(0.65) rotate(-6deg);
}

.fight-reveal.split .fight-flash {
  animation: fightPop 900ms cubic-bezier(0.12, 1.1, 0.2, 1) 160ms forwards;
}

@keyframes revealShake {
  0% { transform: translate(0, 0) rotate(0); filter: brightness(1); }
  25% { transform: translate(-8px, 3px) rotate(-0.25deg); filter: brightness(1.15); }
  50% { transform: translate(7px, -4px) rotate(0.25deg); filter: brightness(0.95); }
  75% { transform: translate(-5px, -2px) rotate(-0.2deg); filter: brightness(1.08); }
  100% { transform: translate(0, 0) rotate(0); filter: brightness(1); }
}

@keyframes splitLeft {
  0% { transform: translateX(0) rotate(0); }
  100% { transform: translateX(-112%) rotate(-7deg); }
}

@keyframes splitRight {
  0% { transform: translateX(0) rotate(0); }
  100% { transform: translateX(112%) rotate(7deg); }
}

@keyframes fightPop {
  0% { opacity: 0; transform: scale(0.65) rotate(-6deg); }
  45% { opacity: 1; transform: scale(1.1) rotate(-6deg); }
  100% { opacity: 1; transform: scale(1) rotate(-6deg); }
}

.player-card {
  position: relative;
  min-height: 205px;
  border: 5px solid #07080b;
  border-bottom: 0;
  background: #f4f6f8;
  color: #08090b;
  overflow: hidden;
  box-shadow: 0 0 0 3px #f7f7f7 inset;
  transform: skew(-5deg);
}

.player-card > * {
  transform: skew(5deg);
}

.player-card.active {
  outline: 5px solid var(--gold);
  outline-offset: -10px;
}

.card-portrait-wrap {
  position: absolute;
  inset: 6px 20px 0 auto;
  width: min(46%, 190px);
  display: flex;
  align-items: end;
  justify-content: center;
  opacity: 0.96;
  pointer-events: none;
}

.girl-card .card-portrait-wrap {
  inset: 6px auto 0 20px;
}

.card-portrait-wrap[data-initial]::before {
  content: attr(data-initial);
  align-self: center;
  color: rgba(0, 0, 0, 0.24);
  font-size: clamp(3rem, 8vw, 6rem);
  line-height: 1;
}

.card-portrait {
  max-width: 100%;
  max-height: 168px;
  object-fit: contain;
  filter: drop-shadow(5px 7px 0 rgba(0, 0, 0, 0.38));
}

.card-portrait[hidden] {
  display: none;
}

.boy-card .card-slash {
  position: absolute;
  inset: 0 42% 0 0;
  background: linear-gradient(135deg, #18b7ff, #0759d8);
  clip-path: polygon(0 0, 68% 0, 100% 100%, 0 100%);
}

.girl-card .card-slash {
  position: absolute;
  inset: 0 0 0 42%;
  background: linear-gradient(135deg, #ff75c4, #f51b83);
  clip-path: polygon(24% 0, 100% 0, 100% 100%, 0 100%);
}

.player-tag {
  position: absolute;
  z-index: 2;
  right: 22px;
  bottom: 2px;
  color: #fff;
  font-size: clamp(2.4rem, 5vw, 4.7rem);
  line-height: 0.95;
  text-shadow: 4px 4px 0 #000;
}

.girl-card .player-tag {
  color: #111;
  text-shadow: 2px 2px 0 #fff;
}

.name-plate {
  position: absolute;
  z-index: 3;
  left: 24px;
  right: 24px;
  bottom: 94px;
  min-height: 40px;
  display: flex;
  align-items: center;
  border: 3px solid #07080b;
  background: rgba(255, 255, 255, 0.88);
  padding: 3px 12px;
  overflow-wrap: anywhere;
  font-family: Arial, Helvetica, sans-serif;
  font-size: clamp(1rem, 2vw, 1.55rem);
  font-weight: 1000;
  text-transform: none;
}

.team-name {
  position: absolute;
  z-index: 3;
  left: 28px;
  bottom: 36px;
  padding: 4px 12px;
  background: #0759d8;
  color: #fff;
  border: 3px solid #07080b;
  font-size: clamp(1rem, 2.5vw, 1.9rem);
  text-shadow: 2px 2px 0 #000;
}

.girl-card .team-name {
  background: #f51b83;
}

.center-controls {
  align-self: center;
  display: grid;
  grid-template-columns: 1fr;
  gap: 9px;
}

.confirm-button,
.reset-button {
  min-height: 42px;
  border: 0;
  color: #0a0d12;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.52);
}

.confirm-button {
  background: linear-gradient(180deg, #fff176, var(--gold));
  font-size: clamp(1.35rem, 3vw, 2.2rem);
}

.reset-button {
  background: #d6dde8;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 1rem;
  font-weight: 900;
}

.confirm-button:disabled {
  cursor: not-allowed;
  filter: grayscale(1) brightness(0.55);
}

@media (max-width: 780px) {
  .select-screen {
    grid-template-rows: 42px auto 1fr auto;
    height: auto;
    min-height: 100vh;
  }

  body {
    overflow: auto;
  }

  .message-strip {
    grid-template-columns: 1fr;
  }

  .message-strip h1 {
    white-space: normal;
  }

  .message-strip p {
    text-align: left;
  }

  .roster {
    grid-template-columns: repeat(auto-fit, minmax(44px, 1fr));
  }

  .bottom-bar {
    grid-template-columns: 1fr;
    padding: 10px 12px;
  }

  .player-card {
    min-height: 112px;
  }

  .card-portrait {
    max-height: 94px;
  }

  .center-controls {
    order: 3;
  }
}
