@font-face {
  font-family: "Monocraft";
  src: url("/monocraft-bold.ttf") format("truetype");
  font-style: normal;
  font-weight: 700;
  font-display: swap;
}

:root {
  --selected: #ffd700;
  --bright-selected: #ffd700;
  --soul: #ffffff;
  --soul-bright: #ffffff;
  --soul-muted: rgba(255, 255, 255, 0.65);
  --void: #000000;
  --danger: #ff6a6a;
}

* {
  box-sizing: border-box;
}

html,
body,
main {
  min-height: 100%;
}

body {
  position: relative;
  margin: 0;
  overflow-x: hidden;
  background-color: #000;
  background-image: url("/webbackground-v2-poster.png");
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  background-attachment: fixed;
  color: #fff;
  font-family: "Monocraft", Arial, Helvetica, sans-serif;
  font-synthesis: none;
  font-weight: 700;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.82);
}

.background-video,
.background-shade {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.background-video {
  z-index: 0;
  object-fit: cover;
  object-position: center;
}

.background-shade {
  z-index: 1;
  background: rgba(0, 0, 0, 0.26);
}

main {
  position: relative;
  z-index: 2;
}

button,
input,
canvas {
  font: inherit;
}

.access-view {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  min-height: 100vh;
  place-items: center;
  background: #000;
  padding: 32px;
}

#access-form {
  width: min(520px, 86vw);
}

#access-code {
  width: 100%;
  border: 0;
  border-radius: 0;
  outline: 0;
  background: transparent;
  padding: 12px 8px;
  color: #fff;
  caret-color: #fff;
  font-family: "Monocraft", Arial, Helvetica, sans-serif;
  font-size: clamp(16px, 3vw, 22px);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-align: center;
  text-shadow: none;
  transition: opacity 140ms ease;
}

#access-code:disabled {
  opacity: 0.45;
}

.access-view.error #access-code {
  animation: shake 260ms ease;
}

body.access-granted .access-view {
  display: none;
}

body.access-locked .background-video,
body.access-locked .background-shade,
body.access-locked main {
  visibility: hidden;
}

[hidden] {
  display: none !important;
}

.username-view,
.verify-view,
.editor-view {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 32px;
}

.verify-player {
  position: relative;
  display: grid;
  place-items: center;
}

#confirm-player {
  position: relative;
  display: grid;
  width: 152px;
  height: 152px;
  place-items: center;
  border: 4px solid #fff;
  border-radius: 0;
  background: rgba(0, 0, 0, 0.32);
  padding: 8px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.46);
  cursor: pointer;
  transition: background 140ms ease, box-shadow 140ms ease, transform 100ms ease;
}

#player-head {
  display: block;
  width: 128px;
  height: 128px;
  image-rendering: pixelated;
}

.confirm-mark {
  position: absolute;
  right: -14px;
  bottom: -14px;
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 3px solid #000;
  background: #fff;
  color: #000;
  font-size: 22px;
  line-height: 1;
  text-shadow: none;
}

#confirm-player:hover,
#confirm-player:focus-visible {
  background: rgba(255, 255, 255, 0.12);
  outline: 3px solid #fff;
  outline-offset: 7px;
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.56);
}

#confirm-player:active {
  transform: scale(0.97);
}

#change-player {
  position: absolute;
  top: -44px;
  right: -44px;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.72);
  font-size: 28px;
  line-height: 1;
  font-weight: 700;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.88);
  cursor: pointer;
}

#change-player:hover,
#change-player:focus-visible {
  color: #fff;
  outline: 2px solid #fff;
  outline-offset: 2px;
}

#username-form {
  width: min(520px, 86vw);
}

#username {
  width: 100%;
  border: 0;
  border-bottom: 3px solid rgba(255, 255, 255, 0.72);
  border-radius: 0;
  outline: 0;
  background: rgba(0, 0, 0, 0.12);
  padding: 18px 10px;
  color: #fff;
  caret-color: #fff;
  font-size: clamp(22px, 4vw, 32px);
  font-weight: 700;
  letter-spacing: 0.015em;
  text-align: center;
  text-shadow: 0 3px 18px rgba(0, 0, 0, 0.92);
  transition: border-color 140ms ease, background 140ms ease, opacity 140ms ease;
}

