:root {
  --darkgreen: rgb(6, 34, 6);
  --green: rgb(5, 63, 5);
  --lightgreen: rgb(10, 104, 10);
  --yellowwhite: rgb(255, 249, 165);
  --brown: rgb(52, 32, 22);
  --darkbrown: rgb(24, 14, 10);
  --purp: rgb(175, 106, 255);
  --darkpurp: rgb(108, 48, 190);
  --orange: rgb(194, 126, 0);
  --lit: rgb(174, 32, 0);
}

* {
  margin: 0;
}

body {
  font-family: "Nanum Pen Script", cursive;
  background: linear-gradient(to bottom, var(--darkgreen) 0%, var(--green) 50%);
  background-attachment: fixed;
  -ms-overflow-style: none;
  scrollbar-width: none;
}

body::-webkit-scrollbar {
  display: none;
}

#fade {
  position: fixed;
  z-index: -1;
  width: 100%;
  height: 100%;
  bottom: 0;
  background-image: linear-gradient(to bottom, transparent 60%, var(--darkgreen) 90%);
}

nav {
  background-image: url("../images/papers.png");
  box-shadow: 0 0 20px black;
  font-weight: bolder;
  position: fixed;
  width: 100%;
  height: 70px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 2;
  font-size: 2em;
}

nav p {
  color: var(--brown);
  margin-left: 30px;
  margin-right: 10px;
  user-select: none;
}

#suffix {
  font-size: 70%;
}

#toke-up-with-me {
  font-family: "Nanum Pen Script", cursive;
  font-size: xx-large;
  font-weight: bold;
  margin-right: 30px;
  margin-left: 10px;
  color: var(--lightgreen);
  text-decoration: none;
  transition:
    text-shadow 1s,
    color 1s;
  text-shadow: 0 0 4px rgba(0, 0, 0, 0.5);
  padding: 0 12px;
  background: rgba(0, 0, 0, 0.69);
  backdrop-filter: blur(1px);
  border: 4px solid var(--darkbrown);
  border-radius: 999px;
  box-shadow: 0 0 5px var(--darkbrown);
  white-space: nowrap;
}

#toke-up-with-me:hover {
  color: var(--lit);
  cursor: pointer;
  text-shadow: 0 0 20px whitesmoke;
}

#sometimes {
  position: fixed;
  margin-top: 25vh;
  width: 100%;
  text-shadow: -2px 3px 5px black;
  font-size: 2.4em;
  text-align: center;
  user-select: none;
  opacity: 0;
  animation: fadein 1.5s 2;
  animation-direction: alternate;
}

#sometimes p {
  max-width: 75vw;
  margin: auto;
}

main {
  padding: 120px 0 80px;
  display: flex;
  flex-direction: column;
  /* justify-content: space-between; TODO: better vertical spacing*/
  color: var(--yellowwhite);
}

section {
  display: flex;
  flex-direction: column;
  color: var(--yellowwhite);
  opacity: 0;
  animation: fadein 2s;
  animation-delay: 3s;
  animation-fill-mode: forwards;
}

main h1 {
  text-shadow: -3px 5px 7px black;
  font-size: 3.8em;
  text-align: center;
}

#keef {
  width: 14em;
  height: 14em;
  margin: auto;
  display: block;
  border-radius: 50%;
  transform: rotate(-12deg);
  animation: shake 2s infinite linear;
  padding: 10px 0 20px;
}

#counter-container,
#t-break-container {
  margin: 0 auto;
  text-align: center;
}

#counter-container p,
#t-break-container p {
  text-shadow: -2px 3px 5px black;
  font-size: 2.4em;
  text-align: center;
  padding: 10px;
  margin-bottom: 20px;
}

.link-btn {
  display: block;
  margin: auto;
  text-align: center;
  font-size: 2em;
  text-decoration: none;
  text-shadow: -1px 2px 3px rgba(0, 0, 0, 0.8);
  color: var(--purp);
  pointer-events: all;
  user-select: none;
  cursor: pointer;
}

.link-btn:hover {
  color: var(--orange);
}

