* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #f8f4f2;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

#frame {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  background: #f8f4f2;
  overflow: hidden;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

#ui {
  position: fixed;
  inset: 0;
  z-index: 8;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) 14px 16px;
  touch-action: auto;
}

#ui[hidden] {
  display: none !important;
}

#ui-back {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(22, 10, 8, 0.55);
  cursor: pointer;
}

#sheet {
  position: relative;
  z-index: 1;
  width: min(440px, 100%);
  max-height: min(86dvh, 760px);
  overflow: auto;
  margin-top: 4vh;
  padding: 22px 18px 18px;
  background: #fffdf8;
  color: #1a1a1a;
  border: 5px solid #161616;
  border-radius: 26px;
  box-shadow: 0 10px 0 rgba(22, 10, 8, 0.18);
  font-family: Nunito, sans-serif;
}

#sheet-title {
  font-family: Russo, Nunito, sans-serif;
  font-weight: 400;
  font-size: 34px;
  line-height: 1;
  text-align: center;
  color: #e22622;
  letter-spacing: 0.02em;
}

#sheet-time,
#sheet-note {
  margin-top: 10px;
  text-align: center;
  font-weight: 800;
  font-size: 18px;
}

#sheet-note {
  color: #1f4f9a;
}

#name-form {
  margin-top: 14px;
}

#name-form label {
  display: block;
  font-weight: 800;
  font-size: 14px;
  margin-bottom: 6px;
}

.name-row {
  display: flex;
  gap: 8px;
}

#nick {
  flex: 1;
  min-width: 0;
  height: 52px;
  border: 4px solid #161616;
  border-radius: 14px;
  padding: 0 12px;
  font: 800 18px Nunito, sans-serif;
  color: #1a1a1a;
  background: #fff;
  user-select: text;
  -webkit-user-select: text;
}

#nick:focus {
  outline: 3px solid #e22622;
  outline-offset: 1px;
}

#save-name,
#sheet-close {
  border: 4px solid #161616;
  border-radius: 14px;
  font-family: Nunito, sans-serif;
  font-weight: 800;
  cursor: pointer;
}

#save-name {
  height: 52px;
  padding: 0 14px;
  background: #e22622;
  color: #fff;
  font-size: 18px;
}

#sheet-list {
  list-style: none;
  margin: 14px 0 12px;
  max-height: 42dvh;
  overflow: auto;
}

#sheet-list li {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 8px 4px;
  border-bottom: 2px solid #efe6df;
  font-weight: 800;
  font-size: 18px;
}

#sheet-list li.me {
  background: #fff3e4;
  border-radius: 12px;
  border-bottom-color: transparent;
}

#sheet-me {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 9px 4px;
  border-top: 3px solid #161616;
  font-weight: 800;
  font-size: 18px;
  background: #fff3e4;
  border-radius: 0 0 12px 12px;
}

#sheet-me .rank {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #e22622;
  color: #fff;
  font-size: 15px;
  overflow: hidden;
}

#sheet-me .who {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #161616;
  color: #fff;
  font-size: 16px;
}

.rank.r1 { background: #e0a020; color: #161616; }
.rank.r2 { background: #8aa0b8; }
.rank.r3 { background: #c46a3a; }

.who {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.when {
  font-variant-numeric: tabular-nums;
}

#sheet-empty {
  margin: 16px 0;
  text-align: center;
  font-weight: 800;
  font-size: 16px;
}

#sheet-empty[hidden],
#sheet-time[hidden],
#sheet-note[hidden],
#name-form[hidden] {
  display: none !important;
}

#sheet-close {
  display: block;
  width: 100%;
  height: 52px;
  background: #1f4f9a;
  color: #fff;
  font-size: 20px;
}

@font-face {
  font-family: "Nunito";
  src: url("assets/Nunito-800.ttf") format("truetype");
  font-weight: 100 900;
  font-display: swap;
}

@font-face {
  font-family: "Balsamiq";
  src: url("assets/BalsamiqSans-Bold.ttf") format("truetype");
  font-weight: 100 900;
  font-display: swap;
}

@font-face {
  font-family: "Russo";
  src: url("assets/RussoOne-Regular.ttf") format("truetype");
  font-weight: 100 900;
  font-display: swap;
}
