/* Loaded after styles.css so the gameplay layout wins the complete legacy cascade. */
@media (max-width: 880px) and (orientation: portrait) {
  #museum-canvas {
    height: 100%;
  }

  .mobile-stick.active,
  .mobile-look:active {
    border-color: var(--cyan);
    color: var(--cyan);
  }

  .mobile-look {
    right: calc(24px + env(safe-area-inset-right));
    bottom: calc(48px + env(safe-area-inset-bottom));
    width: 76px;
    height: 76px;
    border-width: 2px;
    background: rgba(27, 41, 36, 0.98);
    box-shadow: inset 0 0 0 5px rgba(210, 164, 77, 0.08), 0 8px 22px rgba(0, 0, 0, 0.3);
    font-size: 0.64rem;
    touch-action: manipulation;
    user-select: none;
  }

  .room-toast {
    top: 48%;
  }

  .game-wrap.chatting .mobile-stick,
  .game-wrap.chatting .mobile-look {
    opacity: 0;
    pointer-events: none;
  }

  .game-wrap.chatting .museum-chat {
    bottom: calc(8px + env(safe-area-inset-bottom));
  }
}

@media (max-width: 620px) {
  .game-hud {
    top: calc(8px + env(safe-area-inset-top));
    right: 8px;
    left: 8px;
    gap: 6px;
  }

  .hud-room,
  .hud-social {
    min-width: 0;
    padding: 7px 8px;
  }

  .hud-room {
    max-width: 134px;
  }

  .hud-room b,
  .hud-social b {
    font-size: 0.66rem;
    line-height: 1.08;
  }

  .hud-room span,
  .hud-social span {
    font-size: 0.44rem;
  }

  .hud-social {
    min-width: 122px;
  }

  .hud-center {
    min-width: 122px;
  }

  .hud-project-links a,
  .hud-project-links button {
    min-height: 22px;
    padding: 3px 4px;
    font-size: 0.4rem;
  }

  .game-buttons {
    top: calc(76px + env(safe-area-inset-top));
    right: 8px;
    gap: 5px;
  }

  .game-buttons button {
    min-height: 40px;
    padding: 6px 9px;
  }

  .museum-chat {
    right: 8px;
    left: 8px;
    width: auto;
  }

  .chat-head {
    min-height: 36px;
  }

  .chat-head button {
    width: 30px;
    height: 28px;
  }

  .welcome-dialog {
    width: calc(100vw - 16px);
    max-height: calc(100dvh - 16px);
  }

  .welcome-card {
    padding: 22px 16px 18px;
  }

  .welcome-seal {
    width: 46px;
    height: 46px;
    margin-bottom: 9px;
  }

  .welcome-card .kicker,
  .welcome-card h1 {
    margin-bottom: 9px;
  }

  .welcome-card h1 {
    font-size: clamp(2rem, 10vw, 2.8rem);
    line-height: 0.92;
  }

  .welcome-deck {
    margin-bottom: 12px;
    font-size: 0.88rem;
    line-height: 1.35;
  }

  .welcome-links {
    gap: 5px;
    margin-bottom: 10px;
  }

  .welcome-link-slot {
    min-height: 38px;
    gap: 5px;
    padding: 6px;
    font-size: 0.48rem;
  }

  .welcome-ca-slot button {
    padding: 4px;
  }

  .welcome-controls {
    gap: 5px;
    margin-bottom: 12px;
  }

  .welcome-controls span {
    gap: 4px;
    padding: 7px 4px;
  }

  .welcome-actions {
    gap: 6px;
  }

  #chat-input,
  #book-search {
    font-size: 16px;
  }
}

@media (max-width: 430px) and (orientation: portrait) {
  .mobile-stick {
    left: calc(12px + env(safe-area-inset-left));
    width: 118px;
    height: 118px;
  }

  .mobile-look {
    right: calc(18px + env(safe-area-inset-right));
    width: 72px;
    height: 72px;
  }
}

@media (max-width: 880px) and (orientation: landscape) {
  .game-hud {
    justify-content: flex-start;
  }

  .hud-center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
  }

  .hud-progress,
  .game-prompt {
    display: none;
  }

  #museum-canvas {
    height: 100%;
  }

  .mobile-stick {
    bottom: calc(10px + env(safe-area-inset-bottom));
    left: calc(10px + env(safe-area-inset-left));
    width: 112px;
    height: 112px;
  }

  .mobile-look {
    right: calc(12px + env(safe-area-inset-right));
    bottom: calc(14px + env(safe-area-inset-bottom));
  }

  .museum-chat {
    bottom: calc(12px + env(safe-area-inset-bottom));
    left: calc(154px + env(safe-area-inset-left));
    width: min(330px, calc(100% - 250px));
  }

  .welcome-dialog {
    width: min(720px, calc(100vw - 24px));
    max-height: calc(100dvh - 16px);
    overflow: hidden;
  }

  .welcome-card {
    min-height: 0;
    padding: 14px 18px 12px;
  }

  .welcome-card::before {
    inset: 7px;
  }

  .welcome-logo {
    width: min(420px, 52vw);
    margin-bottom: 6px;
  }

  .welcome-card h1 {
    margin-bottom: 6px;
    font-size: clamp(1.75rem, 5.2vw, 2.4rem);
    line-height: 0.88;
  }

  .welcome-deck {
    max-width: 620px;
    margin-bottom: 7px;
    font-size: 0.78rem;
    line-height: 1.24;
  }

  .welcome-links {
    margin-bottom: 7px;
  }

  .welcome-link-slot {
    min-height: 32px;
    padding: 4px 7px;
  }

  .welcome-controls {
    display: none;
  }

  .welcome-actions .button {
    min-height: 40px;
    padding: 8px 16px;
  }

  .welcome-mobile-note {
    margin-top: 4px;
    font-size: 0.42rem;
  }
}
