:root {
  --line: #c8c8c8;
  --line-soft: #e7e7e7;
  --ink: #111;
  --panel: #efefef;
  --paper: #fbfbfb;
  --shadow: #8e8e8e;
  --blue: #0619a8;
  --green: #24d24f;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  scrollbar-width: none;
}

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

body {
  margin: 0;
  color: var(--ink);
  font-family: "MS Sans Serif", "Arial Narrow", Arial, sans-serif;
  font-size: 12px;
  letter-spacing: 0;
  background-color: #fff;
  overflow-x: hidden;
}

body.is-grabbing,
body.is-grabbing * {
  cursor: grabbing !important;
}

button,
a {
  font: inherit;
}

a {
  color: var(--ink);
  text-decoration: none;
}

a:hover {
  color: var(--blue);
  text-decoration: underline;
}

.browser-window {
  width: calc(100% - 8px);
  min-height: calc(100vh - 8px);
  margin: 4px auto;
  background: transparent;
  border: 1px solid #222;
  box-shadow:
    inset 1px 1px 0 #fff,
    inset -1px -1px 0 var(--shadow),
    4px 4px 0 rgba(0, 0, 0, 0.14);
  display: flex;
  flex-direction: column;
}

.browser-window.is-window-jolt {
  animation: window-jolt 560ms steps(2, end);
}

.browser-window.is-window-minimized .menu-bar,
.browser-window.is-window-minimized .toolbar,
.browser-window.is-window-minimized .page-head,
.browser-window.is-window-minimized .asset-shell,
.browser-window.is-window-minimized .status-bar {
  display: none;
}

.browser-window.is-window-max-flash {
  animation: window-max-flash 760ms steps(2, end);
}

.title-bar {
  min-height: 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 3px 5px 3px 8px;
  background: linear-gradient(90deg, #fff 0%, #e4e4e4 62%, #d7d7d7 100%);
  border-bottom: 1px solid #000;
}

.window-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.window-controls {
  display: flex;
  gap: 4px;
}

.window-controls button,
.tiny-button,
.gravity-button {
  min-width: 24px;
  height: 22px;
  display: inline-grid;
  place-items: center;
  background: var(--panel);
  border: 1px solid #222;
  box-shadow:
    inset 1px 1px 0 #fff,
    inset -1px -1px 0 var(--shadow);
  color: var(--ink);
}

.window-controls button {
  padding-bottom: 2px;
  cursor: pointer;
}

.window-controls button:active {
  box-shadow:
    inset -1px -1px 0 #fff,
    inset 1px 1px 0 var(--shadow);
  transform: translate(1px, 1px);
}

.menu-bar {
  display: flex;
  gap: 14px;
  align-items: center;
  min-height: 25px;
  padding: 4px 8px;
  border-bottom: 1px solid var(--line);
  background: #f4f4f4;
}

.menu-bar span {
  cursor: pointer;
}

.menu-bar span:hover,
.nav-links a:hover {
  color: #fff;
  background: var(--blue);
  text-decoration: none;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  min-height: 42px;
  padding: 8px;
  border-bottom: 1px solid var(--line);
  background: transparent;
}

.nav-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
}

.tiny-button {
  cursor: pointer;
}

.tiny-button.is-spilling {
  background: var(--green);
}

.gravity-button {
  width: 92px;
  padding: 0 10px;
  cursor: pointer;
  background: #f8f8f8;
}

.gravity-button:hover,
.gravity-button.is-active {
  background: var(--green);
}

.gravity-button:active,
.tiny-button:active {
  box-shadow:
    inset -1px -1px 0 #fff,
    inset 1px 1px 0 var(--shadow);
  transform: translate(1px, 1px);
}

.page-head {
  position: relative;
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.7);
}

.page-head.is-home-pulse {
  animation: home-pulse 620ms steps(2, end);
}

.time-stamp {
  margin: 0 0 10px;
}

h1 {
  margin: 0;
  font-size: clamp(36px, 9vw, 116px);
  line-height: 0.88;
  font-weight: 400;
  letter-spacing: 0;
}

