:root {
  --ink: #202020;
  --muted: #777777;
  --paper: #ffffff;
  --line: #333945;
  --soft-line: #d9d9d9;
  --accent: #7f8cff;
  --accent-soft: rgba(127, 140, 255, 0.22);
  --closet: #ffffff;
  --dialogue: #aaa09a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Malgun Gothic", "Apple SD Gothic Neo", system-ui, sans-serif;
  background: #ffffff;
  user-select: none;
}

button {
  font: inherit;
}

.game {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  height: auto;
  background: var(--paper);
  overflow: visible;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 62px;
  margin: 8px;
  padding: 10px;
  border: 0;
  border-radius: 0;
  background: #ffffff;
}

.top-actions {
  display: flex;
  align-items: center;
  width: min(100%, 900px, calc((100vh - 240px) * 1.414));
  margin: 0 auto 4px;
  gap: 8px;
}

.square-button,
.reset-button {
  border: 0;
  border-radius: 0;
  color: var(--ink);
  background: #ffffff;
  cursor: pointer;
}

.square-button {
  display: grid;
  place-items: center;
  width: 98px;
  height: 58px;
  font-size: 16px;
  color: #8fffad;
  padding: 0;
}

.square-button span {
  display: none;
}

.reset-button {
  min-width: 98px;
  height: 58px;
  padding: 0;
  color: #ff8aa3;
  font-size: 16px;
  font-weight: 600;
}

.square-button img,
.reset-button img {
  display: block;
  width: auto;
  height: 58px;
  max-width: 100%;
  object-fit: contain;
  pointer-events: none;
}

.square-button img {
  transform: none;
}

.stage-arrow:hover,
.square-button:hover,
.reset-button:hover,
.closet-card:hover {
  border-color: var(--accent);
}

.play-area {
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  align-items: center;
  min-height: 0;
  min-width: 0;
  padding: 8px 8px 0;
  border-bottom: 0;
  background: #ffffff;
  overflow: visible;
}

.stage {
  position: relative;
  width: min(100%, 900px, calc((100vh - 240px) * 1.414));
  max-width: 100%;
  min-width: 0;
  aspect-ratio: 1117 / 790;
  height: auto;
  overflow: hidden;
  border: 1px solid #dddddd;
  border-radius: 0;
  background: #f7f2eb;
  box-shadow: none;
}

.stage-arrow {
  position: absolute;
  top: 50%;
  z-index: 9;
  display: grid;
  place-items: center;
  width: 48px;
  height: 80px;
  border: 0;
  border-radius: 0;
  color: #ffd3df;
  font-size: 54px;
  line-height: 1;
  text-shadow: 0 2px 8px rgba(8, 16, 39, 0.85);
  background: transparent;
  cursor: pointer;
  transform: translateY(-50%);
}

.stage-arrow-left {
  left: 12px;
}

.stage-arrow-right {
  right: 12px;
}

.background {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #f7f2eb;
}

.doll {
  position: absolute;
  bottom: 15px;
  width: 42%;
  aspect-ratio: 2 / 3;
  transition: filter 140ms ease, transform 140ms ease;
}

.doll-left {
  left: calc(14% - 15px);
}

.doll-right {
  right: calc(14% + 15px);
  width: calc(42% + 1px);
}

.doll.drop-ready {
  filter: none;
  transform: none;
}

.layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  transform: translate(var(--wear-x, 0), var(--wear-y, 0)) scale(var(--wear-scale, 1));
  transform-origin: center bottom;
}

.base {
  z-index: 1;
}

.outfit {
  z-index: 3;
}

.event-clothes {
  z-index: 4;
}

.event-face {
  z-index: 2;
}

.outfit,
.event-clothes,
.event-face,
.dialogue {
  display: none;
}

.dialogue {
  position: absolute;
  z-index: 60;
  left: 21%;
  right: 21%;
  bottom: 5%;
  align-items: center;
  justify-content: center;
  min-height: 100px;
  padding: 15px 63px 15px 20px;
  border: 7px solid #070707;
  color: #111;
  font-size: clamp(17px, 2.1vw, 28px);
  line-height: 1.25;
  text-align: center;
  background: var(--dialogue);
}

.dialogue.show {
  display: flex;
}

#dialogueText {
  white-space: pre-line;
}

.dialogue button {
  position: absolute;
  right: 24px;
  bottom: 15px;
  border: 0;
  font-size: 30px;
  background: transparent;
  cursor: pointer;
}

.closet {
  display: grid;
  flex: 0 0 180px;
  grid-template-columns: 1fr 1fr;
  min-height: 0;
  background: var(--closet);
  overflow: hidden;
  border-top: 8px solid #ffffff;
}