#username::placeholder {
  color: rgba(255, 255, 255, 0.74);
  opacity: 1;
}

#username:focus {
  border-color: #fff;
  background: rgba(0, 0, 0, 0.26);
}

#username:disabled {
  opacity: 0.4;
}

.username-view.error #username {
  border-color: var(--danger);
  animation: shake 260ms ease;
}

.editor {
  display: grid;
  grid-template-columns: minmax(240px, 330px) minmax(260px, 360px);
  grid-template-rows: auto 58px;
  align-items: center;
  gap: 34px 72px;
}

.item-preview {
  position: relative;
  display: grid;
  width: 100%;
  aspect-ratio: 1;
  place-items: center;
}

#source-gif {
  position: fixed;
  left: -10000px;
  width: 512px;
  height: 512px;
  opacity: 0.001;
  pointer-events: none;
}

#item-canvas {
  display: block;
  width: 100%;
  height: auto;
  image-rendering: pixelated;
  filter: drop-shadow(0 16px 30px rgba(0, 0, 0, 0.46));
}

.picker {
  display: grid;
  width: 100%;
  gap: 22px;
}

.wheel-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
}

#color-wheel {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  outline: none;
  cursor: crosshair;
  touch-action: none;
  filter: drop-shadow(0 14px 30px rgba(0, 0, 0, 0.42));
}

#color-wheel:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 6px;
}

#wheel-pointer {
  position: absolute;
  width: 19px;
  height: 19px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--selected);
  box-shadow: 0 0 0 2px #000, 0 4px 12px rgba(0, 0, 0, 0.48);
  pointer-events: none;
  transform: translate(-50%, -50%);
}

#brightness {
  width: 100%;
  height: 2px;
  margin: 0;
  appearance: none;
  border-radius: 0;
  outline: 0;
  background: linear-gradient(90deg, #000, var(--bright-selected));
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.58), 0 4px 12px rgba(0, 0, 0, 0.5);
  cursor: pointer;
}

#brightness::-webkit-slider-thumb {
  width: 17px;
  height: 17px;
  appearance: none;
  border: 2px solid var(--void);
  border-radius: 0;
  background: #fff;
  box-shadow: 0 0 0 1px #fff, 0 4px 10px rgba(0, 0, 0, 0.52);
}

#brightness::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border: 2px solid var(--void);
  border-radius: 0;
  background: #fff;
  box-shadow: 0 0 0 1px #fff, 0 4px 10px rgba(0, 0, 0, 0.52);
}

#brightness:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 8px;
}

#save {
  grid-column: 2;
  width: 100%;
  height: 58px;
  border: 3px solid #fff;
  border-radius: 0;
  background: rgba(0, 0, 0, 0.28);
  color: #fff;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.3);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-shadow: 0 3px 16px rgba(0, 0, 0, 0.9);
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease, transform 100ms ease;
}

#save:hover,
#save:focus-visible {
  background: #fff;
  color: #000;
  text-shadow: none;
  outline: 3px solid #fff;
  outline-offset: 4px;
}

#save:active {
  transform: scale(0.985);
}

#save:disabled {
  cursor: wait;
  opacity: 0.45;
}

#save.saved {
  border-color: #fff;
  background: #fff;
  color: #000;
  text-shadow: none;
}

#save.error {
  border-color: var(--danger);
  background: #541b1b;
  color: #fff1f1;
  animation: shake 260ms ease;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  clip-path: inset(50%);
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

@media (max-width: 780px) {
  .editor-view {
    padding: 24px 24px 36px;
  }

  .editor {
    width: min(360px, 86vw);
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 58px;
    gap: 20px;
  }

  .item-preview {
    width: 64%;
    margin: 0 auto -8px;
  }

  #save {
    grid-column: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .background-video {
    display: none;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
