/* ==========================================================================
   FUNsmooshy - the games room (funsmooshy.html) and Smooshy's dress-up room
   (fun-dressup.html), on top of theme.css and monster.css (her look)
   ========================================================================== */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

body.fun-page {
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  height: 100dvh;
  background: var(--menu-bg);
  font-family: var(--font-body);
  color: var(--text);
  touch-action: none;
}

/* --- Top: logo, our games, sound and reset --- */
.fun-top {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 6px;
}

.fun-logo {
  width: 190px;
  justify-self: start;
}

.fun-top .game-tabs {
  width: min(500px, 100%);
}

.fun-actions {
  justify-self: end;
  display: flex;
  gap: 8px;
}

.fun-round {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 3px 0 var(--line), var(--shadow-soft);
  font-size: 20px;
  cursor: pointer;
}

.fun-round:active,
.fun-pill:active {
  transform: translateY(2px);
}

/* Back to all the FUNsmooshy games */
.fun-pill {
  display: inline-flex;
  align-items: center;
  height: 44px;
  padding: 0 16px;
  border-radius: 999px;
  background: var(--surface);
  box-shadow: 0 3px 0 var(--line), var(--shadow-soft);
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  color: var(--coral);
  text-decoration: none;
  white-space: nowrap;
}

/* --- The games room: a card for each game --- */
body.fun-hub {
  grid-template-rows: auto 1fr auto;
  touch-action: pan-y;
}

.hub {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  min-height: 0;
  padding: 10px 16px 24px;
  overflow-y: auto;
}

.hub-head {
  text-align: center;
}

.hub-title {
  font-family: var(--font-display);
  font-size: clamp(32px, 6vw, 46px);
  font-weight: 600;
  line-height: 1.1;
  color: var(--coral);
}

.hub-sub {
  margin-top: 4px;
  font-size: 16px;
  color: var(--text);
}

.hub-games {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 270px));
  justify-content: center;
  gap: 20px;
  width: 100%;
  max-width: 900px;
}

.hub-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  height: 100%;
  padding: 14px 14px 18px;
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow-card);
  color: var(--ink);
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}

a.hub-card:hover {
  transform: translateY(-4px) rotate(-1deg);
  box-shadow: var(--shadow-card), 0 16px 30px rgba(123, 92, 230, 0.18);
}

a.hub-card:active {
  transform: translateY(1px);
}