.content {
  margin-top: 3vh;
  opacity: 0;
  animation: fadein 2s;
  animation-delay: 4.5s;
  animation-fill-mode: forwards;
  padding: 5px 10%;
  max-width: 1500px;
  margin: 20px auto;
}

.content h1 {
  text-shadow: -2px 3px 5px black;
  font-size: 2.5em;
  font-weight: normal;
}

.content p {
  font-size: 24px;
  text-shadow: -2px 3px 5px black;
  text-align: center;
  padding: 5px 0;
}

.content table {
  max-width: 1200px;
}

.content td {
  font-size: 24px;
  padding: 5px;
  text-shadow: -2px 3px 5px black;
  text-align: left;
  max-width: 400px;

  &.command-cell {
    text-align: right;
    vertical-align: middle;
    white-space: nowrap;
    padding-right: 14px;
  }
}

.command {
  display: inline-block;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(0, 0, 0, 0.5);
  border-radius: 8px;
  padding: 0 0.5em;
  line-height: 1.35;
}

.content ul {
  margin: auto;
  font-size: 24px;
  max-width: 800px;
  text-shadow: -2px 3px 5px black;
}

.content li {
  padding: 5px 0;
}

#modal {
  display: none;
  position: fixed;
  z-index: 2;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  justify-content: center;
  align-items: center;
  user-select: none;
  touch-action: none;
}

#leaderboards {
  --col-rank: 3.2rem;
  --col-bowls: 4.6rem;
  display: none;
  flex-direction: column;
  width: 85%;
  height: 70%;
  max-width: 520px;
  padding: 8vw;
  position: relative;
  opacity: 0;
  transition:
    width 0.5s ease,
    max-width 0.5s ease,
    opacity 0.2s ease;
}

#leaderboards.shown,
#disclaimer.shown {
  opacity: 1;
}

#leaderboards.shown {
  transition-duration: 0.5s, 0.5s, 0.45s;
}

#disclaimer.shown {
  transition-duration: 0.45s;
}

#modal.closing {
  pointer-events: none;
}

main {
  transition:
    opacity 0.4s ease 0.1s,
    visibility 0s linear 0.1s;
}

body.modal-open main {
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.4s ease,
    visibility 0s linear 0.4s;
}

#leaderboards::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0 -5%;
  background-image: url("../images/smoke.png");
  background-size: 100% 100%;
  background-repeat: no-repeat;
  pointer-events: none;
}

.smoke-gl #leaderboards::before,
.smoke-gl #disclaimer {
  background-image: none;
}

canvas.smoke {
  display: none;
  position: absolute;
  z-index: -1;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.smoke-gl canvas.smoke {
  display: block;
}

#leaderboards.charting {
  width: 92%;
  max-width: 860px;
}

#leaderboards.down {
  justify-content: center;
}

#leaderboards.down #lb-title,
#leaderboards.down #boards,
#leaderboards.down #chart,
#leaderboards.down #chart-legend,
#leaderboards.down #legend-tip,
#leaderboards.down #btn-chart {
  display: none;
}

#boards {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

#chart,
#chart-legend {
  display: none;
  flex: none;
  align-self: center;
  width: min(860px, 84vw);
}

#chart-legend {
  --fade: 40px;
  -webkit-mask-image: linear-gradient(
    to right,
    transparent,
    #000 var(--fade),
    #000 calc(100% - var(--fade)),
    transparent
  );
  mask-image: linear-gradient(to right, transparent, #000 var(--fade), #000 calc(100% - var(--fade)), transparent);
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: calc(100% + 2 * var(--fade)) 100%;
  mask-size: calc(100% + 2 * var(--fade)) 100%;
}

#chart {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
}

#chart-box {
  position: absolute;
  inset: 6px 3%;
  overflow: hidden;
}

@keyframes reveal {
  from {
    -webkit-mask-size: min(520px, 84vw) 100%;
    mask-size: min(520px, 84vw) 100%;
  }
  to {
    -webkit-mask-size: calc(100% + 2 * var(--fade)) 100%;
    mask-size: calc(100% + 2 * var(--fade)) 100%;
  }
}

