@font-face {
  font-family: "Noto Sans SC Local";
  src: url("./assets/noto-sans-sc-display.ttf") format("truetype");
  font-display: swap;
}

@font-face {
  font-family: "Winter Display";
  src: url("./assets/headline-display.ttf") format("truetype");
  font-display: swap;
}

:root {
  color-scheme: light;
  --snow: #f3fbff;
  --white: #ffffff;
  --ink: #17334a;
  --muted: #6d8799;
  --ice: #42badd;
  --ice-soft: #dff5fc;
  --orange: #ff9c45;
  --orange-soft: #fff0df;
  --coral: #ef5350;
  --line: #cfe5ef;
  --shadow: rgba(48, 102, 128, 0.14);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: #deeff6;
}

body {
  min-width: 320px;
  min-height: 100dvh;
  margin: 0;
  color: var(--ink);
  background: #deeff6;
  font-family: "Noto Sans SC Local", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
  letter-spacing: 0;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  display: flex;
  width: min(100%, 430px);
  min-height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  flex-direction: column;
  background: var(--snow);
  box-shadow: 0 20px 70px var(--shadow);
}

.topbar {
  position: relative;
  z-index: 3;
  display: flex;
  min-height: 105px;
  align-items: center;
  justify-content: center;
  padding: 7px 12px 5px;
  border-bottom: 0;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(16px);
}

