/* The game is one viewport; only an explicitly opened sheet can scroll. */
#mobile-menu-open { display: none; }
#mobile-menu { width: 400px; max-width: calc(100% - 16px); padding: 0; }
.mobile-menu-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid #dce4d5; }
.mobile-menu-heading h2 { margin: 0; padding: 0; font-size: 22px; }
#mobile-menu-close { width: 44px; min-height: 44px; border-radius: 8px; background: #edf2e7; color: #365331; font-size: 24px; }
#mobile-menu-scroll { min-height: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; padding: 16px; }
#mobile-menu-tools { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding-bottom: 16px; border-bottom: 1px solid #dce4d5; }
#mobile-menu-tools #header-profile { flex: 1 1 calc(100% - 52px); max-width: none; width: auto; border: 1px solid #d5dfce; background: #edf2e7; }
#mobile-menu-tools #header-nickname { display: block; max-width: none; }
#mobile-menu-tools #help-open { width: auto; min-height: 44px; padding: 8px 12px; font-size: 14px; border: 1px solid #d5dfce; background: #edf2e7; }
#mobile-menu-tools #connection { display: block; flex: 1 0 100%; font-size: 12px; overflow-wrap: anywhere; }
#menu-blocks { width: 100%; min-height: 44px; margin: 16px 0; padding: 10px 12px; text-align: left; border: 1px solid #d5dfce; border-radius: 8px; color: #365331; background: #edf2e7; font-size: 15px; }
#mobile-menu .sidebar { display: flex; gap: 20px; padding: 0; border: 0; overflow: visible; background: none; }
#mobile-menu #inventory-mount { display: none; }
#mobile-menu .sidebar > * { min-width: 0; }
#mobile-menu .together-heading { flex-wrap: wrap; }
#mobile-menu .together-title { margin: 0; }
#mobile-menu .share-button { min-height: 44px; }
#mobile-menu .activity { min-height: 0; }
#mobile-menu .world-footer { padding-bottom: env(safe-area-inset-bottom); }

/* Keep the projection switch beside the map controls at every viewport size. */
#view-mode { position: absolute; top: 230px; right: 26px; z-index: 3; min-width: 120px; min-height: 44px; padding: 8px 12px; border: 1px solid #d4dfcd; border-radius: 8px; background: #f9faf5; color: #4b6656; box-shadow: 0 2px 10px #35473710; font-size: 13px; line-height: 1.3; white-space: nowrap; touch-action: manipulation; }
#view-mode[hidden] { display: none; }
#view-mode[aria-pressed="true"] { border-color: #9fb88e; background: #eaf0e2; color: #365331; }
#view-mode:focus-visible { outline: 3px solid #df8754; outline-offset: 2px; }
@media(max-width:760px) {
  #view-mode { top: 166px; right: 12px; }
}