#leaderboards.charting #boards {
  display: none;
}

#leaderboards.charting #chart {
  display: block;
  animation: stretch 0.5s ease both;
}

#leaderboards.charting #chart-legend {
  display: block;
  animation: reveal 0.5s ease both;
}

@keyframes stretch {
  from {
    transform: scaleX(var(--from-scale, 1));
  }
  to {
    transform: scaleX(1);
  }
}

#legend-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0 0.9em;
  max-height: 7em;
  overflow-y: auto;
  scrollbar-width: none;
  padding: 0 3%;
  font-size: large;
  line-height: 1.4;
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 1em), transparent);
  mask-image: linear-gradient(to bottom, #000 calc(100% - 1em), transparent);
}

#legend-list::-webkit-scrollbar {
  display: none;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

.legend-item:hover {
  color: var(--orange);
}

.legend-item.off {
  opacity: 0.45;
  text-decoration: line-through;
}

.swatch {
  display: inline-block;
  width: 1em;
  border-top: 3px solid;
}

#chart canvas {
  cursor: crosshair;
  touch-action: none;
}

#zoom-reset {
  position: absolute;
  top: 0;
  right: 3%;
  font-size: large;
  line-height: 1;
  color: var(--darkpurp);
  cursor: pointer;
  user-select: none;
}

#zoom-reset[hidden] {
  display: none;
}

#zoom-reset:hover {
  color: var(--orange);
}

.tip {
  position: absolute;
  z-index: 1;
  transform: translate(-50%, calc(-100% - 12px));
  pointer-events: none;
  background: rgba(0, 0, 0, 0.8);
  color: white;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: large;
  line-height: 1.15;
  white-space: nowrap;
}

.tip[hidden] {
  display: none;
}

#legend-tip {
  transform: translate(-50%, calc(-100% - 6px));
  max-width: 22em;
  white-space: normal;
  text-align: center;
}

.tip-title {
  font-weight: bold;
}

.tip-row {
  display: flex;
  justify-content: space-between;
  gap: 1.5em;
}

#btn-chart {
  flex: none;
  font-size: x-large;
  line-height: 1;
  margin-top: 0.5em;
  color: var(--darkpurp);
  text-shadow: none;
}

#btn-chart:hover {
  color: var(--orange);
}

#leaderboards.down .error {
  display: block;
}

#lb-title {
  flex: none;
  text-align: center;
  font-size: 2.4em;
  font-weight: normal;
  line-height: 1;
  margin: 0.1em 0 0.35em;
}

#tabs {
  flex: none;
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: x-large;
  padding: 0 0.15em 0.25em;
  margin: 0 0.25em 0.5em;
}

#tabs a {
  padding: 0.1em 0.3em;
  line-height: 1;
  user-select: none;
  cursor: pointer;
}

#tabs a:hover {
  color: var(--orange);
}

#tab-indicator {
  position: absolute;
  left: 0;
  bottom: 0.18em;
  height: 2px;
  width: 0;
  background: currentColor;
  pointer-events: none;
}

#tables {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

#tables.dragging {
  scroll-snap-type: none;
}

#tables::-webkit-scrollbar {
  display: none;
}