.subline {
  width: fit-content;
  max-width: 100%;
  margin: 12px 0 0;
  padding: 2px 5px;
  color: #fff;
  background: var(--blue);
}

.asset-shell {
  position: relative;
  flex: 1;
  min-height: 470px;
  padding: 0;
  overflow: hidden;
  background: transparent;
}

.asset-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  padding: 1px;
  background: transparent;
}

.asset-card {
  position: relative;
  aspect-ratio: 1 / 1;
  min-height: 0;
  display: block;
  background: transparent;
  border: 1px solid var(--line);
  touch-action: none;
  user-select: none;
  cursor: default;
  z-index: 1;
}

.asset-card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border: 0;
}

.asset-card.is-dragging {
  cursor: grabbing;
  z-index: 40;
}

.asset-card.is-gravity {
  position: fixed;
  margin: 0;
  z-index: 30;
  border-color: transparent;
  transition: none;
  will-change: left, top, transform;
}

.asset-card img {
  width: 100%;
  height: calc(100% - 14px);
  padding: 6px 8px 2px;
  object-fit: contain;
  pointer-events: none;
  -webkit-user-drag: none;
  filter: drop-shadow(-12px 16px 14px rgba(0, 0, 0, 0.24));
  transition: transform 360ms cubic-bezier(0.2, 0.95, 0.2, 1);
  transform-origin: center;
}

.asset-card.is-dragging img {
  transition: none;
  filter: drop-shadow(-16px 20px 18px rgba(0, 0, 0, 0.3));
  position: relative;
  z-index: 5;
}

.asset-card.is-hovering-object:not(.is-dragging) img {
  animation: object-float-y 1.45s ease-in-out infinite;
}

.asset-card.is-card-jiggle img {
  animation: card-jiggle 680ms ease-in-out;
}

@keyframes object-float-y {
  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-12px);
  }
}

.fake-dropdown {
  position: fixed;
  left: 0;
  top: 0;
  min-width: 150px;
  padding: 4px 0;
  background: #efefef;
  border: 1px solid #222;
  box-shadow:
    inset 1px 1px 0 #fff,
    inset -1px -1px 0 var(--shadow),
    5px 5px 0 rgba(0, 0, 0, 0.14);
  color: var(--ink);
  pointer-events: none;
  z-index: 130;
  animation: dropdown-pop 980ms steps(2, end) forwards;
}

.fake-dropdown span {
  display: block;
  padding: 4px 12px;
  white-space: nowrap;
}

.fake-dropdown span:first-child {
  color: #fff;
  background: var(--blue);
}

.archive-stamp {
  position: fixed;
  left: 50%;
  top: 50%;
  padding: 4px 8px;
  color: var(--blue);
  border: 2px solid var(--blue);
  background: rgba(255, 255, 255, 0.82);
  font-size: clamp(18px, 4vw, 42px);
  font-weight: 700;
  pointer-events: none;
  z-index: 125;
  transform: translate(-50%, -50%) rotate(-8deg) scale(0.55);
  animation: archive-stamp-pop 900ms cubic-bezier(0.2, 0.9, 0.25, 1) forwards;
}

.fake-close-screen {
  position: fixed;
  inset: 4px;
  display: grid;
  place-items: center;
  background: var(--blue);
  color: #fff;
  border: 1px solid #222;
  font-size: clamp(16px, 4vw, 42px);
  line-height: 1.1;
  text-align: center;
  pointer-events: none;
  z-index: 180;
  animation: fake-close-screen-pop 1150ms steps(2, end) forwards;
}

.fake-close-screen span {
  display: block;
  padding: 12px;
}

@keyframes window-jolt {
  0%,
  100% {
    transform: translate(0, 0);
  }

  20% {
    transform: translate(-5px, 0);
  }

  40% {
    transform: translate(4px, -2px);
  }

  60% {
    transform: translate(-2px, 3px);
  }

  80% {
    transform: translate(3px, 0);
  }
}