.brand-logo {
  display: flex;
  width: min(100%, 322px);
  min-height: 86px;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.brand-logo img {
  display: block;
  width: 100%;
  height: auto;
}

.match-stage {
  position: relative;
  height: 447px;
  flex: 0 0 447px;
  overflow: hidden;
  border-bottom: 1px solid #b9dce9;
  background-color: var(--white);
  background-image: url("./assets/pk-snow-fight.png");
  background-repeat: no-repeat;
  background-position: center center;
  background-size: cover;
}

.match-stage::after {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 28px;
  background: rgba(243, 251, 255, 0.88);
  content: "";
  clip-path: polygon(0 72%, 8% 42%, 17% 78%, 28% 36%, 39% 70%, 50% 30%, 62% 76%, 73% 43%, 85% 72%, 94% 35%, 100% 66%, 100% 100%, 0 100%);
}

.versus {
  position: absolute;
  top: 48%;
  left: 50%;
  z-index: 2;
  width: 116px;
  height: 116px;
  filter: drop-shadow(0 9px 9px rgba(48, 91, 112, 0.22));
  transform: translate(-50%, -50%) rotate(-4deg);
}

.versus img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.match-controls {
  position: relative;
  z-index: 2;
  padding: 14px 16px 16px;
  background: var(--snow);
}

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

.kingdom-input {
  display: block;
  min-width: 0;
  padding: 10px 10px 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
  box-shadow: 0 6px 16px rgba(74, 129, 151, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.kingdom-input > span:first-child {
  display: block;
  margin-bottom: 2px;
  font-size: 10px;
  font-weight: 800;
}

.kingdom-a > span:first-child {
  color: #168db6;
}

.kingdom-b > span:first-child {
  color: #d96b18;
}

.input-line {
  display: flex;
  align-items: center;
}

.input-line b {
  margin-right: 5px;
  color: #90a9b8;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px;
}

.input-line input {
  width: 100%;
  min-width: 0;
  padding: 0;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 25px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}

.swap-button {
  position: relative;
  display: inline-flex;
  width: 48px;
  height: 48px;
  align-items: center;
  justify-content: center;
  border: 0;
  color: #258bae;
  background: #49bfe2;
  clip-path: polygon(25% 0, 75% 0, 100% 25%, 100% 75%, 75% 100%, 25% 100%, 0 75%, 0 25%);
  filter: drop-shadow(0 5px 5px rgba(66, 123, 146, 0.18));
  cursor: pointer;
  transition: transform 180ms ease, background-color 180ms ease;
}

.swap-button::before {
  position: absolute;
  inset: 3px;
  z-index: 0;
  background: var(--white);
  clip-path: inherit;
  content: "";
  transition: background-color 180ms ease;
}

.swap-button:hover {
  background: #2aaed3;
}

.swap-button:hover::before {
  background: var(--ice-soft);
}

.swap-button:active {
  transform: rotate(180deg) scale(0.96);
}

.swap-button svg {
  position: relative;
  z-index: 1;
  width: 19px;
  height: 19px;
  stroke-width: 2;
}

.range-control {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  margin-top: 10px;
  padding: 0;
  border: 0;
  background: transparent;
}

.range-control button {
  min-height: 44px;
  border: 0;
  color: #6c8798;
  background: #e0f1f7;
  clip-path: polygon(9px 0, calc(100% - 9px) 0, 100% 9px, 100% calc(100% - 9px), calc(100% - 9px) 100%, 9px 100%, 0 calc(100% - 9px), 0 9px);
  box-shadow: inset 0 0 0 2px #b8dce9, inset 0 -5px 0 rgba(92, 161, 186, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.9);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
  transition: color 180ms ease, background-color 180ms ease, box-shadow 180ms ease, transform 180ms ease, filter 180ms ease;
}

.range-control button:hover {
  color: #176f8e;
  background: #d0edf7;
}

.range-control button.active {
  color: var(--white);
  background: #35add1;
  box-shadow: inset 0 0 0 2px #178fb7, inset 0 -6px 0 rgba(21, 110, 141, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.34);
  filter: drop-shadow(0 4px 4px rgba(42, 125, 155, 0.2));
}

.range-control button:active {
  transform: translateY(1px);
}

.start-button {
  position: relative;
  isolation: isolate;
  display: grid;
  width: 100%;
  min-height: 58px;
  margin-top: 13px;
  grid-template-columns: 48px 1fr 44px;
  align-items: center;
  gap: 8px;
  padding: 0 7px;
  border: 0;
  color: var(--white);
  background: var(--coral);
  clip-path: polygon(12px 0, calc(100% - 12px) 0, 100% 12px, 100% calc(100% - 12px), calc(100% - 12px) 100%, 12px 100%, 0 calc(100% - 12px), 0 12px);
  box-shadow: inset 0 -7px 0 rgba(165, 42, 48, 0.34), inset 0 2px 0 rgba(255, 255, 255, 0.28);
  filter: drop-shadow(0 7px 0 #c8383d) drop-shadow(0 10px 10px rgba(185, 73, 77, 0.18));
  font-size: 16px;
  font-weight: 900;
  cursor: pointer;
  transition: transform 160ms ease, background-color 160ms ease, box-shadow 160ms ease, filter 160ms ease;
}

.start-button::before,
.start-button::after {
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: -1;
  content: "";
}

.start-button::before {
  left: 0;
  width: 60px;
  background: #35add1;
  clip-path: polygon(12px 0, 100% 0, 76% 100%, 12px 100%, 0 calc(100% - 12px), 0 12px);
  box-shadow: inset 0 -7px 0 rgba(21, 110, 141, 0.28), inset -2px 0 0 rgba(255, 255, 255, 0.35);
}

.start-button::after {
  right: 0;
  width: 54px;
  background: var(--orange);
  clip-path: polygon(28% 0, calc(100% - 12px) 0, 100% 12px, 100% calc(100% - 12px), calc(100% - 12px) 100%, 0 100%);
  box-shadow: inset 0 -7px 0 rgba(203, 100, 25, 0.28), inset 2px 0 0 rgba(255, 255, 255, 0.3);
}

.start-button:hover {
  background: #f15c59;
}

.start-button:active {
  transform: translateY(4px);
  filter: drop-shadow(0 3px 0 #c8383d) drop-shadow(0 6px 6px rgba(185, 73, 77, 0.16));
}

.start-button svg {
  position: relative;
  z-index: 1;
  width: 20px;
  height: 20px;
  stroke-width: 2.1;
}

.start-button svg:last-child {
  justify-self: end;
}

.start-button span {
  position: relative;
  z-index: 1;
  text-shadow: 0 2px 0 rgba(156, 42, 47, 0.42);
}

footer {
  display: flex;
  min-height: 42px;
  margin-top: auto;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-top: 1px solid #d9eaf1;
  color: #7893a2;
  background: var(--white);
  font-size: 10px;
}

footer svg {
  width: 13px;
  height: 13px;
  color: #39a788;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 2px solid #178fb7;
  outline-offset: 2px;
}

@media (max-width: 350px) {
  .match-stage {
    height: 387px;
    flex-basis: 387px;
  }

  .match-controls {
    padding-right: 12px;
    padding-left: 12px;
  }

  .topbar {
    min-height: 94px;
    padding-right: 10px;
    padding-left: 10px;
  }

  .kingdom-row {
    grid-template-columns: minmax(0, 1fr) 42px minmax(0, 1fr);
    gap: 5px;
  }

  .swap-button {
    width: 42px;
    height: 42px;
  }

  .input-line input {
    font-size: 22px;
  }
}

@media (min-width: 431px) {
  body {
    padding: 20px 0;
  }

  .app-shell {
    min-height: calc(100dvh - 40px);
    border: 1px solid rgba(116, 170, 192, 0.32);
    border-radius: var(--radius);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
  }
}