.panel {
  flex: 0 0 100%;
  width: 100%;
  min-width: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding: 6px 0 28px;
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 12px, #000 calc(100% - 28px), transparent);
  mask-image: linear-gradient(to bottom, transparent, #000 12px, #000 calc(100% - 28px), transparent);
}

.panel::-webkit-scrollbar {
  display: none;
}

.row {
  display: grid;
  grid-template-columns: var(--col-rank) minmax(0, 1fr) var(--col-bowls);
  align-items: center;
  column-gap: 0.4em;
  padding: 0.15em 0.5em;
  min-height: 1.35em;
  font-size: x-large;
  line-height: 1.1;
  border-bottom: 1px solid rgba(65, 42, 26, 0.3);
}

.board .row:last-child {
  border-bottom: none;
}

.row.head {
  flex: none;
  min-height: 0;
  padding-bottom: 0.1em;
  font-weight: bold;
  border-bottom: none;
}

.row .rank {
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.row .name {
  overflow: hidden;
  white-space: nowrap;
  text-align: left;
}

.name-inner {
  display: block;
  width: max-content;
}

.name.scrolls .name-inner {
  animation: marquee 6s ease-in-out infinite alternate;
}

.row .bowls {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.medal {
  box-sizing: border-box;
  justify-self: center;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.7em;
  line-height: 1;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  border: 0.1em solid;
  color: rgb(48, 30, 10);
  box-shadow:
    inset 0 0.14em 0.16em rgba(255, 255, 255, 0.6),
    inset 0 -0.14em 0.18em rgba(0, 0, 0, 0.28),
    0 0.08em 0.22em rgba(0, 0, 0, 0.35);
}

.row.top-1,
.row.top-2,
.row.top-3 {
  background: linear-gradient(
    90deg,
    rgba(var(--glow), 0) 8%,
    rgba(var(--glow), var(--glow-alpha)) 20%,
    rgba(var(--glow), var(--glow-alpha)) 80%,
    rgba(var(--glow), 0) 92%
  );
}

.row.top-1 {
  --glow: 255, 200, 0;
  --glow-alpha: 0.3;

  .medal {
    background: radial-gradient(circle at 34% 28%, #fff6cc 0%, #f5d25f 45%, #cf9a10 100%);
    border-color: #a87c08;
  }
}

.row.top-2 {
  --glow: 120, 130, 145;
  --glow-alpha: 0.24;

  .medal {
    background: radial-gradient(circle at 34% 28%, #ffffff 0%, #dfe3e8 45%, #9aa4ae 100%);
    border-color: #7d8791;
  }
}

.row.top-3 {
  --glow: 205, 127, 50;
  --glow-alpha: 0.24;

  .medal {
    background: radial-gradient(circle at 34% 28%, #f6d3ad 0%, #dda06a 45%, #b06a24 100%);
    border-color: #8d5218;
  }
}

.empty {
  text-align: center;
  font-size: x-large;
  opacity: 0.7;
  padding: 2em 0;
}

.error {
  display: none;
  font-size: xx-large;
  margin: auto;
  text-align: center;
  width: 75%;
}

#lb-title {
  position: relative;
}

#info {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: 1.4em;
  width: 1.2em;
  height: 1.2em;
  margin-left: -0.1em;
  font-size: 0.3em;
  font-weight: bold;
  line-height: 1;
  border: 2.5px solid currentColor;
  border-radius: 50%;
  color: inherit;
  user-select: none;
}

#info-glyph {
  font-size: 1.5em;
}

#info:hover,
#info:focus-visible {
  color: var(--orange);
  outline: none;
}

#info-tip {
  display: none;
  position: absolute;
  z-index: 3;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: min(80vw, 16em);
  padding: 0.4em 0.8em;
  font-size: 1.8em;
  font-weight: normal;
  line-height: 1.15;
  text-align: center;
  white-space: normal;
  color: white;
  background: rgba(0, 0, 0, 0.85);
  border-radius: 8px;

  .command {
    font-size: 0.9em;
    background: rgba(255, 255, 255, 0.18);
    border-color: rgba(255, 255, 255, 0.3);
  }
}

#info:hover #info-tip,
#info:focus #info-tip,
#info.open #info-tip {
  display: block;
}

.close {
  flex: none;
  width: 60px;
  font-size: x-large;
  text-align: center;
  user-select: none;
  cursor: pointer;
  margin: 0 auto 10px;
  padding: 8px 5px 6px;
}

.close:hover {
  color: var(--orange);
}

#disclaimer {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  line-height: normal;
  width: 85%;
  height: 65%;
  max-width: 500px;
  padding: 8vw;
  opacity: 0;
  transition: opacity 0.2s ease;
  background-image: url("../images/smoke.png");
  background-size: 100% 100%;
  background-repeat: no-repeat;
  text-align: center;
}

