:root {
  --win-bg: #c0c0c0;
  --win-border-light: #ffffff;
  --win-border-shadow: #808080;
  --win-border-dark: #000000;
  --win-title-bg: #000080;
  --win-title-text: #ffffff;
  --text-main: #000000;
  --void: #000000;
}

* {
  box-sizing: border-box;
  user-select: none;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background-color: var(--void);
  overflow: hidden;
  font-family: "VT323", monospace;
  -webkit-font-smoothing: none;
  font-smooth: never;
  color: var(--text-main);
}

button {
  appearance: none;
  -webkit-appearance: none;
}

#starfield {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  z-index: 0;
}

.scanlines {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  background: linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0),
    rgba(255, 255, 255, 0) 50%,
    rgba(0, 0, 0, 0.1) 50%,
    rgba(0, 0, 0, 0.1)
  );
  background-size: 100% 4px;
  z-index: 999;
  pointer-events: none;
}

.vignette {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  box-shadow: inset 0 0 150px rgba(0, 0, 0, 0.9);
  z-index: 998;
  pointer-events: none;
}

#floating-cats {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  z-index: 1;
  pointer-events: none;
  overflow: hidden;
}

.floating-sprite {
  position: absolute;
  will-change: transform;
  display: block;
  width: auto;
  height: auto;
  image-rendering: auto;
  object-fit: contain;
  filter: drop-shadow(6px 6px 0 rgba(0, 0, 0, 0.45));
}

main {
  position: relative;
  z-index: 10;
  width: 100%;
  height: 100dvh;
  display: grid;
  place-items: center;
  padding: 20px;
  overflow: auto;
}

.window {
  background: var(--win-bg);
  border-top: 2px solid var(--win-border-light);
  border-left: 2px solid var(--win-border-light);
  border-right: 2px solid var(--win-border-dark);
  border-bottom: 2px solid var(--win-border-dark);
  box-shadow:
    inset -1px -1px 0 var(--win-border-shadow),
    inset 1px 1px 0 #dfdfdf,
    5px 5px 0 rgba(0, 0, 0, 0.5);
  width: min(800px, 100%);
  max-width: 100%;
  display: flex;
  flex-direction: column;
  margin: auto;
}

.title-bar {
  background: var(--win-title-bg);
  padding: 3px 2px 3px 4px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 2px 2px 0 2px;
}

.title-bar-text {
  color: var(--win-title-text);
  font-size: 16px;
  letter-spacing: 1px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.title-bar-controls {
  display: flex;
}

.win-btn {
  background: var(--win-bg);
  border-top: 2px solid var(--win-border-light);
  border-left: 2px solid var(--win-border-light);
  border-right: 2px solid var(--win-border-dark);
  border-bottom: 2px solid var(--win-border-dark);
  box-shadow:
    inset -1px -1px 0 var(--win-border-shadow),
    inset 1px 1px 0 #dfdfdf;
  font-family: "VT323", monospace;
  font-size: 16px;
  padding: 4px 12px;
  cursor: pointer;
  color: var(--text-main);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.win-btn:active {
  border-top: 2px solid var(--win-border-dark);
  border-left: 2px solid var(--win-border-dark);
  border-right: 2px solid var(--win-border-light);
  border-bottom: 2px solid var(--win-border-light);
  box-shadow: inset 1px 1px 0 var(--win-border-shadow);
  padding: 5px 11px 3px 13px;
}

.btn-close {
  font-weight: bold;
  padding: 0;
  width: 20px;
  height: 18px;
  font-size: 14px;
  line-height: 1;
}

.window-body {
  padding: 10px;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  margin-bottom: -2px;
  z-index: 1;
  position: relative;
  gap: 2px;
}

.tab {
  background: var(--win-bg);
  border-top: 2px solid var(--win-border-light);
  border-left: 2px solid var(--win-border-light);
  border-right: 2px solid var(--win-border-dark);
  border-bottom: 0;
  padding: 6px 12px;
  font-size: 18px;
  cursor: pointer;
  margin-top: 4px;
  flex: 0 1 auto;
  min-width: 0;
  text-align: center;
}

.tab.active {
  margin-top: 0;
  padding-bottom: 8px;
  position: relative;
  z-index: 2;
}

.tab.active::after {
  content: "";
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--win-bg);
}

.tab-content {
  border-top: 2px solid var(--win-border-light);
  border-left: 2px solid var(--win-border-light);
  border-right: 2px solid var(--win-border-dark);
  border-bottom: 2px solid var(--win-border-dark);
  box-shadow:
    inset -1px -1px 0 var(--win-border-shadow),
    inset 1px 1px 0 #dfdfdf;
  padding: 16px;
  background: var(--win-bg);
  height: 450px;
  min-width: 0;
  display: none;
  flex-direction: column;
  position: relative;
  z-index: 1;
  overflow: auto;
}

.tab-content.active {
  display: flex;
}

.inset-panel {
  background: #ffffff;
  border-top: 2px solid var(--win-border-shadow);
  border-left: 2px solid var(--win-border-shadow);
  border-right: 2px solid var(--win-border-light);
  border-bottom: 2px solid var(--win-border-light);
  box-shadow: inset 1px 1px 0 var(--win-border-dark);
  padding: 12px;
  overflow-y: auto;
}

.inset-fill {
  height: 100%;
}

#tab-home {
  align-items: center;
  justify-content: center;
  text-align: center;
  background: #000;
  color: #fff;
  border: inset 3px #808080;
  position: relative;
  overflow: hidden;
}

