/* Wending Worlds v2 responsive layer */
/* Tablet */
@media (max-width: 1100px) {
  .principle-grid { grid-template-columns: repeat(2,1fr); }
  .game-columns { grid-template-columns: minmax(0,1fr) 310px; }
  .game-side-left { display: none; }
}

@media (max-width: 980px) {
  .home-hero-inner-v2 {
    grid-template-columns: 1fr;
    gap: 38px;
  }
  .hero-world-stage { width: min(600px,100%); }
  .world-grid-v2 { grid-template-columns: 1fr 1fr; }
  .showcase-layout { grid-template-columns: 1fr; }
  .showcase-cover { min-height: 430px; }
}

/* Mobile-first corrections for iPhone / Android */
@media (max-width: 760px) {
  :root { --header-h: 58px; }

  body {
    background: var(--bg-0);
  }

  .site-header {
    height: calc(58px + env(safe-area-inset-top, 0px));
    padding-top: env(safe-area-inset-top, 0px);
  }

  .site-header-inner {
    width: calc(100% - 24px);
  }

  .brand img {
    width: 34px;
    height: 34px;
  }

  .brand-name {
    font-size: 15px;
  }

  .header-actions .button {
    min-height: 34px;
    padding-inline: 12px;
    font-size: 11px;
  }

  .home-hero-v2 {
    min-height: auto;
  }

  .home-hero-inner-v2 {
    width: calc(100% - 28px);
    padding: 42px 0 82px;
    gap: 30px;
  }

  .hero-copy-v2 h1 {
    margin: 18px 0 15px;
    font-size: clamp(38px, 11.5vw, 50px);
    line-height: 1.12;
  }

  .hero-copy-v2 .hero-lead {
    font-size: 14px;
    line-height: 1.75;
  }

  .hero-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 9px;
    margin-top: 24px;
  }

  .hero-actions .button {
    width: 100%;
  }

  .hero-meta-v2 {
    margin-top: 27px;
  }

  .hero-meta-v2 > div {
    padding-right: 9px;
  }

  .hero-meta-v2 > div + div {
    padding-left: 9px;
  }

  .hero-meta-v2 strong {
    font-size: 18px;
  }

  .hero-world-stage {
    border-radius: 19px;
  }

  .hero-world-cover {
    height: 350px;
  }

  .hero-world-title h2 {
    font-size: 31px;
  }

  .hero-world-footer {
    padding: 16px;
  }

  .announcement-bar-v2 {
    position: absolute;
    padding: 8px 14px;
    font-size: 10px;
  }

  .section {
    padding: 62px 0;
  }

  .worlds-section,
  .showcase-section,
  .faq-section {
    width: calc(100% - 28px);
  }

  .section-heading-v2 h2,
  .section-heading h2 {
    font-size: 31px;
  }

  .world-filter {
    margin-top: -4px;
  }

  .world-grid-v2,
  .principle-grid {
    grid-template-columns: 1fr;
  }

  .world-card-v2 .world-card-art {
    height: 235px;
  }

  .world-card-v2 .world-card-body {
    padding: 18px;
  }

  .world-card-heading h3 {
    font-size: 22px;
  }

  .world-card-description {
    font-size: 12px !important;
  }

  .principle-card {
    min-height: 200px;
  }

  .principle-icon {
    margin-bottom: 34px;
  }

  .showcase-cover {
    min-height: 390px;
  }

  .showcase-copy {
    padding: 26px 20px 30px;
  }

  .showcase-copy h2 {
    font-size: 32px;
  }

  .showcase-facts > div + div {
    padding-left: 10px;
  }

  /* Creator: true app-like single screen */
  .creator-page {
    min-height: 100dvh;
    background: #11130f;
  }

  .creator-bg {
    position: fixed;
    opacity: .16;
    background-position: center top;
  }

  .creator-bg::after {
    background: linear-gradient(to bottom, rgba(13,14,12,.38), #11130f 42%, #11130f);
  }

  .creator-header {
    position: sticky;
    z-index: 20;
    top: 0;
    width: 100%;
    height: calc(54px + env(safe-area-inset-top, 0px));
    padding: env(safe-area-inset-top, 0px) 14px 0;
    border-bottom: 1px solid var(--line);
    background: rgba(17,19,15,.93);
    backdrop-filter: blur(18px);
  }

  .creator-header .brand-copy {
    display: grid;
  }

  .creator-header .brand-sub {
    display: none;
  }

  .creator-header .brand img {
    width: 32px;
    height: 32px;
  }

  .desktop-only-label {
    display: none;
  }

  .creator-layout {
    display: block;
    width: 100%;
    min-height: calc(100dvh - 54px - env(safe-area-inset-top, 0px));
    padding: 0;
  }

  .creator-preview {
    display: none;
  }

  .creator-card {
    width: 100%;
    min-height: calc(100dvh - 54px - env(safe-area-inset-top, 0px));
    padding: 14px 16px 0;
    border: 0;
    border-radius: 0;
    background: rgba(17,19,15,.94);
    box-shadow: none;
    backdrop-filter: blur(12px);
  }

  .creator-card-top {
    min-height: 36px;
    margin: 0 0 10px;
  }

  .creator-mobile-world {
    display: grid;
    min-width: 0;
    gap: 1px;
  }

  .creator-mobile-world span {
    color: var(--world-accent-soft);
    font-size: 8px;
    font-weight: 750;
    letter-spacing: .08em;
  }

  .creator-mobile-world strong {
    overflow: hidden;
    font-family: ui-serif, "Songti SC", serif;
    font-size: 15px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .creator-mobile-world small {
    color: var(--text-3);
    font-size: 8px;
  }

  .restore-cloud-inline {
    flex: 0 0 auto;
    min-height: 31px;
    padding-inline: 9px;
    font-size: 9px;
  }

  .creator-progress-v2 {
    margin-bottom: 14px;
  }

  .creator-progress-dots {
    display: none;
  }

  .creator-step-wrap {
    min-height: 0;
  }

  .creator-step {
    padding-bottom: 4px;
  }

  .creator-step h2 {
    margin: 5px 0 5px;
    font-size: 25px;
    line-height: 1.2;
  }

  .creator-step > p {
    margin-bottom: 13px;
    font-size: 11px;
    line-height: 1.55;
  }

  .step-kicker {
    font-size: 8px;
  }

  .text-input-large {
    height: 48px;
    font-size: 16px;
  }

  .name-suggestions {
    gap: 6px;
  }

  .name-suggestions button {
    padding: 6px 9px;
    font-size: 10px;
  }

  .creation-grid {
    gap: 7px;
  }

  .creation-option {
    min-height: 62px;
    padding: 8px 10px;
  }

  .creation-option-icon {
    width: 36px;
    height: 36px;
  }

  .creation-option p {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .creator-featured-options {
    gap: 6px;
    margin-bottom: 10px;
  }

  .creator-featured-chip {
    min-height: 35px;
    padding: 0 9px;
    font-size: 9px;
  }

  .creator-select {
    height: 42px;
    font-size: 12px;
  }

  .creator-selection-preview {
    grid-template-columns: 34px minmax(0,1fr) auto;
    padding: 9px;
  }

  .selection-preview-mark {
    width: 34px;
    height: 34px;
  }

  .creator-selection-preview p {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .creator-summary {
    margin-top: 9px;
    padding: 9px;
  }

  .world-legal-note {
    margin-top: 8px;
    padding: 7px 9px;
  }

  .world-legal-note p {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .creator-actions {
    position: sticky;
    z-index: 10;
    bottom: 0;
    margin: auto -16px 0;
    padding: 11px 16px calc(11px + env(safe-area-inset-bottom, 0px));
    background: linear-gradient(to top, #11130f 72%, rgba(17,19,15,.92));
  }

  .creator-actions .button {
    min-height: 44px;
  }

  .creator-actions .button-primary {
    flex: 1;
  }

  .creator-notice {
    display: none;
  }

  /* Game: avoid Safari toolbar and keep controls reachable */
  .play-root {
    min-height: 100dvh;
    height: 100dvh;
  }

  .game-app {
    height: 100dvh;
    grid-template-rows: calc(54px + env(safe-area-inset-top, 0px)) minmax(0,1fr) calc(58px + env(safe-area-inset-bottom, 0px));
  }

  .game-header {
    height: auto;
    padding: env(safe-area-inset-top, 0px) 10px 0;
    grid-template-columns: minmax(0,1fr) auto;
  }

  .game-header-left {
    min-width: 0;
    gap: 8px;
  }

  .game-back-button {
    width: 34px;
    height: 34px;
  }

  .game-world-mark {
    width: 32px;
    height: 32px;
  }

  .game-title-copy strong {
    max-width: min(48vw, 190px);
    font-size: 11px;
  }

  .game-title-copy span {
    font-size: 8px;
  }

  .game-header-right .icon-button {
    width: 34px;
    height: 34px;
  }

  .game-columns {
    display: block;
    min-height: 0;
    overflow: hidden;
  }

  .game-side,
  .game-center {
    display: none;
    height: 100%;
  }

  .mobile-view-stats .game-side-left {
    display: block;
    border: 0;
    padding: 12px 12px calc(18px + env(safe-area-inset-bottom,0px));
  }

  .mobile-view-story .game-center {
    display: grid;
  }

  .mobile-view-phone .game-side-right {
    display: block;
    border: 0;
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom,0px));
  }

  .game-center {
    grid-template-rows: 44px minmax(0,1fr);
  }

  .game-center-toolbar {
    padding: 0 10px;
  }

  .world-position strong {
    font-size: 10px;
  }

  .world-position span {
    font-size: 8px;
  }

  .story-scroll {
    padding: 12px 11px calc(20px + env(safe-area-inset-bottom,0px));
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  .world-legal-banner {
    margin-bottom: 10px;
    padding: 7px 9px;
  }

  .world-legal-banner span {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .story-timeline {
    gap: 10px;
  }

  .story-card {
    padding: 16px 14px;
    border-radius: 14px;
  }

  .story-card-head {
    margin-bottom: 12px;
  }

  .story-body {
    font-size: calc(14.5px * var(--reader-scale));
    line-height: 1.9;
  }

  .story-body p + p {
    margin-top: 12px;
  }

  .ai-content-badge {
    padding: 4px 6px;
  }

  .story-composer {
    margin-top: 12px;
    padding: 12px;
    border-radius: 14px;
  }

  .composer-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
  }

  .composer-head > div > p {
    display: none;
  }

  .choice-list {
    gap: 6px;
  }

  .choice-button {
    min-height: 46px;
    padding: 7px 9px;
  }

  .choice-label {
    font-size: 10px;
  }

  .free-action textarea {
    min-height: 62px;
    padding: 10px 44px 20px 11px;
    font-size: 10px;
  }

  .send-button {
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
  }

  .mobile-game-nav {
    height: calc(58px + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    border-top-color: var(--line);
  }

  .mobile-game-nav-item {
    min-height: 58px;
    font-size: 8px;
  }

  .jade-phone {
    border-radius: 15px;
  }

  .phone-app {
    padding: 11px;
  }

  .toast-stack {
    bottom: calc(66px + env(safe-area-inset-bottom,0px));
  }

  .modal-overlay {
    padding: 12px 12px calc(12px + env(safe-area-inset-bottom,0px));
  }

  .modal-panel {
    max-height: calc(100dvh - 24px - env(safe-area-inset-top,0px) - env(safe-area-inset-bottom,0px));
    overflow-y: auto;
  }

  .settings-action-grid {
    grid-template-columns: 1fr;
  }

  .admin-sidebar {
    height: calc(62px + env(safe-area-inset-bottom,0px));
    padding-bottom: env(safe-area-inset-bottom,0px);
  }

  .admin-main {
    padding-bottom: calc(78px + env(safe-area-inset-bottom,0px));
  }
}

@media (max-width: 390px) {
  .hero-copy-v2 h1 { font-size: 38px; }
  .hero-world-cover { height: 320px; }
  .creation-option { min-height: 59px; }
  .creation-option p { -webkit-line-clamp: 1; }
  .creator-step h2 { font-size: 23px; }
  .creator-featured-options { grid-template-columns: 1fr 1fr; }
  .world-card-bottom small { max-width: 62%; }
}

@media (prefers-reduced-motion: reduce) {
  .hero-world-cover > img,
  .creator-progress-track > div,
  .world-card-v2,
  .button {
    transition: none !important;
  }
}

/* V2 multi-world admin cards */
.admin-world-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.admin-world-card {
  display: grid;
  min-width: 0;
  grid-template-columns: 150px minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(245, 239, 225, 0.022);
}

.admin-world-cover {
  position: relative;
  min-height: 190px;
  overflow: hidden;
  background: #0b0c0b;
}

.admin-world-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.admin-world-cover::after {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(8, 9, 8, .48), transparent 55%);
  content: "";
}

.admin-world-number {
  position: absolute;
  z-index: 1;
  left: 10px;
  bottom: 9px;
  color: #eee8db;
  font-family: monospace;
  font-size: 11px;
  letter-spacing: .12em;
}

.admin-world-body {
  display: grid;
  align-content: start;
  gap: 10px;
  min-width: 0;
  padding: 16px;
}

.admin-world-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.admin-world-heading h3 {
  margin: 0 0 3px;
  font-family: ui-serif, "Songti SC", Georgia, serif;
  font-size: 17px;
}

.admin-world-heading p,
.admin-world-description {
  margin: 0;
  color: var(--text-3);
  font-size: 9px;
  line-height: 1.6;
}

.world-policy-badge {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 8px;
  color: var(--text-2);
  font-size: 8px;
  white-space: nowrap;
}

.world-policy-badge.commercial {
  border-color: rgba(130, 170, 134, .22);
  background: rgba(130, 170, 134, .06);
  color: #b9d4bb;
}

.world-policy-badge.fan {
  border-color: rgba(216, 166, 107, .25);
  background: rgba(216, 166, 107, .06);
  color: #dfc698;
}

.admin-world-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.admin-world-meta span {
  border-radius: 999px;
  padding: 4px 7px;
  background: rgba(245, 239, 225, .045);
  color: var(--text-2);
  font-size: 8px;
}

.admin-world-notice {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  border-left: 2px solid var(--amber);
  padding-left: 8px;
  color: #cbbd9e;
  font-size: 8px;
  line-height: 1.55;
}

.admin-world-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: auto;
}

.admin-world-actions code {
  overflow: hidden;
  color: var(--text-3);
  font-size: 8px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 1180px) {
  .admin-world-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .world-grid-v2 {
    display: flex;
    width: auto;
    margin-right: -14px;
    padding: 2px 14px 12px 0;
    gap: 12px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
  }

  .world-grid-v2::-webkit-scrollbar { display: none; }

  .world-card-v2 {
    flex: 0 0 min(82vw, 330px);
    scroll-snap-align: start;
  }

  .admin-nav {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .admin-world-grid { grid-template-columns: 1fr; }

  .admin-world-card {
    grid-template-columns: 104px minmax(0, 1fr);
  }

  .admin-world-cover { min-height: 176px; }
  .admin-world-body { padding: 12px; }
  .admin-world-heading { display: grid; gap: 7px; }
  .world-policy-badge { justify-self: start; }
  .admin-world-description,
  .admin-world-notice { display: none; }
}