#disclaimer > div {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -ms-overflow-style: none;
  scrollbar-width: none;
  padding: 12px 0 28px;
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 12px, #000 calc(100% - 28px), transparent);
  mask-image: linear-gradient(to bottom, transparent, #000 12px, #000 calc(100% - 28px), transparent);
}

#disclaimer > div::-webkit-scrollbar {
  display: none;
}

#disclaimer p {
  line-height: 1;
  padding: 5px 0;
  width: 90%;
  margin: 0 auto;
  font-size: 1em;
}

#disclaimer ul {
  text-align: left;
  width: 90%;
  margin: 0 auto;
  font-size: 1em;
}

#agree-btn {
  display: block;
  width: fit-content;
  font-family: "Nanum Pen Script", cursive;
  font-size: larger;
  font-weight: bold;
  padding: 2px 10px;
  color: var(--darkbrown);
  background-color: lightgray;
  border: solid var(--darkbrown) 2px;
  border-radius: 5px;
  cursor: pointer;
  text-decoration: none;
  margin: 0 auto;
  flex: none;
  transition: opacity 0.3s ease;
}

#agree-btn:hover {
  background-color: white;
}

#agree-btn.disabled {
  opacity: 0.45;
  pointer-events: none;
}

.online {
  display: none;
}

.offline {
  display: block;
}

@keyframes shake {
  50% {
    transform: rotate(18deg);
  }
}

@keyframes marquee {
  0%,
  20% {
    transform: translateX(0);
  }
  80%,
  100% {
    transform: translateX(calc(-1 * var(--overflow, 0px)));
  }
}

@keyframes fadein {
  100% {
    opacity: 1;
  }
}

@media screen and (max-width: 1200px) {
  #disclaimer h2 {
    margin-top: 20px;
  }

  #disclaimer p {
    width: 80%;
  }

  #disclaimer ul {
    width: 80%;
  }

  #agree-btn {
    margin: 0 auto 20px;
  }
}

/* 86% + 5vw + 5vw is 96vw: the panel is content-box, and wider than that clips
   the smoke's soft edges off a phone screen. smoke.png, the no-WebGL fallback,
   is opaque only from 10.4% to 91.4% of its width, so that path stays inset. */
@media screen and (max-width: 620px) {
  #leaderboards,
  #leaderboards.charting {
    width: 86%;
    padding: 12vw 5vw 9vw;
  }

  html:not(.smoke-gl) #leaderboards,
  html:not(.smoke-gl) #leaderboards.charting {
    width: 76%;
    padding-inline: 10vw;
  }

  #leaderboards::before {
    inset: 0 -2%;
  }

  #chart,
  #chart-legend {
    width: 100%;
    -webkit-mask-image: none;
    mask-image: none;
    animation: none;
  }

  #chart-box {
    inset: 6px 0;
  }

  #legend-list {
    padding: 0;
  }
}

@media screen and (max-width: 480px) {
  body {
    font-size: 80%;
  }

  nav {
    font-size: 22px;
  }

  #toke-up-with-me {
    font-size: 22px;
  }

  .content p,
  .content td,
  .content ul {
    font-size: 20px;
  }

  #leaderboards {
    --col-rank: 2.3rem;
    --col-bowls: 3.4rem;
    height: 72%;
  }

  #leaderboards,
  #leaderboards.charting {
    padding-top: 20vw;
  }

  #lb-title {
    font-size: 2em;
  }

  #tabs {
    font-size: 20px;
  }

  .row,
  .empty {
    font-size: large;
  }

  .row {
    padding-left: 0.15em;
    padding-right: 0.15em;
  }

  .error {
    font-size: x-large;
    width: 95%;
  }

  .close {
    font-size: x-large;
  }

  #disclaimer h2 {
    margin-top: 50px;
  }

  #disclaimer p {
    width: 75%;
  }

  #disclaimer ul {
    width: 75%;
  }

  #agree-btn {
    margin: 0 auto 50px;
  }
}

@media screen and (min-width: 1200px) and (min-height: 1200px) {
  #disclaimer {
    font-size: 120%;
  }
}