@keyframes window-max-flash {
  0%,
  100% {
    filter: none;
    transform: scale(1);
  }

  22% {
    filter: invert(1);
    transform: scale(0.995);
  }

  44% {
    filter: none;
    transform: scale(1.004);
  }

  66% {
    filter: invert(1);
    transform: scale(1);
  }
}

@keyframes home-pulse {
  0%,
  100% {
    filter: none;
  }

  50% {
    filter: invert(1);
  }
}

@keyframes card-jiggle {
  0%,
  100% {
    transform: translateY(0) rotate(0deg);
  }

  25% {
    transform: translateY(-10px) rotate(-4deg);
  }

  50% {
    transform: translateY(4px) rotate(3deg);
  }

  75% {
    transform: translateY(-6px) rotate(-2deg);
  }
}

@keyframes dropdown-pop {
  0% {
    opacity: 0;
    transform: translateY(-4px);
  }

  12%,
  78% {
    opacity: 1;
    transform: translateY(0);
  }

  100% {
    opacity: 0;
    transform: translateY(-4px);
  }
}

@keyframes archive-stamp-pop {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(-8deg) scale(0.55);
  }

  18%,
  72% {
    opacity: 1;
    transform: translate(-50%, -50%) rotate(-8deg) scale(1);
  }

  100% {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(-8deg) scale(1.18);
  }
}

@keyframes fake-close-screen-pop {
  0%,
  82% {
    opacity: 1;
  }

  100% {
    opacity: 0;
  }
}

.asset-name {
  position: absolute;
  left: 4px;
  right: 4px;
  bottom: 2px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 2px;
  border-top: 0;
  background: transparent;
  overflow: hidden;
  white-space: nowrap;
}

.asset-name span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.asset-name span:last-child {
  flex: 0 0 auto;
}

.status-bar {
  min-height: 27px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 5px 8px;
  border-top: 1px solid var(--line);
  background: #efefef;
}

body.gravity-active .asset-grid {
  background: transparent;
}

body.gravity-active .asset-card:not(.is-gravity) {
  visibility: hidden;
}

.asset-card.is-gravity::before,
.asset-card.is-gravity .asset-name {
  display: none;
}

.asset-card.is-gravity img {
  transition: none;
}

.asset-burst {
  position: fixed;
  left: 0;
  top: 0;
  width: clamp(42px, 5.5vw, 74px);
  height: clamp(42px, 5.5vw, 74px);
  object-fit: contain;
  pointer-events: none;
  z-index: 120;
  opacity: 0;
  filter: drop-shadow(-10px 14px 14px rgba(0, 0, 0, 0.26));
  transform: translate(-50%, -50%) scale(0.28) rotate(0deg);
  animation: asset-burst-pop 1150ms cubic-bezier(0.15, 0.8, 0.2, 1) forwards;
}

@keyframes asset-burst-pop {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.28) rotate(0deg);
  }

  12% {
    opacity: 1;
  }

  72% {
    opacity: 1;
  }

  100% {
    opacity: 0;
    transform:
      translate(calc(-50% + var(--burst-x)), calc(-50% + var(--burst-y)))
      scale(var(--burst-scale))
      rotate(var(--burst-rotate));
  }
}

@media (max-width: 640px) {
  .browser-window {
    width: calc(100% - 6px);
    min-height: calc(100vh - 6px);
    margin: 3px auto;
  }

  .menu-bar {
    gap: 10px;
    overflow: hidden;
  }

  .toolbar {
    align-items: flex-start;
  }

  .nav-links {
    gap: 10px;
  }

  .gravity-button {
    width: 78px;
  }

  .page-head {
    padding: 14px 12px 12px;
  }

  .asset-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .asset-card {
    min-height: 0;
  }

  .asset-card img {
    height: calc(100% - 12px);
    padding: 4px 5px 1px;
  }

  .asset-name {
    left: 2px;
    right: 2px;
    bottom: 1px;
    height: 18px;
    gap: 4px;
    font-size: 10px;
  }
}

@media (max-width: 420px) {
  .asset-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