.hub-art {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  margin-bottom: 6px;
  border-radius: var(--radius-lg);
  background: radial-gradient(circle at 50% 78%, #e3d6ff 0%, #f3edff 55%, #fbf8ff 100%);
}

.hub-art svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* her clothes are drawn on top of her, so she holds still in the picture (blinking is fine) */
.hub-art .m-body {
  animation: none;
}

.hub-name {
  font-family: var(--font-display);
  font-size: 23px;
  font-weight: 600;
}

.hub-desc {
  font-size: 14px;
  line-height: 1.35;
  text-align: center;
  color: var(--text);
}

.hub-play {
  margin-top: 10px;
  padding: 9px 26px;
  border-radius: 999px;
  background: var(--coral);
  box-shadow: 0 4px 0 var(--coral-dark);
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  color: #ffffff;
}

.hub-card.is-soon .hub-play {
  background: var(--coral-soft);
  box-shadow: none;
  color: var(--coral);
}

/* --- The stage: Smooshy on her floor --- */
.fun-stage {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  min-height: 0;
  --size: min(44vh, 68vw, 400px);
}

.fun-floor {
  position: absolute;
  left: 50%;
  bottom: 2%;
  width: calc(var(--size) * 2.4);
  max-width: 96vw;
  height: calc(var(--size) * 0.36);
  transform: translateX(-50%);
  border-radius: 50%;
  background:
    radial-gradient(ellipse at 50% 35%, rgba(255, 244, 199, 0.95) 0%, rgba(255, 244, 199, 0) 55%),
    linear-gradient(180deg, #dacdff 0%, #b9a4f7 100%);
  box-shadow: inset 0 6px 0 rgba(255, 255, 255, 0.6), 0 14px 30px rgba(90, 62, 190, 0.18);
}

.fun-stage .smooshy {
  position: relative;
  left: auto;
  top: auto;
  z-index: 2;
  width: var(--size);
  height: var(--size);
  margin-bottom: calc(var(--size) * 0.08);
  container-type: inline-size;
  cursor: pointer;
}

.fun-hint {
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  padding: 0 4px;
  font-family: 'Caveat', var(--font-display), cursive;
  font-size: 24px;
  font-weight: 700;
  color: var(--coral);
  white-space: nowrap;
  transition: opacity 0.4s ease;
  pointer-events: none;
}

.fun-hint.is-gone {
  opacity: 0;
}

/* --- Tools and their effects --- */
/* Soap bubbles sit on her fur; js/fun.js moves this layer with her body every frame */
.fun-bubbles {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  transform-origin: 0 0;
  container-type: inline-size;
}

.soap-bubble {
  position: absolute;
  width: calc(var(--b) * 1cqw);
  height: calc(var(--b) * 1cqw);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  /* a rainbow sheen that turns, like a real bubble's */
  background:
    radial-gradient(circle at 32% 28%, #ffffff 0 14%, rgba(255, 255, 255, 0) 24%),
    conic-gradient(from calc(var(--hue) * 1deg), rgba(255, 170, 220, 0.5), rgba(170, 220, 255, 0.45), rgba(200, 255, 220, 0.45), rgba(255, 240, 170, 0.5), rgba(255, 170, 220, 0.5));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.95), inset -2px -3px 5px rgba(255, 255, 255, 0.6);
  animation: bubbleIn 0.25s ease-out, bubbleBob 2.4s ease-in-out infinite;
}

.soap-bubble.is-popping {
  animation: bubblePop 0.26s ease-out forwards;
}

@keyframes bubbleIn { from { transform: translate(-50%, -50%) scale(0); } }
@keyframes bubbleBob {
  0%, 100% { margin-top: 0; }
  50% { margin-top: -0.6cqw; }
}
@keyframes bubblePop { to { transform: translate(-50%, -50%) scale(1.6); opacity: 0; } }

/* The mirror pops up beside her; her reflection inside copies everything she does */
.fun-mirror {
  position: absolute;
  bottom: calc(var(--size) * 0.18);
  left: calc(50% - var(--size) * 1.05);
  width: calc(var(--size) * 0.42);
  height: calc(var(--size) * 0.62);
  border-radius: 50% 50% 46% 46%;
  background: linear-gradient(135deg, #f4f9ff 0%, #d6e4ff 45%, #ffffff 55%, #dfe9ff 100%);
  border: calc(var(--size) * 0.035) solid #ffd166;
  box-shadow: 0 0 0 3px #e8a92a, 0 12px 24px rgba(90, 62, 190, 0.2);
  opacity: 0;
  transform: translateY(20px) scale(0.8);
  transition: opacity 0.35s ease, transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
}

.fun-mirror.is-up {
  opacity: 1;
  transform: none;
}

.mirror-glass {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: inherit;
}

/* a shine across the glass, over her reflection */
.mirror-glass::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0) 30%, rgba(255, 255, 255, 0.55) 45%, rgba(255, 255, 255, 0) 60%);
}

.mirror-smooshy {
  position: absolute;
  left: 50%;
  top: 8%;
  width: calc(var(--size) * 0.62);
  height: calc(var(--size) * 0.62);
  transform: translateX(-50%) scaleX(-1);
  opacity: 0.92;
}

.mirror-smooshy svg {
  width: 100%;
  height: 100%;
}

/* --- Dragged things follow the pointer --- */
.drag-ghost {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 80;
  font-size: 54px;
  line-height: 1;
  pointer-events: none;
  filter: drop-shadow(0 8px 10px rgba(58, 50, 83, 0.25));
}

