@import url("https://fonts.googleapis.com/css2?family=Luckiest+Guy&family=Nunito:wght@800;900&display=swap");

:root {
  --ink: #112c34;
  --deep: #0e5163;
  --leaf: #20b56f;
  --leaf-dark: #0c704c;
  --sun: #ffd84d;
  --pink: #ff6aa8;
  --sky: #72d8ff;
  --panel: #fff3a6;
  --cream: #fff9d7;
  --shadow: rgba(8, 34, 42, 0.34);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: transparent;
}

body {
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  padding: 18px;
}

.scorebug {
  position: relative;
  width: min(520px, calc(100vw - 36px));
  min-width: 330px;
  color: var(--ink);
  filter: drop-shadow(0 12px 0 rgba(6, 29, 34, 0.2));
  transform-origin: top left;
  animation: settle-in 520ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.counter-shell {
  position: relative;
  display: grid;
  grid-template-columns: 58px minmax(92px, 0.82fr) minmax(178px, 1.4fr) 68px;
  align-items: center;
  gap: 10px;
  min-height: 96px;
  padding: 14px 18px 14px 13px;
  border: 5px solid var(--ink);
  border-radius: 8px;
  background:
    radial-gradient(circle at 12% 0%, rgba(255, 255, 255, 0.85), transparent 26%),
    linear-gradient(135deg, var(--sky) 0 27%, var(--panel) 27% 68%, #7df0a3 68% 100%);
  box-shadow:
    inset 0 -8px 0 rgba(14, 81, 99, 0.15),
    inset 0 4px 0 rgba(255, 255, 255, 0.72),
    8px 8px 0 var(--shadow);
}

.counter-shell::before,
.counter-shell::after {
  position: absolute;
  content: "";
  pointer-events: none;
}

.counter-shell::before {
  inset: 8px;
  border: 2px dashed rgba(17, 44, 52, 0.32);
  border-radius: 5px;
}

.counter-shell::after {
  right: 18px;
  bottom: -16px;
  width: 82px;
  height: 28px;
  border: 4px solid var(--ink);
  border-top: 0;
  border-radius: 0 0 8px 8px;
  background: linear-gradient(90deg, var(--leaf-dark), var(--leaf));
  transform: skewX(-18deg);
  z-index: -1;
}

.crest {
  position: relative;
  width: 54px;
  height: 60px;
  border: 4px solid var(--ink);
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 25%, var(--sun) 0 18%, transparent 19%),
    linear-gradient(145deg, var(--pink), #ff9c53 62%, var(--sun));
  box-shadow: inset 0 -5px 0 rgba(112, 22, 54, 0.18);
}

.crest::before,
.crest::after,
.crest span {
  position: absolute;
  content: "";
  background: var(--ink);
}

.crest::before {
  left: 22px;
  top: 5px;
  width: 8px;
  height: 43px;
  border-radius: 99px;
  transform: rotate(45deg);
}

.crest::after {
  left: 10px;
  top: 18px;
  width: 30px;
  height: 7px;
  border-radius: 99px;
  transform: rotate(45deg);
}

.crest span {
  left: 14px;
  bottom: 7px;
  width: 22px;
  height: 8px;
  border-radius: 99px;
  background: var(--cream);
  border: 3px solid var(--ink);
}

.nameplate {
  position: relative;
  justify-self: stretch;
  min-width: 0;
  padding: 8px 10px 5px;
  border: 4px solid var(--ink);
  border-radius: 8px;
  background: linear-gradient(180deg, var(--cream), #ffe47a);
  color: var(--deep);
  font-family: "Luckiest Guy", "Cooper Black", "Trebuchet MS", fantasy;
  font-size: clamp(21px, 5.2vw, 34px);
  line-height: 0.95;
  letter-spacing: 0;
  text-align: center;
  text-shadow: 2px 2px 0 rgba(255, 255, 255, 0.65);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.score-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(50px, 1fr));
  gap: 8px;
  min-width: 0;
}

.score {
  position: relative;
  display: grid;
  grid-template-columns: 22px minmax(28px, 1fr);
  align-items: center;
  min-width: 0;
  height: 56px;
  border: 4px solid var(--ink);
  border-radius: 8px;
  overflow: hidden;
  background: var(--cream);
  box-shadow: inset 0 -5px 0 rgba(17, 44, 52, 0.09);
}

.score-label {
  display: grid;
  place-items: center;
  height: 100%;
  color: white;
  font-family: "Nunito", "Trebuchet MS", sans-serif;
  font-size: 16px;
  font-weight: 900;
  line-height: 1;
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.25);
}

.score-value {
  min-width: 0;
  padding: 0 7px 0 5px;
  font-family: "Luckiest Guy", "Cooper Black", "Trebuchet MS", fantasy;
  font-size: clamp(26px, 6vw, 38px);
  line-height: 1;
  letter-spacing: 0;
  text-align: center;
  color: var(--ink);
  white-space: nowrap;
}

.score-value.bump {
  animation: pop 360ms cubic-bezier(0.2, 0.9, 0.3, 1.25);
}

.score-win .score-label {
  background: var(--leaf-dark);
}

.score-loss .score-label {
  background: #e9405f;
}

.score-draw .score-label {
  background: var(--deep);
}

.total-rune {
  display: grid;
  place-items: center;
  min-width: 0;
  height: 58px;
  border: 4px solid var(--ink);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 24%, white, var(--sun) 42%, #ff9c53 100%);
  font-family: "Nunito", "Trebuchet MS", sans-serif;
  font-weight: 900;
  line-height: 1;
  box-shadow: inset 0 -6px 0 rgba(100, 57, 12, 0.16);
}

.total-label {
  font-size: 10px;
  text-transform: uppercase;
  color: var(--deep);
}

#total {
  max-width: 50px;
  overflow: hidden;
  font-family: "Luckiest Guy", "Cooper Black", "Trebuchet MS", fantasy;
  font-size: 24px;
  color: var(--ink);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.connection-dot {
  position: absolute;
  top: 9px;
  right: 10px;
  width: 12px;
  height: 12px;
  border: 3px solid var(--ink);
  border-radius: 50%;
  background: #ffcf4b;
}

.connection-dot[data-status="live"] {
  background: #45f27b;
}

.connection-dot[data-status="offline"] {
  background: #ff4d6d;
}

.spark {
  position: absolute;
  width: 26px;
  height: 26px;
  border: 4px solid var(--ink);
  background: var(--sun);
  transform: rotate(45deg);
  z-index: 2;
}

.spark-one {
  left: 40px;
  top: -11px;
}

.spark-two {
  right: 116px;
  bottom: -10px;
  width: 18px;
  height: 18px;
  background: var(--pink);
}

@keyframes settle-in {
  from {
    opacity: 0;
    transform: translateY(-10px) scale(0.96);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes pop {
  0% {
    transform: scale(1);
  }

  45% {
    transform: scale(1.22) rotate(-2deg);
  }

  100% {
    transform: scale(1);
  }
}

@media (max-width: 430px) {
  body {
    padding: 10px;
  }

  .scorebug {
    width: calc(100vw - 20px);
    min-width: 0;
  }

  .counter-shell {
    grid-template-columns: 48px minmax(72px, 0.7fr) minmax(150px, 1.6fr);
    gap: 7px;
    min-height: 86px;
    padding: 12px;
  }

  .total-rune {
    position: absolute;
    right: -4px;
    bottom: -20px;
    width: 56px;
    height: 56px;
  }

  .crest {
    width: 46px;
    height: 52px;
  }

  .score {
    grid-template-columns: 18px minmax(22px, 1fr);
    height: 50px;
  }

  .score-label {
    font-size: 13px;
  }
}