.home-eat {
  width: min(320px, 64%);
  height: auto;
  margin-bottom: 30px;
  display: block;
  object-fit: contain;
  image-rendering: pixelated;
  filter: drop-shadow(4px 4px 0 #000);
}

.home-text {
  font-size: 28px;
  line-height: 1.4;
  text-shadow: 2px 2px 0 #000;
  z-index: 2;
}

.home-subtext {
  font-size: 16px;
  color: #aaa;
  margin-top: 20px;
}

.lore-header {
  font-size: 24px;
  margin-bottom: 10px;
  border-bottom: 2px solid var(--win-border-shadow);
  padding-bottom: 5px;
}

.lore-text p {
  font-size: 18px;
  line-height: 1.5;
  margin-bottom: 15px;
}

#tab-links {
  justify-content: center;
  align-items: center;
  gap: 20px;
}

.link-btn {
  font-size: 24px;
  padding: 15px 30px;
  width: 300px;
  max-width: 100%;
  display: flex;
  justify-content: flex-start;
  gap: 20px;
  text-decoration: none;
}

.link-btn-buy {
  font-weight: bold;
  color: #0000aa;
}

.icon-box {
  width: 32px;
  height: 32px;
  display: inline-block;
  background-size: cover;
  image-rendering: pixelated;
}

.bagworking-panel {
  height: 100%;
}

.bagworking-form {
  display: grid;
  gap: 10px;
}

.bag-label {
  font-size: 18px;
}

.bag-input,
.bag-textarea,
.bag-file {
  width: 100%;
  background: #ffffff;
  color: #000000;
  border-top: 2px solid var(--win-border-shadow);
  border-left: 2px solid var(--win-border-shadow);
  border-right: 2px solid var(--win-border-light);
  border-bottom: 2px solid var(--win-border-light);
  box-shadow: inset 1px 1px 0 var(--win-border-dark);
  font-family: "VT323", monospace;
  font-size: 20px;
  padding: 10px 12px;
  outline: none;
}

.bag-textarea {
  resize: vertical;
  min-height: 110px;
}

.bag-file {
  padding: 8px 10px;
}

.bag-files,
.bagworking-status {
  min-height: 26px;
  font-size: 18px;
  line-height: 1.3;
}

.bagworking-actions {
  display: flex;
  justify-content: flex-start;
  margin-top: 6px;
}

.bagworking-status.is-error {
  color: #aa0000;
}

.bagworking-status.is-success {
  color: #006600;
}

.pfp-layout {
  display: flex;
  gap: 16px;
  height: 100%;
  min-width: 0;
}

.pfp-left {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.pfp-right {
  width: 200px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.pfp-canvas-container {
  flex-grow: 1;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

#main-pfp-image {
  width: 80%;
  height: 80%;
  display: block;
  object-fit: contain;
  image-rendering: auto;
}

.pfp-controls {
  display: flex;
  gap: 10px;
}

.pfp-controls .win-btn {
  flex: 1;
}

.pfp-sidebar-title {
  font-size: 14px;
  margin-bottom: 5px;
}

.thumb-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  overflow-y: auto;
  flex-grow: 1;
}

.thumb-item {
  aspect-ratio: 1;
  background: #000;
  cursor: pointer;
  border: 2px solid transparent;
}

.thumb-item:hover {
  border-color: var(--win-border-shadow);
}

.thumb-item.selected {
  border-color: #0000aa;
  border-style: dotted;
}

.thumb-item img,
.thumb-item svg {
  width: 100%;
  height: 100%;
  display: block;
}

.thumb-item img {
  object-fit: cover;
  image-rendering: auto;
}

.catalog-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  height: 100%;
  min-width: 0;
}