.closet-side {
  position: relative;
  min-width: 0;
  padding: 18px 18px 10px;
  border-right: 6px solid #dddddd;
  min-height: 0;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  touch-action: pan-x;
  -webkit-overflow-scrolling: touch;
}

.closet-side::-webkit-scrollbar:vertical {
  width: 0;
  display: none;
}

.closet-side::-webkit-scrollbar:horizontal {
  height: 12px;
}

.closet-side:last-child {
  border-right: 0;
}

.closet-title {
  display: none;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  color: transparent;
  font-weight: 700;
}

.closet-title small {
  color: transparent;
  font-size: 13px;
  font-weight: 400;
}

.closet-rail {
  display: none !important;
}

.closet-grid {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  gap: 0;
  height: 100%;
  padding-top: 0;
  padding-left: 0;
  overflow: visible;
  scrollbar-color: #bfbfbf #ffffff;
  scrollbar-width: thin;
}

.closet-card {
  position: relative;
  display: grid;
  flex: 0 0 138px;
  grid-template-rows: 156px 0;
  min-height: 160px;
  padding: 0;
  border: 0;
  border-radius: 0;
  color: var(--ink);
  background: transparent;
  cursor: grab;
  touch-action: pan-x;
  overflow: hidden;
}

.closet-card:first-child {
  margin-left: 0;
}

.closet-card + .closet-card {
  margin-left: -48px;
}

#leftCloset .closet-card + .closet-card {
  margin-left: -48px;
}

.closet-card:active {
  cursor: grabbing;
}

.closet-card.active {
  background: transparent;
  box-shadow: none;
}

.hanger {
  display: none;
}

.closet-card img {
  width: 100%;
  height: 100%;
  max-height: none;
  object-fit: contain;
  object-position: center top;
  pointer-events: none;
  transform: translateY(-150px) scale(2.2);
  transform-origin: center top;
}

#leftCloset .closet-card:not([data-id="hidden"]) img,
#rightCloset .closet-card:not([data-id="hidden"]) img {
  transform: translateY(-112px) scale(1.72);
}

#leftCloset .closet-card:not([data-id="hidden"]) img {
  transform: translateY(-96px) scale(1.48);
}

.closet-card[data-id="hidden"][data-kind="outfit"] img {
  transform: translateY(-330px) translateX(88px) scale(2.25);
  opacity: 0.28;
}

.closet-card[data-id="hidden"][data-kind="outfit"] {
  z-index: 5;
  flex-basis: 72px;
  margin-left: -40px;
}

#leftCloset .closet-card[data-id="hidden"][data-kind="outfit"] {
  margin-left: -40px;
}

.closet-card span {
  display: none;
  min-height: 24px;
  padding: 4px 3px 0;
  font-size: 13px;
  line-height: 1.15;
  text-align: center;
  overflow-wrap: anywhere;
}

.drag-ghost {
  position: fixed;
  z-index: 20;
  width: 160px;
  height: 220px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.drag-ghost img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: none;
}

@media (max-width: 900px) {
  .top-bar {
    min-height: 90px;
    padding: 12px;
  }

  .square-button {
    width: 100px;
    height: 60px;
  }

  .reset-button {
    min-width: 100px;
    height: 60px;
    font-size: 20px;
  }

.stage {
    width: min(100%, 760px);
  }

  .top-actions {
    width: min(100%, 760px);
  }

  .closet {
    flex-basis: 172px;
  }

  .closet-card {
    flex-basis: 128px;
    grid-template-rows: 148px 0;
    min-height: 152px;
  }

  .closet-card + .closet-card {
    margin-left: -44px;
  }
}

@media (max-width: 560px) {
  .top-bar {
    min-height: 58px;
  }

  .closet {
    flex-basis: 156px;
  }

  .stage-arrow {
    width: 40px;
    height: 64px;
    font-size: 44px;
  }

  .doll {
    bottom: 15px;
    width: 42%;
  }

  .doll-left {
    left: calc(9% - 15px);
  }

  .doll-right {
    right: calc(9% + 15px);
    width: calc(42% + 1px);
  }

  .dialogue {
    left: 12%;
    right: 12%;
    min-height: 78px;
    border-width: 5px;
    font-size: clamp(15px, 4vw, 20px);
    line-height: 1.22;
  }

  .dialogue button {
    right: 18px;
    bottom: 12px;
    font-size: 28px;
  }

  .closet-card {
    flex-basis: 116px;
    grid-template-rows: 132px 0;
    min-height: 136px;
  }

  .closet-card + .closet-card {
    margin-left: -40px;
  }
}
