/* styles.css — plain CSS: no framework, no web fonts (offline-first). */
:root {
  --ink: #1f2937;
  --paper: rgba(255, 255, 255, 0.72);
  --accent: #ec4899;
  --radius: 22px;
  color-scheme: light;
}

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

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  font-family: system-ui, -apple-system, "Segoe UI", "Noto Sans", "Noto Sans Arabic", Tahoma, sans-serif;
  color: var(--ink);
  background: linear-gradient(135deg, #fbcfe8 0%, #c7d2fe 50%, #bae6fd 100%);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  cursor: pointer;
  touch-action: manipulation;
}

button:focus-visible {
  outline: 4px solid #fde047;
  outline-offset: 3px;
}

/* ---------- L-shaped layout: 80% top row, 20% bottom row ---------- */
.app {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-columns: 30% 70%;
  grid-template-rows: 80% 20%;
  grid-template-areas: "inventory stage" "nav nav";
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.app.is-photo {
  grid-template-columns: 0 1fr;
  grid-template-rows: 1fr 0;
}

.app.is-photo .inventory,
.app.is-photo .categories {
  visibility: hidden;
}

/* ---------- inventory ---------- */
.inventory {
  grid-area: inventory;
  min-height: 0;
  min-width: 0;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--paper);
}

.palette {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.swatch {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--swatch);
  border: 5px solid #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.swatch[aria-pressed="true"] {
  outline: 4px solid var(--ink);
  outline-offset: 2px;
}

.items {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  align-content: start;
}

.item {
  min-height: 84px;
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
  padding: 6px;
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.12);
  font-size: 28px;
  font-weight: 700;
}

.item svg {
  width: 100%;
  height: 100%;
}

.item[aria-pressed="true"] {
  outline: 5px solid var(--accent);
  outline-offset: 2px;
}

.soon {
  grid-column: 1 / -1;
  text-align: center;
  font-weight: 700;
}

/* ---------- stage ---------- */
.stage {
  grid-area: stage;
  position: relative;
  min-height: 0;
  min-width: 0;
  display: grid;
  place-items: center;
  touch-action: none;
}

#character-stage {
  display: block;
  height: 100%;
  width: auto;
  max-width: 100%;
  aspect-ratio: 5 / 8;
}

.fab {
  position: absolute;
  top: 10px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.15);
  font-size: 28px;
  display: grid;
  place-items: center;
  z-index: 2;
}

.fab-1 {
  inset-inline-start: 10px;
}

.fab-2 {
  inset-inline-start: 84px;
}

.fab-end {
  inset-inline-end: 10px;
}

.photo-bar {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
  z-index: 2;
}

.pose-btn {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #fff;
  font-size: 28px;
  display: grid;
  place-items: center;
}

.pose-btn[aria-pressed="true"] {
  outline: 4px solid var(--accent);
  outline-offset: 2px;
}

.snap {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 38px;
  box-shadow: 0 6px 0 #be185d;
}

/* ---------- category bar ---------- */
.categories {
  grid-area: nav;
  min-height: 0;
  display: flex;
  gap: 12px;
  padding: 10px 14px;
  overflow-x: auto;
  scrollbar-width: none;
  background: var(--paper);
}

.categories::-webkit-scrollbar {
  display: none;
}

.cat-btn {
  flex: 0 0 auto;
  min-width: 84px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 6px 10px;
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.12);
  font-size: 14px;
  font-weight: 700;
  transition: transform 0.15s ease;
}

.cat-btn .ico {
  font-size: 26px;
  line-height: 1;
}

.cat-btn[aria-pressed="true"] {
  background: var(--accent);
  color: #fff;
  transform: translateY(-4px);
}

/* ---------- feedback ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 22vh;
  transform: translate(-50%, 8px);
  padding: 12px 20px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 10;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.flash {
  position: fixed;
  inset: 0;
  background: #fff;
  opacity: 0;
  pointer-events: none;
  z-index: 30;
}

.flash.go {
  animation: flash 0.45s ease-out;
}

@keyframes flash {
  from { opacity: 0.85; }
  to { opacity: 0; }
}

/* ---------- photo sheet ---------- */
.sheet {
  width: min(92vw, 560px);
  max-height: 92dvh;
  padding: 16px;
  border: 0;
  border-radius: 28px;
  background: #fff;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

.sheet::backdrop {
  background: rgba(31, 41, 55, 0.55);
}

.sheet img {
  display: block;
  width: 100%;
  max-height: 60dvh;
  object-fit: contain;
  border-radius: 16px;
  background: #f9fafb;
}

.sheet-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 14px;
}

.sheet-btn {
  min-height: 64px;
  padding: 10px 18px;
  border-radius: 20px;
  background: #f3f4f6;
  font-size: 18px;
  font-weight: 700;
}

.gate {
  margin-top: 14px;
  text-align: center;
  font-size: 18px;
}

.gate-opt {
  width: 72px;
  height: 72px;
  margin: 6px;
  border-radius: 16px;
  background: #f3f4f6;
  font-size: 26px;
  font-weight: 700;
}

/* ---------- portrait overlay: the game is landscape only ---------- */
#rotate-hint {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 40;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  background: #fdf2f8;
  font-size: 22px;
  font-weight: 700;
  text-align: center;
}

#rotate-hint .phone {
  font-size: 64px;
  animation: turn 2.4s ease-in-out infinite;
}

@keyframes turn {
  0%, 15% { transform: rotate(0deg); }
  50%, 100% { transform: rotate(90deg); }
}

@media (orientation: portrait) {
  #rotate-hint {
    display: flex;
  }

  .app {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  #rotate-hint .phone {
    animation: none;
  }

  .cat-btn {
    transition: none;
  }
}