.catalog-item {
  background: #000;
  aspect-ratio: 1;
  position: relative;
  border: 2px solid var(--win-bg);
  display: block;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

.catalog-item img,
.catalog-item svg {
  width: 100%;
  height: 100%;
  display: block;
}

.catalog-item img {
  object-fit: cover;
  image-rendering: auto;
}

.catalog-label {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  background: rgba(192, 192, 192, 0.9);
  font-size: 12px;
  padding: 2px;
  text-align: center;
  border-top: 1px solid var(--win-border-light);
}

::-webkit-scrollbar {
  width: 16px;
  background: #dfdfdf;
  border-left: 1px solid #ffffff;
}

::-webkit-scrollbar-button {
  height: 16px;
  background-color: var(--win-bg);
  border-top: 1px solid var(--win-border-light);
  border-left: 1px solid var(--win-border-light);
  border-right: 1px solid var(--win-border-dark);
  border-bottom: 1px solid var(--win-border-dark);
  box-shadow:
    inset -1px -1px 0 var(--win-border-shadow),
    inset 1px 1px 0 #dfdfdf;
}

::-webkit-scrollbar-thumb {
  background-color: var(--win-bg);
  border-top: 1px solid var(--win-border-light);
  border-left: 1px solid var(--win-border-light);
  border-right: 1px solid var(--win-border-dark);
  border-bottom: 1px solid var(--win-border-dark);
  box-shadow:
    inset -1px -1px 0 var(--win-border-shadow),
    inset 1px 1px 0 #dfdfdf;
}

@media (max-width: 900px) {
  main {
    padding: 16px;
  }

  .window {
    margin: 0 auto;
  }

  .tab-content {
    height: min(450px, calc(100dvh - 220px));
    min-height: 320px;
  }

  .pfp-layout {
    flex-direction: column;
  }

  .pfp-right {
    width: 100%;
    min-height: 160px;
    max-height: 260px;
  }

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

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

@media (max-width: 640px) {
  main {
    height: 100dvh;
    padding: 10px;
  }

  .window {
    width: min(800px, calc(100vw - 20px));
    box-shadow:
      inset -1px -1px 0 var(--win-border-shadow),
      inset 1px 1px 0 #dfdfdf,
      3px 3px 0 rgba(0, 0, 0, 0.45);
  }

  .title-bar-text {
    font-size: 13px;
    letter-spacing: 0.5px;
    gap: 4px;
  }

  .window-body {
    padding: 8px;
  }

  .tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px;
    margin-bottom: 8px;
  }

  .tab {
    margin-top: 0;
    border-bottom: 2px solid var(--win-border-dark);
    padding: 8px 6px;
    font-size: 15px;
    line-height: 1.1;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow-wrap: anywhere;
  }

  .tab.active {
    padding-bottom: 8px;
  }

  .tab.active::after {
    display: none;
  }

  .tab-content {
    padding: 10px;
    min-height: 280px;
    height: min(450px, calc(100dvh - 250px));
  }

  .inset-panel {
    padding: 10px;
  }

  .home-eat {
    width: min(260px, 82%);
    margin-bottom: 20px;
  }

  .home-text {
    font-size: 22px;
    line-height: 1.3;
  }

  .home-subtext {
    font-size: 14px;
    margin-top: 14px;
  }

  .lore-header {
    font-size: 20px;
  }

  .lore-text p {
    font-size: 16px;
    line-height: 1.35;
    margin-bottom: 12px;
  }

  #tab-links {
    gap: 12px;
  }

  .link-btn {
    width: 100%;
    font-size: 20px;
    padding: 12px 14px;
    gap: 14px;
  }

  .icon-box {
    width: 26px;
    height: 26px;
    flex: 0 0 26px;
  }

  .bag-label {
    font-size: 16px;
  }

  .bag-input,
  .bag-textarea,
  .bag-file {
    font-size: 18px;
    padding: 8px 10px;
  }

  .bagworking-status,
  .bag-files {
    font-size: 16px;
  }

  #main-pfp-image {
    width: 100%;
    height: auto;
    max-height: 56vh;
  }

  .pfp-controls {
    flex-direction: column;
  }

  .pfp-controls .win-btn {
    width: 100%;
  }

  .pfp-right {
    max-height: 220px;
  }

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

  .catalog-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    height: auto;
  }
}
