/* Sharlee — dress-up game, mobile-first */
:root {
  --bg: #F8F0E6;
  --peach: #F6D5C3;
  --peach-deep: #EFBCA4;
  --peach-glow: #FBE4D6;
  --cream: #FFF9F3;
  --sage: #8FAA86;
  --sage-deep: #6F8D68;
  --coral: #E8897A;
  --coral-deep: #D46B5C;
  --ink: #3C3835;
  --muted: #8B8580;
  --card: #F6EFE6;
  --card-press: #F0E4D8;
  --line: #E8DCD0;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --font: ui-rounded, "SF Pro Rounded", "Hiragino Maru Gothic ProN", "Hiragino Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.3;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

body {
  min-height: 100dvh;
  min-height: -webkit-fill-available;
}

.app {
  height: 100dvh;
  max-height: 100dvh;
  width: 100%;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-t);
  padding-left: var(--safe-l);
  padding-right: var(--safe-r);
  padding-bottom: 0;
  overflow: hidden;
  position: relative;
}

.deco {
  position: absolute;
  pointer-events: none;
  z-index: 0;
  opacity: 0.85;
}
.deco-tr { top: calc(var(--safe-t) + 4px); right: calc(var(--safe-r) + 2px); width: 88px; height: 120px; }
.deco-bl { left: calc(var(--safe-l) + 0px); bottom: 38%; width: 70px; height: 100px; }

.stage {
  position: relative;
  z-index: 1;
  overflow: hidden;
  flex: 1 1 44%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: stretch;
  padding: 0 8px;
}

.header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 4px 12px 0;
  width: 100%;
  z-index: 2;
}

.title {
  margin: 0;
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.1;
}
.title .s-coral { color: var(--coral); }
.title .s-sage { color: var(--sage-deep); }

.stage-art {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.glow {
  position: absolute;
  left: 50%;
  top: 8%;
  transform: translateX(-50%);
  width: min(78vw, 340px);
  height: 78%;
  background: radial-gradient(ellipse at 50% 45%, var(--peach) 0%, var(--peach-glow) 42%, rgba(248, 240, 230, 0) 72%);
  pointer-events: none;
  z-index: 0;
}

.platform {
  position: absolute;
  left: 50%;
  bottom: 2%;
  transform: translateX(-50%);
  width: min(64vw, 260px);
  height: 14%;
  background: radial-gradient(ellipse at 50% 50%, #F3C7B0 0%, #F0C4AC 55%, #E8B59C 100%);
  border-radius: 50%;
  box-shadow: 0 8px 16px rgba(180, 110, 80, 0.12), inset 0 2px 0 rgba(255, 255, 255, 0.28);
  z-index: 0;
  pointer-events: none;
}

.platform::after {
  content: "";
  position: absolute;
  inset: 18% 10% auto;
  height: 28%;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
}

#doll {
  position: relative;
  z-index: 1;
  height: 100%;
  width: auto;
  max-width: 100%;
  max-height: 100%;
  display: block;
  overflow: hidden;
}

.signature {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: center center;
  display: none;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}
.stage-art.is-signature .signature { display: block; }
.stage-art.is-signature #doll,
.stage-art.is-signature .platform,
.stage-art.is-signature .glow { display: none; }

.wardrobe {
  position: relative;
  z-index: 2;
  flex: 1 1 56%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--cream);
  border-radius: 24px 24px 0 0;
  box-shadow: 0 -10px 28px rgba(80, 50, 40, 0.07);
  overflow: hidden;
  padding-bottom: var(--safe-b);
}

.tabs {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scroll-padding-inline: 16px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  overscroll-behavior-y: none;
  padding: 12px 16px 8px;
  flex: 0 0 auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  flex: 0 0 auto;
  scroll-snap-align: start;
  min-height: 44px;
  min-width: 44px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}
.tab:active { background: var(--card-press); }
.tab[aria-selected="true"] {
  background: var(--coral);
  color: #fff;
}

.grid {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;

  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 6px 16px 16px;
  scrollbar-width: thin;
  align-content: start;
}
.grid > * {
  min-width: 0;
  min-height: 0;
  max-width: 100%;
}

.card {
  appearance: none;
  -webkit-appearance: none;
  display: block;
  position: relative;
  width: 100%;
  height: auto;
  min-height: 44px;
  min-width: 0;
  overflow: hidden;
  margin: 0;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 16px;
  background: var(--card);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  font-family: inherit;
  color: inherit;
  transition: border-color 0.15s ease, transform 0.15s ease, background 0.15s ease;
}
.card::before {
  content: "";
  display: block;
  width: 100%;
  padding-top: 100%;
}
.card:active { background: var(--card-press); transform: scale(0.97); }
.card[aria-pressed="true"] {
  border-color: var(--coral);
  background: #FFF6F2;
  box-shadow: 0 0 0 1px var(--coral);
}
.card svg {
  position: absolute;
  left: 8%;
  top: 8%;
  width: 84%;
  height: 84%;
  max-width: 100%;
  max-height: 100%;
  pointer-events: none;
  display: block;
  overflow: hidden;
}

.actions {
  flex: 0 0 auto;
  display: flex;
  gap: 10px;
  padding: 8px 16px 10px;
  padding-bottom: max(10px, var(--safe-b));
}

.btn {
  flex: 1 1 0;
  min-height: 44px;
  min-width: 44px;
  padding: 10px 14px;
  border: 0;
  border-radius: 999px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  color: #fff;
  transition: transform 0.15s ease, filter 0.15s ease;
}
.btn:active { transform: scale(0.97); filter: brightness(0.95); }
.btn-save { background: var(--coral); }
.btn-shuffle { background: var(--sage); }
.btn-reset {
  background: transparent;
  color: var(--ink);
  box-shadow: inset 0 0 0 2px var(--line);
  flex: 0 0 auto;
  padding-inline: 18px;
}

@media (min-width: 800px) {
  .app {
    flex-direction: row;
    padding: calc(12px + var(--safe-t)) calc(16px + var(--safe-r)) calc(12px + var(--safe-b)) calc(16px + var(--safe-l));
    gap: 8px;
  }
  .stage {
    flex: 1 1 44%;
    padding: 0 8px 8px;
  }
  .wardrobe {
    flex: 1 1 56%;
    border-radius: 24px;
    margin: 8px 8px 8px 0;
    max-width: 720px;
  }
  .grid { grid-template-columns: repeat(5, minmax(0, 1fr)); padding: 8px 20px 12px; }
  .deco-bl { bottom: 8%; }
  .actions { padding-bottom: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
  .card:active, .btn:active { transform: none; }
}