.drag-ghost.is-tool {
  font-size: 58px;
}

.drag-ghost .item-art {
  display: block;
  width: 72px;
}

.drag-ghost.is-returning {
  transition: transform 0.3s ease-in, opacity 0.3s ease-in;
  opacity: 0.4;
}

.item-art svg {
  display: block;
  width: 100%;
  height: auto;
}

/* --- The tray: two rooms of things --- */
.fun-tray {
  position: relative;
  z-index: 5;
  margin: 0 auto;
  width: min(760px, calc(100% - 20px));
  padding: 10px 12px 12px;
  border-radius: var(--radius-xl) var(--radius-xl) 22px 22px;
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.room-tabs {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-bottom: 8px;
}

.room-tab {
  padding: 7px 16px;
  border: none;
  border-radius: 999px;
  background: #efe9ff;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
}

.room-tab.is-active {
  background: var(--coral);
  color: #ffffff;
  box-shadow: 0 3px 0 var(--coral-dark);
}

.tray-items {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
  gap: 6px;
}

.tray-items[hidden] {
  display: none;
}

.tray-item,
.tray-undress {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 2px 5px;
  border: none;
  border-radius: 16px;
  background: #f6f2ff;
  cursor: grab;
  touch-action: none;
  transition: transform 0.15s ease, background 0.2s ease, opacity 0.2s ease;
}

.tray-item:hover,
.tray-undress:hover {
  transform: translateY(-2px);
  background: #ece5ff;
}

.tray-item .item-art,
.tray-undress .item-art {
  width: 40px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tray-item .item-art svg,
.tray-undress .item-art svg {
  width: 100%;
  height: 100%;
}

/* "Take off": everything off her at once, last in the clothes trays; faded while she has nothing on */
.tray-undress {
  border: 2px dashed #ffb3cf;
  background: #fff3f7;
  cursor: pointer;
  touch-action: manipulation;
}

.tray-undress:hover {
  background: #ffe6ef;
}

.tray-undress .tray-label {
  color: var(--pink-ink);
}

.tray-undress.is-empty {
  opacity: 0.45;
}

.tray-label {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
}

/* Worn clothes show faded in the tray, with a small tick */
.tray-item.is-worn {
  opacity: 0.45;
  position: relative;
}

.tray-item.is-worn::after {
  content: '✓';
  position: absolute;
  top: 3px;
  right: 6px;
  font-size: 12px;
  font-weight: 900;
  color: var(--coral);
}

.fun-footer {
  padding: 6px 16px calc(6px + env(safe-area-inset-bottom, 0px));
  font-size: 11px;
  text-align: center;
  color: var(--muted);
}

.fun-footer a {
  color: var(--text);
}

/* --- Phones --- */
@media (max-width: 640px) {
  .fun-top {
    grid-template-columns: 1fr auto;
    gap: 8px;
  }

  .fun-logo {
    display: none;
  }

  .fun-top .game-tabs {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .fun-actions {
    grid-column: 1 / -1;
    grid-row: 1;
  }

  .fun-top .game-tab {
    font-size: 13px;
    padding: 8px 6px;
    gap: 4px;
  }

  .fun-stage {
    --size: min(40vh, 74vw, 320px);
  }

  /* No room beside her on a phone: the mirror pops up in the space above her left shoulder */
  .fun-mirror {
    z-index: 4;
    left: 6px;
    bottom: calc(var(--size) * 0.62);
    width: calc(var(--size) * 0.3);
    height: calc(var(--size) * 0.46);
  }

  .mirror-smooshy {
    width: calc(var(--size) * 0.46);
    height: calc(var(--size) * 0.46);
  }

  .tray-items {
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
  }

  .room-tab {
    padding: 7px 11px;
    font-size: 14px;
    white-space: nowrap;
  }

  .tray-label { font-size: 10.5px; }
  .fun-footer { font-size: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .soap-bubble {
    animation: none;
  }
}
