/* Play Corner base: reset, page, typography, focus, motion. RTL-first, logical properties only. */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  background: var(--pc-bg);
  color-scheme: light;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--pc-font);
  font-size: var(--pc-text);
  line-height: var(--pc-leading);
  color: var(--pc-ink);
  background: var(--pc-bg);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* App root: centered column, 320–560px, safe-area aware */
#app {
  position: relative;
  max-inline-size: var(--pc-max);
  min-block-size: 100vh;
  min-block-size: 100dvh;
  margin-inline: auto;
  padding-block-end: calc(var(--pc-space-6) + var(--pc-safe-bottom));
  padding-inline-start: var(--pc-safe-start);
  padding-inline-end: var(--pc-safe-end);
  outline: none;
}

/* Full-screen places (the house, a minigame, the login): the screen paints the whole window and sizes its own
   content and safe areas, instead of sitting in the app column. */
#app:has(> .hs, > .fz.is-playing, > .hi) {
  max-inline-size: none;
  padding: 0;
}

[hidden] {
  display: none !important;
}

img,
svg,
canvas,
video,
iframe {
  display: block;
  max-inline-size: 100%;
}

img {
  block-size: auto;
}

h1,
h2,
h3,
h4,
p,
ul,
ol,
figure {
  margin: 0;
}

h1,
h2,
h3,
h4 {
  line-height: var(--pc-leading-tight);
  font-weight: 800;
  letter-spacing: 0;
}

h1 { font-size: var(--pc-text-2xl); }
h2 { font-size: var(--pc-text-xl); }
h3 { font-size: var(--pc-text-lg); }
h4 { font-size: var(--pc-text-md); }

p {
  max-inline-size: 60ch;
}

ul,
ol {
  padding: 0;
  list-style: none;
}

a {
  color: inherit;
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
}

button {
  cursor: pointer;
  border: 0;
  background: none;
  padding: 0;
  touch-action: manipulation;
}

button:disabled {
  cursor: default;
}

input,
textarea,
select {
  min-block-size: var(--pc-touch);
}

::selection {
  background: var(--pc-yellow-soft);
}

/* Focus: always visible for keyboard users; never for mouse/touch */
:focus {
  outline: none;
}

:focus-visible {
  outline: 3px solid var(--pc-focus-color);
  outline-offset: 3px;
  box-shadow: 0 0 0 7px var(--pc-focus-halo);
  border-radius: var(--pc-radius-sm);
}

/* Headings and containers focused by the router (tabindex=-1) show no ring */
[tabindex="-1"]:focus,
[tabindex="-1"]:focus-visible {
  outline: none;
  box-shadow: none;
}

/* Screen reader only */
.pc-sr-only {
  position: absolute !important;
  inline-size: 1px;
  block-size: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Skip link */
.pc-skip {
  position: absolute;
  inset-inline-start: var(--pc-space-3);
  inset-block-start: calc(var(--pc-space-3) + var(--pc-safe-top));
  z-index: var(--pc-z-toast);
  padding: var(--pc-space-2) var(--pc-space-4);
  border-radius: var(--pc-radius-pill);
  background: var(--pc-ink);
  color: #fff;
  font-weight: 700;
  transform: translateY(-200%);
}

.pc-skip:focus-visible {
  transform: none;
}

/* Western digits inside Arabic text keep reading order */
.pc-num {
  font-variant-numeric: tabular-nums;
  unicode-bidi: isolate;
}

/* Boot splash shown by index.html until the first screen renders */
.pc-boot {
  display: grid;
  place-items: center;
  gap: var(--pc-space-4);
  min-block-size: 70vh;
  text-align: center;
  color: var(--pc-muted);
}

.pc-boot__sun {
  inline-size: 72px;
  block-size: 72px;
  border-radius: 50%;
  background: var(--pc-yellow);
  box-shadow: 0 0 0 12px var(--pc-yellow-soft);
  animation: pc-pulse 1.4s var(--pc-ease) infinite alternate;
}

@keyframes pc-pulse {
  from { transform: scale(0.92); }
  to { transform: scale(1.04); }
}

@keyframes pc-fade-up {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

@keyframes pc-pop-in {
  0% { opacity: 0; transform: scale(0.8); }
  70% { opacity: 1; transform: scale(1.04); }
  100% { opacity: 1; transform: scale(1); }
}

@keyframes pc-spin {
  to { transform: rotate(360deg); }
}

/* Lock page scroll while a dialog is open */
body.pc-no-scroll {
  overflow: hidden;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