html[data-mobile-shell="true"], html[data-mobile-shell="true"] body { width: 100%; height: var(--mobile-viewport-height, 100dvh); min-height: 0; overflow: hidden; overscroll-behavior: none; }
html[data-mobile-shell="true"] body { display: flex; flex-direction: column; }
html[data-mobile-shell="true"] .header { flex: 0 0 auto; height: calc(60px + env(safe-area-inset-top)); min-height: 60px; padding: env(safe-area-inset-top) max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left)); gap: 8px; }
html[data-mobile-shell="true"] .header .brand { display: flex; min-width: 0; gap: 7px; }
html[data-mobile-shell="true"] .header .brand>div { display: block; }
html[data-mobile-shell="true"] .header .brand h1 { font-size: 20px; }
html[data-mobile-shell="true"] .header .brand span { display: none; }
html[data-mobile-shell="true"] .header-actions { gap: 6px; flex-shrink: 0; }
html[data-mobile-shell="true"] .account-button { min-width: 84px; max-width: 110px; min-height: 44px; padding: 4px 8px; }
html[data-mobile-shell="true"] #mobile-menu-open { display: inline-flex; align-items: center; justify-content: center; min-width: 48px; min-height: 44px; padding: 8px; border: 1px solid #d5dfce; border-radius: 8px; background: #edf2e7; color: #365331; font: inherit; font-size: 14px; }
html[data-mobile-shell="true"] body > main { flex: 1 1 auto; height: auto; min-height: 0; width: 100%; min-width: 0; display: block; overflow: hidden; }
html[data-mobile-shell="true"] .world-stage { width: 100%; height: 100%; min-height: 0; overflow: hidden; }
html[data-mobile-shell="true"] #world { width: 100%; height: 100%; }
html[data-mobile-shell="true"] #mobile-menu[open] { position: fixed; inset: 0 0 0 auto; display: flex; flex-direction: column; width: min(400px, 100%); max-width: 100%; height: var(--mobile-viewport-height, 100dvh); max-height: var(--mobile-viewport-height, 100dvh); margin: 0; border-radius: 16px 0 0 16px; overflow: hidden; }
html[data-mobile-shell="true"] .mobile-menu-heading { flex-shrink: 0; padding-top: max(12px, env(safe-area-inset-top)); }
html[data-mobile-shell="true"] #mobile-menu-scroll { flex: 1; }
html[data-mobile-shell="true"] dialog { max-height: calc(var(--mobile-viewport-height, 100dvh) - 16px); max-width: calc(100% - 16px); overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; overflow-wrap: anywhere; }
html[data-mobile-shell="true"] #inventory-dialog { max-width: 100%; }
html[data-mobile-shell="true"] #inventory-dialog, html[data-mobile-shell="true"] #inventory-dialog-content, html[data-mobile-shell="true"] #inventory-dialog .inventory-panel { max-height: calc(var(--mobile-viewport-height, 100dvh) - 16px); }
html[data-mobile-shell="true"] :is(#scope-panel, #edit-extras) { max-height: calc(var(--mobile-viewport-height, 100dvh) - 160px); overflow-y: auto; overscroll-behavior: contain; }
html[data-mobile-shell="true"] .world-links { min-width: 0; }
html[data-mobile-shell="true"] .world-links > button { min-width: 0; }
#mobile-menu-open:focus-visible, #mobile-menu-close:focus-visible, #menu-blocks:focus-visible { outline: 3px solid #df8754; outline-offset: 2px; }

#settings-open { display: inline-flex; align-items: center; justify-content: center; min-width: 48px; min-height: 44px; padding: 8px 12px; border: 1px solid #d5dfce; border-radius: 8px; background: #edf2e7; color: #365331; font: inherit; font-size: 14px; }
#settings-dialog { width: 420px; padding: 24px; }
.settings-heading { position: sticky; top: -24px; z-index: 2; display: flex; justify-content: space-between; align-items: center; gap: 12px; background: #f8faf3; }
.settings-heading h2 { margin: 6px 0 0; }
#settings-close { flex-shrink: 0; width: 44px; min-height: 44px; border-radius: 8px; background: #edf2e7; color: #365331; font-size: 24px; }
.settings-section { margin-top: 24px; padding-top: 20px; border-top: 1px solid #dce4d5; }
.settings-section h3, .settings-section label { display: block; margin: 0; color: #365331; font-size: 16px; font-weight: 600; }
.settings-section p { margin: 8px 0 14px; font-size: 13px; line-height: 1.6; }
.settings-section small { display: block; margin-top: 10px; color: #75866c; font-size: 12px; line-height: 1.5; }
.settings-section .sound-toggle { display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: 14px; cursor: pointer; }
#edit-sound-enabled { width: 20px; height: 20px; margin: 0; accent-color: #52784c; }
.sound-tone { min-width: 0; margin: 12px 0 0; padding: 0; border: 0; }
.sound-tone legend { padding: 0; margin-bottom: 8px; color: #365331; font-size: 13px; font-weight: 600; }
.sound-tone-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.settings-section .sound-tone-options label { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 8px 12px; border: 1px solid #d5dfce; border-radius: 8px; font-size: 14px; cursor: pointer; }
.sound-tone-options input { flex-shrink: 0; width: 18px; height: 18px; margin: 0; accent-color: #52784c; }
.sound-tone-options label:has(input:checked) { border-color: #52784c; background: #eaf0e2; }
.sound-tone-options label:has(input:focus-visible) { outline: 3px solid #df8754; outline-offset: 2px; }
.sound-tone-options label:has(input:disabled) { opacity: .45; cursor: default; }
.sound-volume-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; }
.sound-volume-heading label, #edit-sound-value { font-size: 13px; }
#edit-sound-volume { width: 100%; min-height: 44px; margin: 0; accent-color: #52784c; cursor: pointer; }
#edit-sound-volume:disabled { opacity: .45; cursor: default; }
#edit-sound-enabled:focus-visible, #edit-sound-volume:focus-visible { outline: 3px solid #df8754; outline-offset: 3px; }
#settings-dialog .language-select { width: 100%; max-width: none; min-height: 48px; padding: 10px 12px; font-size: 16px; }
.settings-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.settings-links { display: flex; flex-wrap: wrap; gap: 0 16px; margin-top: 20px; padding-top: 12px; border-top: 1px solid #dce4d5; }
.settings-links a, .account-privacy a { display: inline-flex; align-items: center; min-height: 44px; color: #365331; font-size: 13px; line-height: 1.5; text-underline-offset: 3px; }
.settings-links a:focus-visible, .account-privacy a:focus-visible { outline: 3px solid #df8754; outline-offset: 2px; }
.account-privacy { margin: 8px 0 0; text-align: center; }
#settings-dialog #profile-settings, #settings-account { display: inline-flex; flex: 1 1 130px; align-items: center; justify-content: center; width: auto; min-width: 0; min-height: 44px; padding: 10px 12px; border: 1px solid #d5dfce; border-radius: 8px; background: #edf2e7; color: #365331; font: inherit; font-size: 14px; }
#settings-open:focus-visible, #settings-close:focus-visible, #settings-account:focus-visible { outline: 3px solid #df8754; outline-offset: 2px; }

@media(max-width:370px) {
  html[lang="en"][data-mobile-shell="true"] #scope-panel .brush-sizes button { font-size: 12px; padding-left: 3px; padding-right: 3px; }
}

@media(max-width:1100px) and (max-height:450px) and (orientation:landscape) {
  html[data-mobile-shell="true"] .header { height: calc(52px + env(safe-area-inset-top)); min-height: 52px; }
  #view-mode { top: 58px; right: 12px; }
  body[data-world-kind="island"] .world-heading { right: 144px; }
}
