:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  background: #000;
  color: #f4f4f0;
}
* {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
body {
  margin: 0;
  background: #000;
  overflow: hidden;
}
header {
  min-height: 170px;
  position: fixed;
  z-index: 20;
  inset: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 13px 22px;
  border-bottom: 1px solid #242424;
  background: #080808ed;
  backdrop-filter: blur(14px);
}
h1,
h2,
p {
  margin: 0;
}
.brand {
  max-width: 1100px;
}
.brand h1 {
  position: relative;
  display: inline-block;
  font-size: clamp(34px, 3.15vw, 58px);
  font-weight: 900;
  line-height: 1.02;
  letter-spacing: -0.035em;
  background: linear-gradient(110deg, #4ef4e3 4%, #ff45b5 50%, #478dff 96%);
  color: transparent;
  background-clip: text;
  -webkit-background-clip: text;
  filter: drop-shadow(0 0 15px #517dff35);
}
.brand h1::after {
  content: attr(data-title);
  position: absolute;
  inset: 0;
  color: transparent;
  background: linear-gradient(
    135deg,
    transparent 34%,
    #ffffff28 42%,
    #fff 48%,
    #ffffff75 52%,
    transparent 61%
  );
  background-size: 280% 280%;
  background-position: 125% 125%;
  background-clip: text;
  -webkit-background-clip: text;
  pointer-events: none;
  animation: titleShimmer 3.8s ease-in-out infinite;
}
@keyframes titleShimmer {
  0%,
  25% {
    background-position: 125% 125%;
  }
  72%,
  100% {
    background-position: -35% -35%;
  }
}
.brand p {
  color: #b5b5b2;
  font-size: 13px;
  line-height: 1.4;
  margin-top: 5px;
}
.wallMeta {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
.wallMeta > div {
  min-width: 170px;
  padding: 8px 12px;
  border: 1px solid #8f692d;
  border-radius: 8px;
  background:
    repeating-linear-gradient(135deg, transparent 0 9px, #d6a6470c 10px 11px),
    linear-gradient(145deg, #1a140b, #0a0907);
  box-shadow: inset 0 0 10px #d3a1440e;
}
.wallMeta span,
.wallMeta strong {
  display: block;
}
.wallMeta .countdownCard {
  min-width: 285px;
  border-color: #f0c56d;
  background:
    radial-gradient(circle at 50% 0, #ffd77d25, transparent 62%),
    repeating-linear-gradient(135deg, transparent 0 9px, #f2c15d12 10px 11px),
    linear-gradient(145deg, #2b1c08, #0d0a06);
  box-shadow:
    inset 0 0 18px #f5bf481a,
    0 0 0 2px #4d3516,
    0 0 20px #e3a43b35;
}
.countdownCard #countdown {
  color: #fff1c4;
  font-size: 23px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.075em;
  text-shadow: 0 0 12px #ffc04f66;
}
.countdownCard small {
  display: block;
  margin-top: 3px;
  color: #9d865c;
  font-size: 7px;
  font-weight: 800;
  letter-spacing: 0.12em;
  white-space: nowrap;
}
.wallMeta span {
  color: #a99670;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}
.wallMeta strong {
  margin-top: 3px;
  color: #ffe0a0;
  font-size: 14px;
  white-space: nowrap;
}
.modalHead p,
.hint {
  color: #8d8d88;
  font-size: 12px;
  margin-top: 4px;
}
button,
input {
  font: inherit;
}
button {
  border: 1px solid #343434;
  background: #151515;
  color: #eee;
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
  touch-action: manipulation;
}
button:disabled {
  cursor: wait;
  opacity: 0.65;
}
button:hover,
.active {
  border-color: #ff5c16;
  color: #fff;
}
#add,
.primary {
  position: relative;
  overflow: hidden;
  border: 1px solid #f0c56d;
  background-color: #9d3f08;
  background-image:
    radial-gradient(circle at 20% 25%, #ffd47a38 0 2px, transparent 3px),
    repeating-linear-gradient(135deg, transparent 0 8px, #ffd17612 9px 10px),
    linear-gradient(145deg, #c76413, #7c2906 58%, #b9500d);
  color: #fff;
  font-weight: 700;
  white-space: nowrap;
  text-shadow: 0 1px 3px #401400;
  box-shadow:
    inset 0 1px 0 #ffe2a36b,
    inset 0 -2px 5px #4b160088,
    0 0 0 2px #4d3516,
    0 5px 18px #0008;
}
#add:hover,
.primary:hover {
  border-color: #ffe2a0;
  background-position: 8px 5px, 5px 5px, 0 0;
  filter: brightness(1.13);
  box-shadow:
    inset 0 1px 0 #fff0bd99,
    inset 0 -2px 5px #4b160066,
    0 0 0 2px #8d682b,
    0 0 18px #e3a43b55;
  transform: translateY(-1px);
}
.headerActions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.headerActions #userStatus {
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #ddd;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.adminLink {
  color: #aaa;
  text-decoration: none;
  border: 1px solid #343434;
  border-radius: 8px;
  padding: 9px 12px;
}
.adminLink:hover {
  color: #fff;
  border-color: #666;
}
#viewport {
  position: fixed;
  inset: 170px 0 0;
  overflow: auto;
  background-color: #080603;
  background-image:
    radial-gradient(circle at 15% 20%, #6f4d181f 0 2px, transparent 3px),
    radial-gradient(circle at 85% 75%, #d1a64617 0 1px, transparent 2px),
    repeating-linear-gradient(45deg, transparent 0 28px, #b98a3210 29px 30px),
    linear-gradient(135deg, #030303, #171005 48%, #050403);
  background-size:
    auto,
    auto,
    42px 42px,
    auto;
}
#wall {
  position: relative;
  width: 1920px;
  height: 1080px;
  background-color: #000;
  background-image:
    radial-gradient(#242015 1px, transparent 1px),
    linear-gradient(135deg, #050505, #000 55%, #080603);
  background-size: 32px 32px;
  box-shadow:
    0 0 0 2px #3a2a11,
    0 0 0 6px #c69b45,
    0 0 0 9px #4c3515,
    0 0 0 12px #17100a,
    0 18px 70px #000;
}
#wall::before {
  content: "";
  position: absolute;
  z-index: 15;
  inset: 12px;
  pointer-events: none;
  border: 2px solid #b98a3266;
  box-shadow:
    inset 0 0 0 2px #090704,
    inset 0 0 28px #c7983517;
}
#wall.fit-screen {
  position: absolute;
  transform-origin: top left;
}
@media (min-width: 900px) {
  #viewport {
    overflow: hidden;
  }
}
.entry,
.placement-preview {
  position: absolute;
  image-rendering: pixelated;
}
.entry {
  cursor: help;
  isolation: isolate;
}
.entry:hover {
  outline: 2px solid #fff;
  box-shadow: 0 0 14px #ffffff80;
  z-index: 16;
}
.entry canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}
.entry::after {
  content: attr(data-label);
  display: none;
  position: absolute;
  left: 50%;
  bottom: calc(100% + 6px);
  transform: translateX(-50%);
  white-space: nowrap;
  background: #080808ee;
  color: #fff;
  border: 1px solid #fff;
  border-radius: 6px;
  padding: 7px 11px;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: 0.01em;
  text-shadow: 0 1px 4px #000;
  box-shadow: 0 5px 18px #000c;
}
.entry:hover::after {
  display: block;
}
.placement-preview {
  width: 128px;
  height: 128px;
  z-index: 10;
  pointer-events: none;
  opacity: 0.72;
  outline: 2px solid #fff;
  box-shadow: 0 0 20px #fff8;
}
#empty {
  position: fixed;
  inset: 55% auto auto 50%;
  transform: translate(-50%, -50%);
  color: #555;
  pointer-events: none;
}
dialog {
  border: 1px solid #9d762f;
  border-radius: 14px;
  background: #0b0b0b;
  color: #eee;
  padding: 0;
  width: min(94vw, 720px);
  box-shadow:
    0 0 0 3px #241a0d,
    0 0 0 4px #d0a34b66,
    0 30px 100px #000;
}
dialog::backdrop {
  background: #000c;
  backdrop-filter: blur(5px);
}
form {
  padding: 22px;
}
.modalHead {
  display: flex;
  justify-content: space-between;
  margin-bottom: 18px;
}
.icon {
  font-size: 24px;
  padding: 2px 10px;
}
label {
  display: grid;
  gap: 7px;
  font-size: 12px;
  color: #aaa;
}
input[type="text"],
#name {
  background: #141414;
  border: 1px solid #333;
  border-radius: 7px;
  color: #fff;
  padding: 11px;
  margin-bottom: 13px;
}
.toolRows {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}
.toolRow {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.primaryTools button {
  min-width: 112px;
  font-weight: 700;
}
.toolIcon {
  display: inline-grid;
  place-items: center;
  width: 20px;
  font-size: 18px;
  line-height: 1;
}
.primaryTools .active {
  border-color: #e0b357;
  color: #fff4d6;
  background: linear-gradient(180deg, #39260e, #1c1409);
  box-shadow: inset 0 0 10px #d9a44220;
}
.colorControl {
  display: flex;
  align-items: center;
  gap: 7px;
}
.brushControl {
  display: grid;
  grid-template-columns: auto minmax(130px, 1fr) 42px;
  align-items: center;
  gap: 9px;
  min-width: min(100%, 290px);
  padding: 7px 10px;
  border: 1px solid #383024;
  border-radius: 8px;
  background: #11100d;
}
#brushSize {
  accent-color: #d7a847;
  width: 100%;
}
#brushValue {
  color: #e5c77e;
  text-align: right;
}
#color {
  width: 44px;
  height: 40px;
  padding: 3px;
  background: #111;
  border: 1px solid #444;
  border-radius: 7px;
}
#pixelCanvas {
  display: block;
  width: min(100%, 560px);
  aspect-ratio: 1;
  border: 1px solid #765927;
  background: repeating-conic-gradient(#171717 0 25%, #202020 0 50%) 0/16px 16px;
  image-rendering: pixelated;
  touch-action: none;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  margin: auto;
}
.canvasFrame {
  position: relative;
  width: min(100%, 596px);
  margin: auto;
  padding: 12px;
  border: 2px solid #be9140;
  outline: 1px solid #4b3516;
  background: linear-gradient(
    135deg,
    #2c1d0d,
    #080706 18%,
    #080706 82%,
    #2c1d0d
  );
  box-shadow:
    inset 0 0 0 3px #0c0905,
    inset 0 0 0 5px #8f692d,
    0 10px 35px #000b,
    0 0 18px #bd8d2f1c;
}
.canvasFrame::before,
.canvasFrame::after {
  content: "◆";
  position: absolute;
  z-index: 2;
  color: #e0b45c;
  background: #0b0805;
  font-size: 13px;
  line-height: 18px;
  width: 18px;
  height: 18px;
  text-align: center;
}
.canvasFrame::before {
  left: -9px;
  top: -9px;
}
.canvasFrame::after {
  right: -9px;
  bottom: -9px;
}
.hint {
  width: min(100%, 596px);
  margin: 10px auto 0;
  text-align: left;
  line-height: 1.45;
}
.actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}
#placing {
  display: none;
  position: fixed;
  z-index: 25;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #eee;
  color: #111;
  padding: 9px 10px 9px 15px;
  border-radius: 10px;
  align-items: center;
  gap: 13px;
  box-shadow: 0 10px 40px #000;
}
#placing.show {
  display: flex;
}
#toast {
  position: fixed;
  z-index: 40;
  right: 20px;
  bottom: 20px;
  max-width: 360px;
  background: #eee;
  color: #111;
  padding: 13px 16px;
  border-radius: 9px;
  opacity: 0;
  transform: translateY(12px);
  transition: 0.2s;
  pointer-events: none;
}
#toast.show {
  opacity: 1;
  transform: none;
}
@media (max-width: 600px) {
  header {
    min-height: 275px;
    align-items: stretch;
    flex-direction: column;
    justify-content: flex-start;
    gap: 9px;
    padding: 10px 13px;
  }
  .brand p {
    font-size: 11px;
    max-width: 270px;
  }
  .brand h1 {
    font-size: clamp(25px, 7.4vw, 34px);
  }
  #viewport {
    inset: 275px 0 0;
  }
  .wallMeta {
    gap: 5px;
    margin-top: 8px;
  }
  .wallMeta > div {
    flex: 1;
    min-width: 0;
    padding: 6px;
  }
  .wallMeta .countdownCard {
    min-width: 0;
  }
  .wallMeta span {
    font-size: 8px;
  }
  .wallMeta strong {
    font-size: 10px;
  }
  .countdownCard #countdown {
    font-size: 13px;
    letter-spacing: 0.025em;
  }
  .countdownCard small {
    font-size: 5px;
    letter-spacing: 0.03em;
  }
  .headerActions {
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 7px;
  }
  .headerActions #userStatus {
    display: block;
    flex-basis: 100%;
    max-width: none;
    color: #e7d7b5;
    font-size: 12px;
    text-align: right;
  }
  .adminLink,
  #logout:not([hidden]) {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 8px 11px;
  }
  dialog {
    width: 96vw;
    max-height: 96dvh;
    overscroll-behavior: contain;
  }
  form {
    padding: 14px;
    max-height: 96dvh;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  .modalHead {
    margin-bottom: 10px;
  }
  #name {
    margin-bottom: 9px;
  }
  .toolRows {
    margin-bottom: 8px;
  }
  .toolRow {
    gap: 6px;
  }
  .primaryTools button {
    min-width: 0;
    flex: 1;
    padding-inline: 7px;
  }
  .colorControl {
    width: 52px;
  }
  .colorControl span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
  }
  .secondaryTools .brushControl {
    flex-basis: 100%;
  }
  .secondaryTools button {
    flex: 1;
  }
  .canvasFrame {
    width: min(100%, calc(100dvh - 380px));
    min-width: 220px;
    padding: 9px;
  }
  #pixelCanvas {
    width: 100%;
    min-width: 220px;
  }
  .hint {
    margin-top: 6px;
  }
  .actions {
    position: sticky;
    bottom: -14px;
    background: #0b0b0b;
    padding: 10px 0 14px;
    margin-top: 6px;
  }
  button {
    padding: 9px 11px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .brand h1::after {
    animation: none;
    background-position: 50% 50%;
  }
}
